I have been fiddling with Mikrotik some time now, and have come to love it. It didn't take long time until I noticed the best service for getting the dsl pipes a working dns you could script it against Changeip. However, since I also use the domain for lots of FreeBSD boxes I was in some sort of trouble since I then needed to move the whole domain from Zoneedit to Changeip. In the matter of need I made a "whack" script to get the little red ones updating against Changeip.
//Cheers
Goran
Installation:
- mkdir -p /etc/ddns
- touch /etc/ddns/update.log
- cd /usr/ports/ftp/curl && make install clean
- Edit crontab (crontab -e) add the entry (The path is for finding stuff in the system)
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
*/15 * * * * /etc/ddns/update.sh >/dev/null 2>&1 - Below the ------------ line copy the lot and save it as /etc/ddns/update.sh
- Edit the update.sh to your needs that's 1) Interface 2) Username 3) Password 4) Domain
- That's it.
Shell scripting has a nice feature, to see what the script does edit the first line
in the script to looks like below, run it the from the promt. This will show you that all things get set right. When it all looks great just remove it and fire up the crontab.
#!/bin/sh -x
#!/bin/sh
FreeBSD ddns script for changeip.com
Created by Goran[AT]Partman.se, "The need has no law".This script only update one host @ changeip.com
\
Set the wan interface. Remember to pick the one connected to your router/modem/3G,
if="nfe0"
Logfile, no need to change that.
log="/etc/ddns/update.log"
Set your Changeip.com username in the " " area.
uid="MY_UID_AT_CHANGEIP"
Set your Changeip.com password in the " " area.
pw="MY_PASS_AT_CHANGEIP"
Set your domain in the " " area.
host="MY.COOL.DOMAIN.SE"
################### CONFIG AREA ABOVE, THIS IS THE LAZY PART ###############################
wanip=ifconfig $if | grep inet | cut -f2 | awk '{ print $2 }'
if [ -z $wanip ];then
echo "Check your interface, no wanip noticed"
exit 1
fi
regdns=dig $host | grep -v ";" | grep $host | awk '{ print $5 }'
if [ -z $regdns ];then
echo "Check your hostname. It cannot be resolved"
exit 1
fi
Check out if we dig out ok.
if [ $wanip = $regdns ];then
echo "DNS is fresh, no update needed"
exit 0
else
echo "date New IP ($wanip), updating DNS" >> $log
/usr/local/bin/curl -k -s "https://nic.changeip.com/nic/update?u=$uid&p=$pw&cmd=update&hostname=$host&ip=$w
anip" >/dev/null 2>&1
exit 0
fi