In latest version of their airOS firmware for airMax devices Ubiquiti networks dropped support for Dynamic DNS services. This left me out in the dark, unable to update the dynamic DNS corresponding to my devices. After a lot of crawling around the support forums I eventually came to a working solution based on crontab.
I use services from Hurricane Electric for my dynamic DNS needs. Updating boils down to fetching a special URL using either wget or curl. My idea was to do this every 30 minutes using cron jobs. This would have been done within a couple of minutes on a regular Linux system but turned out to be less straight forward on Ubiquiti device.
The airOS system ships with crond, however it is looking for its crontabs files into /etc/crontabs and it is not started on boot. What we will do is create custom scripts to run crond on boot and use our own crontabs directory.
- An airMAX Ubiquiti device running a Custom Scripts capable firmware. Get it from here. I am using version 8.7.1
- SSH access to the device
- Know-how on editing files using vi editor (there are plenty of vi tutorials on the internet)
- Familiar with cron jobs
Getting it done
Create or edit the poststart script using vi editor. This script will be run after the system has started.
Below is the content of the rc.poststart script. It basically only starts crond telling it to look into our own (not yet created) crontabs directory.
null/bin/crond -b -c /etc/persistent/crontabs -L /dev/
Make the rc.poststart script executable and create the directory where our crontabs will be stored.
chmod +x /etc/persistent/rc.poststart mkdir /etc/persistent/crontabs
Edit our cronjobs
crontab -e -c /etc/persistent/crontabs
This is how my cron job to update my dns looks like (it is anonymized here).
*/30 * * * * /bin/wget -O /tmp/updatednsresponse.txt http://myhost.mydomain.com:myPassWord@dyn.dns.he.net/nic/update?hostname=myhost.mydomain.com > /tmp/updatedns.log 2>&1
Save everything between reboots !
Once done and on every change, in order to apply your changes you need run the following commands. This will save the changes (actually all that is contained in /etc/persistent plus other config stuff) and reboot the system.
Here are the partial information (not exhaustive list) I collected to achieve this :