Unifi Controller on a FreeBSD laptop
Why?
I have 2 Ubiquiti Unifi access points for my Wifi networks, and so far I was managing them from a controller running on a MacBook Pro.
Since I'm switching my personal laptop to a Lenovo running FreeBSD, I am slowly moving features to that device.
I have migrated the "basic" features such as email, browser, image manipulations, and even blogging.
One thing which I thought I could not migrate was the Unifi controller, but it turns out that's not true!
Installing it
I simply searched for unifi:
# pkg search unifi
unifi7-7.3.83_2 UniFi Controller v7
Then
# pkg install unifi7
and a few minutes later, I had it installed.
I first looked in my XFCE menus and search for Unifi, but could not find it.
Then a quick look at the files in /usr/ports/net-mgmt/unifi7 showed the file
files/unifi.in, which is a rc.d script:
#!/bin/sh
#
# Created by: Mark Felder <feld@FreeBSD.org>
# PROVIDE: unifi
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable `unifi':
#
# unifi_enable="YES"
[...]
OK, so I checked in /usr/local/etc/rc.d and indeed there was a unifi file.
So I simply looked at its status with:
# /usr/local/etc/rc.d/unifi onestatus
(I had to use onestatus since I hadn't added the relevant line in my /etc/rc.conf).
FreeBSD confirmed it was not running, so I launched it with
# /usr/local/etc/rc.d/unifi onestart
Looking at the services listening, I confirmed that I had a bunch of new ones:
# netstat -an |grep LISTEN
tcp4 0 0 *.8843 *.* LISTEN
tcp4 0 0 *.8443 *.* LISTEN
tcp4 0 0 *.8880 *.* LISTEN
tcp4 0 0 *.8080 *.* LISTEN
[...]
I then added the below line in my /etc/rc.conf
:
# Unifi Controller
unifi_enable="YES"
Using it
Trying to login and fixing the pf issue
When trying to open the URL https://127.0.0.1:8443, I got an error message from Firefox.
I then remembered that my laptop had the pf firewall installed and configured pretty aggressively, so I tested disabling it with:
# pfctl -d
and this worked straight away.
I updated my /etc/pf.conf file to tell it to allow local connections:
set skip on lo0
and reloaded pf with pfctl -f /etc/pf.conf
, followed by a pfctl -e
.
First login
I then opened the URL https://127.0.0.1:8443 in Firefox, and got a Unifi window asking me whether I wanted to create a new configuration, or import a backup.
Backing up my previous configuration
I fired up the Unifi controller running on my Macbook and downloaded a configuration backup (.unf file), noting that this was a version 6.x, when I was running version 7 on my FreeBSD.
Restoring it
I then used that file on the FreeBSD system, and the import process started.
At some point, I got a message telling me that the Unifi controller would
restart, so I waited.
After a few minutes, I still had nothing, and when checking the status of the
Unifi controller (with service unifi status
), I confirmed that it was not
running.
A service unifi start
fixed it, and the import process carried on and
finished.
I could then log into the Controller, where I could see the 2 access points, but no client yet - after a few minutes, the clients started to appear.
Using the Unifi Controller
The experience is the same as with any other controller, should you be running it on MacOS/Windows, or e.g. on a Linux server, so I won't give details.
Just a few screenshots to show it to you in action:
Wrap Up
I'm glad that it's possible to run Unifi controller on FreeBSD, that's one more steps towards "recycling" my old MacBook Pro!