Since changing from O2 to Virgin broadband, I’ve had to hope my dynamic external IP address didn’t change too often. As it turns out, Virgin appear to have a very slow turnover of IPs for home customers, since I’ve had the same one since we changed. I wrote a little script to scrape my IP from http://checkip.dyndns.org every 10 minutes and save the output do Dropbox, but this seemed less than optimal.
I recently read about a nifty little client called ddclient. If your router doesn’t support updating a dynamic DNS service (such as www.dyndns.org) for you, then having a tool like ddclient do it for you is pretty handy.
It’s a little perl utility, which on Slackware requires some external dependencies (perl-IO-Socket-SSL, Net-SSLeay, libwww-perl, perl-html-parser and perl-html-tagset) available from SlackBuilds.org. Set up is pretty straightforward, and the default configuration file (/etc/ddclient/ddclient.conf) is pretty comprehensive. I found, however, it was a bit overwhelming, and the documentation on the website was more useful. In the end, my configuration looked like this:
# Stripped down version of the config file.
# Easier to manage, I think.daemon=600 # update every 10 minutes
syslog=yes # write to syslog
mail=root # all messages go to root
mail-failure=root # failures sent to root too
pid=/var/run/ddclient.pid # runtime pid file
# host setup
ssl=yes # use ssl when updating hostname
protocol=dyndns2 # using dyndns.org
use=web, web=checkip.dyndns.org/, web-skip=’IP Address’
#use=web # get ip from internet
login=myusername # username
password=mypassword # duh…
my.hostname.com # my hostname
I set the daemon to run every ten minutes and it uses www.dyndns.org to update the IP associated with my.hostname.com. I altered the line use=web to use=web, web=checkip.dyndns.org/, web-skip=’IP Address’ because I was getting errors with ddclient finding the checkip.dyndns.org address. In theory, this forces ddclient to parse the output from checkip.dyndns.org correctly.
In the end, ddclient does a very similar thing to my suboptimal approach, though it updates my dyndns account for me rather than me having to do so from the Dropbox text file to which my script saved my IP address.