Unifi GCP

I’ve been a big fan of Unifi for several years now. I run a combination of AP’s, switches and a USG at home. The hardware is nothing special. underneath you will find various bits of software that keep these devices running like iptables and vyatta.

What makes these devices stand out from other (expensive) products is the controller. The controller provides you with a simple interface to configure networks, firewall rules, view analytics and just about anything. You can demo the controller software online which is quite neat.

Previously I ran the controller at home on a server, but this was a bit of an issue for several reasons. Running a server 24x7 can chew through a fair bit of power, they generate heat (not ideal in the warmer months) and my server isn’t exactly quiet.

For that reason, I decided to run my controller in “the cloud”. I have run it in Azure, AWS and now in GCP. All of the major cloud providers will happily run the controller with minimal requirements, but for now I am using GCP. There are a few challenges with running a controller in the cloud, and one that appears to be specific to GCP and Azure (though I wasn’t able to confirm that at the time of writing). One challenge was also not having a static IP address at home.

For this guide, I will be using Ubuntu 16.04. Not because I am old fashioned, but because at the time of writing, the version of Unifi Controller comes with this warning;
Linux systems must be running a version of MongoDB prior to 3.6.x. We recommend 3.4.x. This is most likely to be an issue on Ubuntu 18.04 LTS, as it currently offers MongoDB 3.6.x.

Granted, its easy enough to specify the version of MongoDB running on a linux system, but for simplicity I will stick to 16.04.

Unlike my previous guide on setting up BIND, Pi-hole and DNS over HTTPS you will need a slightly larger instance to run the controller. For my deployment I required a g1-small (1 vCPU, 1.7 GB memory). Depending on the size of your network, and the number devices connected, you may need a larger one. But for now, this is our test environment.

So I have created a server in GCP with the following specifications:

  • Ubuntu 16.04 (Minimal LTS)
  • g1-small (1 vCPU, 1.7 GB memory)
  • 15GB standard persistent disk
  • Dynamic External IP (don’t worry, we will get to that)

The estimated cost of running this VM is $19.32/month

So lets install Unifi

Starting with a blank Ubuntu 16.04 as mentioned above, you can simply follow this guide, but there can be problems with Java.

The first thing I recommend doing is running the following on your server:

apt-get update && apt-get install openjdk-8-jdk-headless -y 

This will ensure a working version of jdk is installed on your server prior to installation which avoids issues later during the install. Once you’ve done that, proceed with the recommended Ubnt install steps which in a nutshell are:

echo 'deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ubnt.com/unifi/unifi-repo.gpg

Now you’re ready to install the Unifi controller, just type this:

apt-get update && apt-get install unifi -y

Assuming you’re allowing connections from your IP address to your GCP instance on port 8443, you should now be able to browse to https://YOUR INSTANCE IP :8443 and continue with the setup of the controller (I wont go into that now)

installed

DONE! That was easy wasn’t it? But what was so hard about that? Nothing really. How you use the controller and make it work for your particular case is where it becomes slightly more fun (especially with Dynamic IP’s on both ends). Stay tuned for Part 2