Skip to content

Self-Hosting the Ubiquiti UniFi Controller

For a while now, I’ve been using UniFi at home, and have since been impressed with its reliability and capabilities. Though, I have only purchased the Unifi AP’s, and no other Ubiquiti networking equipment (so far) because, well, I can’t afford it lol.

To operate UniFi AP’s to a decent extent, you really need to run a UniFi controller. I self-host this in an Ubuntu 18.04 LTS Linux Container, and haven’t had an issue. I would like to share how to install and operate the UniFi Controller.

Installation (Ubuntu)

I use this support article supplied by Ubiquiti. This outlines a procedure to install the UniFi Controller through APT package managers. I prefer it over downloading the .deb package file because it allows for simplified upgrades through apt update; apt upgrade -y.

1. Install ca-certificates and apt-transport-https.

sudo apt-get update
sudo apt-get install ca-certificates apt-transport-https gnupg

2. Add the MongoDB and Unifi Keys.

wget -qO - | sudo apt-key add -
sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg 

3. Add the MongoDB and Unifi sources list and then update.

echo "deb xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
echo 'deb stable ubiquiti' | sudo tee /etc/apt/sources.list.d/ubnt-unifi.list
sudo apt update

4. Install OpenJDK 8 and Unifi. For me, this was roughly 968MB and installed quite a lot of other package dependencies.

sudo apt install openjdk-8-jre unifi

5. Make sure the service has started and is enabled. A couple things you’re looking for here is that the service is active (running) and enabled. This means that the process is running, and if you reboot the computer, systemd will start it up again.

[email protected]:~$ systemctl status unifi
● unifi.service - unifi
   Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-11-12 06:08:45 UTC; 4min 16s ago
 Main PID: 5616 (jsvc)
    Tasks: 116 (limit: 1104)
   CGroup: /system.slice/unifi.service

Initial Setup

Once you’re all setup, you can open your preferred web browser and go to port 8443 on the machine you installed UniFi on. You’ll be greeted with an initial configuration page.

1. Give the controller an appropriate name. I tend to just use the host name of the server, or something like “UniFi Controller Canberra”. You’ll also need to agree to the EULA on this page. Click the box, then go “Next”.

2. Ubiquiti has a fancy remote control feature, where you can administrate your network from afar. If you have an account, you can sign in here. You don’t have to do this though. Personally, I’m not a fan and I prefer to keep these things off the internet. If you click “Advanced Setup” you can disable remote access and create a local account to authenticate with instead, which is what I do. Sorry Ubiquiti!

3. I keep network optimisation on, it helps with wireless performance and saves me from having to fiddle with it too much. I also keep Auto Backup enabled too.

4. If you already have your devices ready to go, you can add them here. Otherwise, you can add them later once you’ve logged into the main interface.

5. Step five will offer to create a WiFi network, I perfer not to do it here just so I can have a bit more control over the configuration. By all means though! If you’re comfortable with standard settings, you can create your network here. Otherwise, click “Skip”.

6. Review your configuration. Set your locale, then click “Finished”. You should be moved into the main configuration.


Classic (Advanced) Dashboard

Ubiquiti has really tried to clean up the interface recently, and I appreciate their efforts. Though I’ve found that they’ve hidden a lot of the settings to allow for a more user friendly experience, and placed adverts for their other products on the homepage (Grrrr).

I don’t see it as an issue if you would prefer to use the modern dashboard, but I’ve found the classic dashboard more intuitive for advanced configuration. Personal preference! If you don’t plan on delving into VLANs, RADIUS Authentication, and Radio Settings then you’re welcome to stick in the modern dashboard.

To switch over, click the gear at the bottom left. Go to “System”, and disable “New User Interface”.

Updating the Default Network.

Before adding your new network, I advise to do this first.

Ubiquiti pre-adds a standard after installation. I like to make sure the details of this network, and any other sub-networks I’m running in my network are correct on UniFi. It helps me with extending them to a Wireless network easier later.

  1. Click the gear at the bottom left, and navigate to the “Networks” tab.
  2. You’ll see the “LAN” network already added there, click “Edit”.
  3. In our case, because we’ve installed the controller on some server, the settings in here largely won’t matter. Though updating the stuff in here makes it easier for us to manager later, particularly when we get into VLANs.
  4. Give your network Name, and set any other details here where you see fit. I tend to just all this network “Unsecured” or “IoT”, because it resides on VLAN 1 (default VLAN). Then click save.

Adding a New Network (VLAN)

This is useful if you do not have a USG. We can create multiple logical networks on our one phyiscal network through the use of VLANs.

This is not required if you just want to create a simple WiFi network. I’ll cover that in the next section.

  1. Go back to the “Networks” tab and click “Add Network”.
  2. Give the new network a Name.
  3. Set the VLAN to whatever the VLAN ID is of your network. UniFi devices are VLAN aware, you must first make sure that you’re pushing tagged VLAN packets to your UniFi AP’s first in your switch!
  4. Specify the Gateway IP/Subnet, Domain Name, and DHCP Range. If you’re not using UniFi as a DHCP server then none of this really matters, this only applies to those using USGs. I like to put in the correct details anyway.
  5. Click Save.

You now need to broadcast this network no your Access Points. In the next section for adding a new network, specify this network you have now just created.

Adding a New Wireless Network

  1. Click the gear at the bottom left, and navigate to the “Wireless Networks” tab. Then, click “Create new Wireless Network”.
  2. Give your wireless network a distinct Name/SSID, this is what will be broadcasted.
  3. Specify how you’d like to secure the network. Word of advice; avoid WEP. WPA Personal is perfectly reasonable for most installations, WPA Enterprise allows you to authenticate users against a RADIUS server (requires configuration prior to creating the network). I usually enable WPA3 and WPA3 Transition Mode as well.
  4. Select the Network the Wireless Network belongs to from the drop down list. If you’re using VLANs, specify the VLAN we created earlier.
  5. Generally, you won’t need to change the Advanced Options. But here, you can specify which AP’s you’d like this network to be broadcast on, and any other funky settings!
  6. Click “Save”.

Upgrading the UniFi Controller

Because we’ve installed UniFi through a repository and package manager, upgrading UniFi is relatively straight forward. At times, when you login you’ll get a pop-up saying there’s a new release of the application.

To upgrade, SSH to the server and simply do the following;

sudo apt update
sudo apt upgrade

Leave a Reply

Your email address will not be published. Required fields are marked *