DynDNS Updates
I use Afraid FreeDNS to host my DNS and perform DynDNS for my home machine. Today I decided it would be neat to also DynDNS my laptop. Afraid uses a simple update mechanism: perform and HTTP request using a unique token and your DynDNS is updated to the request IP. At home, in my crontab, I have:
curl -s http://freedns.afraid.org/dynamic/update.php?_TOKEN_ | logger -p user.info -t dyndns
This isn't great, so today I updated it. For my MacBook Pro I'm using the in-built net command to do a host lookup to check if networking is up and whether my IP has changed, or we just shouldn't bother. It looks something like:
current="$(net lookup _DOMAIN_)" && actual="$(curl -s http://whatismyip.org)" && ( if [ "$current" != "$actual" ]; then curl -s http://freedns.afraid.org/dynamic/update.php?_TOKEN_ | logger -p user.info -t dyndns; fi )
At home, however, is a Linux box. Substitute a terse dig for net and we're set:
current="$(dig +short _DOMAIN_)" && actual="$(curl -s http://whatismyip.org)" && ( if [ "$current" != "$actual" ]; then curl -s http://freedns.afraid.org/dynamic/update.php?_TOKEN_ | logger -p user.info -t dyndns; fi )
Much better!