Deploying Ubiquiti UniFi APs with a RaspberryPi 2 Controller

I recently got fed up with the mediocre coverage and speeds of my home wireless network even after throwing DD-WRT on the pair of APs (Netgear and Linksys .11n) to eek out all the performance I could.  So I decided to take the plunge and go up market a bit with a couple APs from Ubiquiti Networks.

Ubiquiti UniFi APsI went with a pair of UAP (.11n) and UA-AC-LR (.11ac) units for a mix of coverage in light usage areas and better performance in high usage areas, along with a RaspberryPi 2 to act as the controller.    Since the UniFi APs are becoming more popular among home users, and I can’t be the only one wary of putting management functions in the cloud, I decided to document the setup process.

Step 1: Gather needed parts

  1. RPi2
    1. 5v micro-usb power source
    2. Ethernet cable
    3. MicroSD card
  2. Ubiquiti UniFi APs
    1. patch cables (2x per AP)

Step 2: Burn Raspian (these instructions based upon Hypriot 0.6.1) to a MicroSD card

Step 3: Cable up APs and plug into the network

Step 4: Turn on RPi2

  1. Scan network to determine IP or look in your router’s DHCP lease table
  2. SSH to RPi2
  3. Assign static IP
    1. Open /etc/network/interfaces in your preferred text editor
    2. Adjust the below guide for your networkiface eth0 inet static
      address xxx.xxx.xxx.xxx
      gateway xxx.xxx.xxx.xxx
      netmask xxx.xxx.xxx.xxx
      network xxx.xxx.xxx.xxx
      broadcast xxx.xxx.xxx.xxx
    3. Save and exit
    4. Restart networking
      /etc/init.d/networking restart
  4. Upgrade Raspian
    apt-get update; apt-get dist-upgrade
  5. Upgrade RPi firmware
    rpi-update

Step 5: Install UniFi Controller (Source Guide)

  1. Add the UniFi respository
    1. Open /etc/apt/sources.list.d/ubnt.list in your preferred text editor
    2. Add the following line
      deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti
    3. Save and exit
  2. Add Ubiquiti’s signing key
    apt-key adv –keyserver keyserver.ubuntu.com –recv C0A52C50
  3. Update sources and install UniFi along with dependencies
    apt-get update; apt-get install unifi -y
  4. Disable default MongoDB instance
    1. Open /etc/mongodb.conf in your preferred text editor
    2. At the end of the file add the followingENABLE_MONGODB=no
    3. Save and exit
  5. Reboot

Step 6: Configure your UniFi environment

  1. Point your browser to https://<ControllerIP>:8443/
  2. Set your timezone and country
  3. Select any unmanaged UniFi APs (or other UniFi devices) showing up
  4. Set your SSID and Key
  5. Set the username and password for your initial administrator account
  6. Click finish and then login

Step 7: Install and Configure Syslog

  1. Install syslog-ng
    apt-get install syslog-ng -y
  2. Open /etc/syslog-ng/syslog-ng.conf in your preferred text editor and add the below
    1. Add the following to accept syslog over UDP/514 from remote sources# Listen on both TCP/514 and UDP/514 on all IPs
      source s_net { tcp(port(514)); udp(); };
    2. Add the following to set the destination for syslog data# Set the log destination for the Ubiquiti UniFi Controller
      destination d_unifi { file(“/var/log/Ubiquiti/UniFi.log”); };
    3. Add the following for the log path#Set the logging for Ubiquiti UniFi
      log { source(s_net); destination(d_unifi); };
    4. Save and exit
  3. Create the log file
    mkdir /var/log/Ubiquiti
    touch /var/log/Ubiquiti/UniFi.log
  4. Restart syslog-ng
    service syslog-ng restart
  5. Set log rotation
    1. Open /etc/logrotate.conf in your text editor of choice and add the below
      This will rotate the above set syslogs and the logs created by the UniFi installer on a weekly basis# Rotate Ubiquiti logs
      /var/log/Ubiquiti/*/ {
      missingok
      weekly
      rotate 5
      create

      }/var/log/unifi/*/ {
      missingok
      weekly
      rotate 5
      create
      }

Step 8: Point UniFi Controller to Syslog

  1. Log into your controller and click Settings in the lower left
  2. Under the Services heading find Remote Logging and click the check box
  3. Enter the IP of your Raspberry Pi
  4. Click Apply

For the next post in this series we’ll step through installing an ELK stack and use it to monitor the syslog feed we setup along with the UniFi controller logs.

  • Sami Fantar

    Hi ! I’m really interesting about your tweaking 🙂 What kind of logs did you received from Unifi Controller ?

    Sami

    • Michael

      It largely depends on what parts of the UniFi system you’ve got deployed, but lots of chatter from the APs in regards to clients associating/disassociating mainly.