Using Billion routers with ddclient

I have a website at home served from a Dlink NSLU2. This would be fine but we have ADSL with a non-static IP. To overcome this I am using ddclient to update a dyndns address. I have added a CNAME redirect from to that address. The dyndns TTL is 1 minute, so there should rarely be a IP cache error; ddclient updates dyndns, if required, from an internal check every minute. So a new dynamic IP should propagate in ~3 minutes max. (first check fails because of no IP, second OK + TTL)

What I did.

Created a account, got an Dyndns name and edited the CNAME and MX records to point at that name. Then installed ddclient using apt-get install ddclient and followed the install prompts.

ddclient worked straight out of the box except Billion routers are not supported :( This meant I could use a web IP lookup (why use the traffic?) or roll my own script to echo the external IP from the router status page. I decided to roll my on script. I started by making a /usr/local/sbin/ip script with the following contents.

# /usr/local/sbin/ip

USER='username here'
PASS='password here'
IP='ip address of router'

# Billion will allow you grab the status page, unless someone else is on the 
# interface, when you get the error page which doesn't match the sed pattern.

X=$(wget -qO -  http://$USER:$PASS@$IP/welcome.html | grep '<td>' | \
        sed 's/\(<td>\)\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)\(&nbsp;<\/td>\)/\2/' \
        | grep -v '<td>')

# if we got the external ip X, then echo X else fail 
# ddclient handles fail as a NOT FOUND error which is ok, because the ddclient
# daemon then logs this, sends emails and stops.

if [ -n "$X" ] ; then
        wget -qO /dev/null http://$USER:$PASS@$IP/logout.html
        echo "IP address $X"
        exit 1

exit 0

Then all I had to do was edit the /etc/ddclient.conf to call the script

# Custom cmd to update ddclient.
use=cmd, cmd=/usr/local/sbin/ip

then test with sudo ddclient -query -verbose, some external checks on, gmail test emails etc. and it was done.

Michael 20100211, update 20100813