Reservation of IP address on Nanostation M5

Note: From AirOS version 5.6.9 and forward, the following is no longer necessary, because you can reserve IP addresses directly from the Nanostation’s web interface. 2017-01-11.

The Nanostation M5 from Ubiquity has a comprehensive and beautiful web GUI interface that enables customization of a large number of settings. Unfortunately, reservation of IP addresses for specific hosts on the local network in the Nanostation’s DHCP server is not possible via the GUI. This is a bit strange, because the GUI does allow port-forwarding, an option which is a bit useless without the possibility to reserve an IP address on the LAN to forward traffic to.

Instead, you need to specify the DHCP reservations manually by making a small change in the Nanostation’s operating system. Log on to the Nanostation from a terminal:

ssh admin@

The Nanostation runs a tiny Linux system (“AirOS”), and many of the standard UNIX tools are available via busybox. Fortunately, AirOS allows users to add scripts in the /etc/persistent directory of the Ubiquiti device.

Create a file /etc/persistent/reservations.conf containing the DHCP reservations:

# raspberrypi
# my-laptop

These statements will ensure that the device with the given Mac address is given the same IP address every time it joins the network. In order to prevent that other devices are given these adresses, they should be chosen outside the range of IP addresses normally handed out by the DHCP daemon. This range is defined in the Nanostation’s web GUI.

The file /etc/dnsmasq.conf is rewritten every time the Nanostation boots, taking parameters from the GUI interface, so it is useless to edit it manually. Create a boot-time script /etc/persistent/rc.prestart:

if test -r $RES; then
   cat /etc/persistent/reservations.conf >> /etc/dnsmasq.conf

Do a save:

M.v5.5.10# save

(The command save is an alias: save='cfgmtd -w -p /etc/')

Now, you can kill the dnsmasq daemon, it is restarted automatically by init (it is listed in /var/etc/inittab). You can also reboot the Nanostation:

M.v5.5.10# reboot

When the Nanostation is back up, reboot your device or simply renew the DHCP lease. Below is shown how this is done in Mac OSX 10.10.

Renew DHCP lease, Mac OS X 10.10

Installing Python 3 compatible Fabric

Unfortunately, Fabric has not yet officilly been ported to Python 3. However, it is possible to get it to work. Here is how I did it.

First, create a virtual environment to run fabric in. (If you haven’t set up virtual environments for Python, go ahead and do that now, then come back.) I have the [fink environment] ( installed on my Mac, and the Python 3 executable is in /sw/bin/python3. If you have Python3 from homebrew or elsewhere, just put the correct path to the python3 executable after the --python switch below:

$ mkvirtualenv --python=/sw/bin/python3 fabric
[ ... ]

Save the following lines in a file /tmp/requirements.txt:


[Added 20150509] If you don’t care about running fabric’s unittests, you can actually get by with this list:

six - - -

In the fabric environment, install these packages:

(fabric)$ pip3 install -r /tmp/requirements.txt

Now, all you need is the last two requirements, which are not available from PyPi, because they are forked from the main developement line. Go to the place you store your github clones:

(fabric)$ cd ~/github

First, clone and install the Python 3 version of rudolf:

(fabric)$ git clone --depth=1
(fabric)$ cd rudolf
(fabric)$ python3 install

(The --depth=1 switch gives a shallow clone. It is sufficient for most cases, unless you are interested in the history of the repo.) Next, clone the git repository from Sergey Pashinin, who has ported fabric itself to Python 3:

(fabric)$ cd ~/github
(fabric)$ git clone --depth=1
(fabric)$ cd fabric

See the tests, most of them run ok, but a few do fail :-(

(fabric)$ python3 nosetests

Even though some tests fail, fabric seems to work fine for most things I have tried. Build and install:

(fabric)$ python3 install

Now, test out your fabric installation. From the documentation, try the following example. Place in /tmp/

from fabric.api import run
def host_type():
    run('uname -s')

Now try to run it on localhost (requires ssh):

(fabric)$ fab -H localhost host_type
[localhost] Executing task 'host_type'
[localhost] run: uname -s
[localhost] out: Darwin
[localhost] out:

Disconnecting from localhost... done.

Deactivate the fabric enviroment:

(fabric)$ deactivate

Whenever you need to use your fabric installation, just issue the command:

$ workon fabric

(The latter requires that you have also installed virtualenvwrapper).

That’s all, good luck!