WRT54G and the Dynamic IP services of BNamed.net


BNamed.net offers a dynamic IP service as a part of their domain name registration services.

They offer client software for updating your IP address, but the provided script requires some changes in order to work on your WRT54G(S).

Below, you can a modified script for the Linksys WRT54G that updates your registered IP address when it has changed.

#!/bin/sh

#########################################################
#
# Update script for the dynamic IP services of BNamed.net
# To be run on a WRT54G(S) linux router. The last updated
# IP address is stored in a file on /tmp, so that
# it doesn't wear out your flash partition.
#
# L. Hollevoet, 2006
##########################################################

USER="xxxxxx"
PASS="xxxxxx"
LOGGER=/usr/bin/logger

BASE=/tmp

####### Normally, no changes are required beyond this line ##################

KNOWN_IP_FILE=$BASE/bnamed_ip.txt

KNOWN_IP=`cat $KNOWN_IP_FILE`

CURRENT_IP=$(ifconfig $(nvram get wan_ifname) | grep inet | awk '{print $2}' | cut -c 6-)

if [ $KNOWN_IP = $CURRENT_IP ]
then
        $LOGGER -t bnamed "No change in IP address ($CURRENT_IP)"
        exit
else
        echo $CURRENT_IP > $KNOWN_IP_FILE

        $LOGGER -t bnamed "Updating IP address to $CURRENT_IP..."

        OK=$( wget -O - http://$USER:$PASS@www.bnamed.net/dyn/dyn.asp?myip="$current_ip" )
        if [ $OK = good ]
        then
                $LOGGER -t bnamed "update OK: $OK"
        else
                $LOGGER -t bnamed "update failed: $OK"
        fi
fi

Add a cron job to run this script every 15 minutes and you’re all set…