Here's how to install the Ubiquiti UniFi and/or mFi in a FreeNAS jail:
Notes:
1. Create the jail
Jail name: (Whatever you want)
Template: -----
Networking: Check DHCP or set the ipv4 address and netmask as appropriate (highly recommend using static IP)
Autostart and VIMAGE: checked (I want my jail to autostart so I can keep the stats 24x7)
NAT: unchecked
2. Prepare the Mongodb package
Copy the Mongo 2.4.14 pkg that I compiled to your jail wherever you want using whatever process makes you happy. But you need to know where you put it for later. I put it in the root of the jail and the remainder of my guide assumes that is where you put it as well.
Link: https://dl.dropboxusercontent.com/u/57989017/Mongodb/mongodb-2.4.14.txz
SHA256: 536862E9CF7969B0A104A43183D5074C65401E7DF08EF99C72A6C910B1AEA28F
3. Setup our packages
Run the following commands:
Lock the pkg-ng tool so it does not upgrade itself:
# pkg lock pkg-1.4.12
Install a bunch of dependencies and other things that we will use later:
# pkg install py27-setuptools27 devel/libexecinfo devel/pcre archivers/snappy devel/boost-libs scons v8 R-cran-DBI nano sudo wget tmux openjdk-jre
This will take a little bit.. have some coffee. I had to download 250MB of data. Your will likely be very close, depending on the current dependencies, etc.
Now install the mongodb package:
# pkg add /path/to/the/file/mongodb-2.4.14.txz
If you had any errors with this installation, see NOTE1 at the bottom.
Lock the mongodb install so it is never upgraded with future pkg-ng upgrades:
# pkg lock mongodb-2.4.14
Unlock the pkg-ng install so we can upgrade it to the latest
# pkg unlock pkg-1.4.12
Now upgrade all packages to the latest
# pkg update && pkg upgrade
4. Set the hostname
Set the hostname to a name that will resolve in DNS (if applicable). I had to do this because my jail was named 'mfi' and 'mfi' doesn't resolve to a FQDN so when I put in "mfi" on my mPower device it wouldn't resolve and failed to contact the server (boo). When i put in mfi.f.q.d.n.com it worked since my DNS handled it at home.
If you plan to tie your devices by IP, you can do that. But if your IPs ever change things will stop working.
Change the hostname of the jail to whatever you need it to be (if you want to use the DNS resolving)
# sysrc hostname="mfi.cyberjock.is-a-loser.com"
5. Set mongodb to run at startup
# sysrc mongod_enable="YES" (I did mean to put mongod and not mongodb).
6. Restart the jail from the WebGUI
Restart the jail from the WebGUI and verify that your mongodb service is running.
# service mongod status
If it doesn't say that the service is running you've made an error in step 5.
8. Install UniFi and/or mFi
For the sake of the guide I'll install both at the same time. On my personal setup I run them in independent jails because I always stick to "one jail per service" for isolation purposes.
At the time of this writing the two download files are:
http://dl.ubnt.com/mfi/2.1.11/mFi.unix.zip
http://dl.ubnt.com/unifi/4.7.6/UniFi.unix.zip
I downloaded the files to / and extracted them into respective directories as follows:
# cd /
# wget http://dl.ubnt.com/mfi/2.1.11/mFi.unix.zip
# wget http://dl.ubnt.com/unifi/4.7.6/UniFi.unix.zip
# unzip mFi.unix.zip
# unzip UniFi.unix.zip
Now you should have two directories (/mFi and /UniFi) that have your mFi and UniFi software.
9. Create the mongodb links
Remove the unzipped file and create the links as show below:
# rm /UniFi/bin/mongod
# ln -s /usr/local/bin/mongod /UniFi/bin/mongod
# rm /mFi/bin/mongod
# ln -s /usr/local/bin/mongod /mFi/bin/mongod
10. Run your services manually (not recommended... see step 11!)
To run mFi:
# cd /mFi
# java -jar lib/ace.jar start
To run UniFi:
# cd /UniFi
# java -jar lib/ace.jar stop
This works, but as soon as the session ends you lose the WebGUI for mFi and/or UniFi. The optional step 11 is recommended if you want to keep the historical data for 24x7 usage, blah blah blah...
11. (Optional, but highly recommended) Run as a service
If you want these to run automatically on jail startup run the following:
# sysrc local_enable="YES"
# echo /usr/local/bin/tmux new-session -d "/usr/local/bin/java -jar /mFi/lib/ace.jar start" > /etc/rc.local
# echo /usr/local/bin/tmux new-window -d "/usr/local/bin/java -jar /UniFi/lib/ace.jar start" >> /etc/rc.local
# chmod +x /etc/rc.local
If you did all of this correctly, you should be able to restart the jail and have access to the software.
12. Use the UniFi/mFi services:
Access the mFi software by going to:
https://IP.address.of.jail:6443/ or use the FQDN
Access the UniFi software by going to:
https://IP.address.of.jail:8443/ or use the FQDN
If you are using Firefox you may get a security warning that the web browser won't let you access the website because of the security certificate, you'll need to fix that by visiting: https://forum.eset.com/topic/5348-s...-code-ssl-error-weak-server-ephemeral-dh-key/
The problem is that Firefox doesn't allow some older encryption types. Unfortunately the Ubiquiti software doesn't support the newer types, so we have to allow support for the older encryption. If you are using Chrome you don't have to worry about this as Chrome doesn't stop you from using the older encryption.
Things that are pretty disappointing about this software:
1. Mongodb version being used is fairly old. Mongodb is currently at version 3.2 while 2.4.0 is from 2013. It would sure be nice if Ubiquiti updated their software to use something that isn't almost 3 years old.
2. We had to use the old Java 7 openjdk. At least in Windows, using Java 8 doesn't work and you get nasty errors just trying to get to the login page. (This is why I got fed up and decided that I'd make this stuff work in a jail.) Again, would be nice if Ubiquiti used current software.
3. If you change the username/password of the devices themselves, it will stop working with the server. The defaults must stay the defaults. Yes, this means that the IoT is insecure. Anyone expect anything less in this world?
I believe there is a way to change the username/password and then provide that info to the server by editing a config file, but the mFi/UniFi software won't let you do this through the WebGUI. /fail
NOTE1:
In the future, dependencies may change. If you get an error when trying to install mongodb like this:
# pkg add mongodb-2.4.14.txz
[UniFi] Installing mongodb-2.4.14...
pkg: Missing dependency matching Origin: 'devel/libexecinfo' Version: '1.1_3'
Failed to install the following 1 package(s): mongodb-2.4.14.txz
That means there are needed dependencies that you need to install before you can install mongodb. In this case, you'd want to fix this with:
# pkg install devel/libexecinfo
Good luck and hope this helps others that use FreeNAS with Ubiquiti products.
I've been pretty happy with Ubiquiti products aside from these software 'issues'.
My WiFi Hotspots of choice:Ubiquiti UniFi Long Range Access Point, (2.4 GHz, UAP-LR-US, US Version)
My power strip: Ubiquiti mPower mFi 3-port Power (EU and US) Wifi
I am not a Ubiquiti employee, don't have any affiliation with them, etc.
If you are an Ubiquiti employee and would like me to test newer versions of your software, update the guide to work with newer software, test new hardware (I love new hardware) feel free to message.
Special thanks to Sam for help in getting the mongodb package put together. Without his help I wouldn't have been able to get the old mongodb to compile!
Notes:
- This uses Mongodb 2.4.14 (latest 2.4 release available). At this time Mongodb 2.4.x is all that seems to be work with the Ubiquiti software. I'm providing a self-compiled version of 2.4.14. It took some real trickery to get it to compile and get it to work properly, so don't ask how I did it. Either use the included file or figure it out yourself. It's one of those things where "if you have to ask... you probably can't do it anyway".
- You must do this from a fresh jail. A fresh jail uses pkg-ng 1.4.12, which is necessary to install the mongodb package that I've compiled. There are ways to rollback, but that is far beyond what I'm going to try to do with this guide because of various caveats. Please don't ask questions about rolling back because I don't want to discuss the complexities of it. I will delete any posts asking about it.
- The UniFi and mFi software has some restrictions on how well it works. So you should read the included readme.txt file to figure out what limitations/problems may exist. Right now the readme files say:
- Auto update (of the mFi/UniFi controller) does not work
- Backup/Restore does not work (see FAQ)
- If you are using a network configuration that fully supports FQDN I recommend you use those for the setup of the jail as well as the setup of the devices themselves. If not, I recommend that your server and devices uses static IPs to ensure everything works properly in the future. Ideally your mPower and/or UniFi devices should have a static IP as well as the server. I set my whole network up with static IP for these devices and "it works for me".
1. Create the jail
Jail name: (Whatever you want)
Template: -----
Networking: Check DHCP or set the ipv4 address and netmask as appropriate (highly recommend using static IP)
Autostart and VIMAGE: checked (I want my jail to autostart so I can keep the stats 24x7)
NAT: unchecked
2. Prepare the Mongodb package
Copy the Mongo 2.4.14 pkg that I compiled to your jail wherever you want using whatever process makes you happy. But you need to know where you put it for later. I put it in the root of the jail and the remainder of my guide assumes that is where you put it as well.
Link: https://dl.dropboxusercontent.com/u/57989017/Mongodb/mongodb-2.4.14.txz
SHA256: 536862E9CF7969B0A104A43183D5074C65401E7DF08EF99C72A6C910B1AEA28F
3. Setup our packages
Run the following commands:
Lock the pkg-ng tool so it does not upgrade itself:
# pkg lock pkg-1.4.12
Install a bunch of dependencies and other things that we will use later:
# pkg install py27-setuptools27 devel/libexecinfo devel/pcre archivers/snappy devel/boost-libs scons v8 R-cran-DBI nano sudo wget tmux openjdk-jre
This will take a little bit.. have some coffee. I had to download 250MB of data. Your will likely be very close, depending on the current dependencies, etc.
Now install the mongodb package:
# pkg add /path/to/the/file/mongodb-2.4.14.txz
If you had any errors with this installation, see NOTE1 at the bottom.
Lock the mongodb install so it is never upgraded with future pkg-ng upgrades:
# pkg lock mongodb-2.4.14
Unlock the pkg-ng install so we can upgrade it to the latest
# pkg unlock pkg-1.4.12
Now upgrade all packages to the latest
# pkg update && pkg upgrade
4. Set the hostname
Set the hostname to a name that will resolve in DNS (if applicable). I had to do this because my jail was named 'mfi' and 'mfi' doesn't resolve to a FQDN so when I put in "mfi" on my mPower device it wouldn't resolve and failed to contact the server (boo). When i put in mfi.f.q.d.n.com it worked since my DNS handled it at home.
If you plan to tie your devices by IP, you can do that. But if your IPs ever change things will stop working.
Change the hostname of the jail to whatever you need it to be (if you want to use the DNS resolving)
# sysrc hostname="mfi.cyberjock.is-a-loser.com"
5. Set mongodb to run at startup
# sysrc mongod_enable="YES" (I did mean to put mongod and not mongodb).
6. Restart the jail from the WebGUI
Restart the jail from the WebGUI and verify that your mongodb service is running.
# service mongod status
If it doesn't say that the service is running you've made an error in step 5.
8. Install UniFi and/or mFi
For the sake of the guide I'll install both at the same time. On my personal setup I run them in independent jails because I always stick to "one jail per service" for isolation purposes.
At the time of this writing the two download files are:
http://dl.ubnt.com/mfi/2.1.11/mFi.unix.zip
http://dl.ubnt.com/unifi/4.7.6/UniFi.unix.zip
I downloaded the files to / and extracted them into respective directories as follows:
# cd /
# wget http://dl.ubnt.com/mfi/2.1.11/mFi.unix.zip
# wget http://dl.ubnt.com/unifi/4.7.6/UniFi.unix.zip
# unzip mFi.unix.zip
# unzip UniFi.unix.zip
Now you should have two directories (/mFi and /UniFi) that have your mFi and UniFi software.
9. Create the mongodb links
Remove the unzipped file and create the links as show below:
# rm /UniFi/bin/mongod
# ln -s /usr/local/bin/mongod /UniFi/bin/mongod
# rm /mFi/bin/mongod
# ln -s /usr/local/bin/mongod /mFi/bin/mongod
10. Run your services manually (not recommended... see step 11!)
To run mFi:
# cd /mFi
# java -jar lib/ace.jar start
To run UniFi:
# cd /UniFi
# java -jar lib/ace.jar stop
This works, but as soon as the session ends you lose the WebGUI for mFi and/or UniFi. The optional step 11 is recommended if you want to keep the historical data for 24x7 usage, blah blah blah...
11. (Optional, but highly recommended) Run as a service
If you want these to run automatically on jail startup run the following:
# sysrc local_enable="YES"
# echo /usr/local/bin/tmux new-session -d "/usr/local/bin/java -jar /mFi/lib/ace.jar start" > /etc/rc.local
# echo /usr/local/bin/tmux new-window -d "/usr/local/bin/java -jar /UniFi/lib/ace.jar start" >> /etc/rc.local
# chmod +x /etc/rc.local
If you did all of this correctly, you should be able to restart the jail and have access to the software.
12. Use the UniFi/mFi services:
Access the mFi software by going to:
https://IP.address.of.jail:6443/ or use the FQDN
Access the UniFi software by going to:
https://IP.address.of.jail:8443/ or use the FQDN
If you are using Firefox you may get a security warning that the web browser won't let you access the website because of the security certificate, you'll need to fix that by visiting: https://forum.eset.com/topic/5348-s...-code-ssl-error-weak-server-ephemeral-dh-key/
The problem is that Firefox doesn't allow some older encryption types. Unfortunately the Ubiquiti software doesn't support the newer types, so we have to allow support for the older encryption. If you are using Chrome you don't have to worry about this as Chrome doesn't stop you from using the older encryption.
Things that are pretty disappointing about this software:
1. Mongodb version being used is fairly old. Mongodb is currently at version 3.2 while 2.4.0 is from 2013. It would sure be nice if Ubiquiti updated their software to use something that isn't almost 3 years old.
2. We had to use the old Java 7 openjdk. At least in Windows, using Java 8 doesn't work and you get nasty errors just trying to get to the login page. (This is why I got fed up and decided that I'd make this stuff work in a jail.) Again, would be nice if Ubiquiti used current software.
3. If you change the username/password of the devices themselves, it will stop working with the server. The defaults must stay the defaults. Yes, this means that the IoT is insecure. Anyone expect anything less in this world?
I believe there is a way to change the username/password and then provide that info to the server by editing a config file, but the mFi/UniFi software won't let you do this through the WebGUI. /fail
NOTE1:
In the future, dependencies may change. If you get an error when trying to install mongodb like this:
# pkg add mongodb-2.4.14.txz
[UniFi] Installing mongodb-2.4.14...
pkg: Missing dependency matching Origin: 'devel/libexecinfo' Version: '1.1_3'
Failed to install the following 1 package(s): mongodb-2.4.14.txz
That means there are needed dependencies that you need to install before you can install mongodb. In this case, you'd want to fix this with:
# pkg install devel/libexecinfo
Good luck and hope this helps others that use FreeNAS with Ubiquiti products.
I've been pretty happy with Ubiquiti products aside from these software 'issues'.
My WiFi Hotspots of choice:Ubiquiti UniFi Long Range Access Point, (2.4 GHz, UAP-LR-US, US Version)
My power strip: Ubiquiti mPower mFi 3-port Power (EU and US) Wifi
I am not a Ubiquiti employee, don't have any affiliation with them, etc.
If you are an Ubiquiti employee and would like me to test newer versions of your software, update the guide to work with newer software, test new hardware (I love new hardware) feel free to message.
Special thanks to Sam for help in getting the mongodb package put together. Without his help I wouldn't have been able to get the old mongodb to compile!
Last edited: