Here is my solution by modifications to Tristan Nixon's original script.
This script compares the dns record with the router IP (in my case Netcomm NB9W) and if they differ enforces the update.
I also have a different version for Netcomm NB5W which requires a POST mechanism for router/modem login instead.
... Robert
#!/usr/bin/perl -Tw
# updatedns - ChangeIP.com Auto Client Script
# by Tristan Nixon (
corvi42@silencegreys.com )
# based very loosely upon the script by: Bob Lee (
crazyboblee@hotmail.com)
# License:
http://www.gnu.org/copyleft/gpl.html
#
# I have tried to make this program responsible in
# such a way that it will be optimal for both running as a cron
# task to update the dns should your ip change, and as part of a
# network init script
# it will also update your /etc/hosts file so that your hostname
# is set correctly for local resolution
# ( ie it adds an entry with the ppp ip when you go online, and modifies this to a local address when offline )
# sometimes apache or other daemons
# complain if you're locally using a hostname that doesn't properly resolve,
# this should solve this problem
#
# usage: updatedns <offline>
#
# if the command is run without arguments, it will
# check if it is neccessary to update the dns
# ( ie if the ppp interface has a different ip from the dns record )
# and then do so this is how it should be run if you want to set
# or update a dns record when your machine goes online or when your ip changes
#
# if it is run with an argument: 'updatedns offline'
# ( or any argument that resolves to true in perl: 'updatedns 1' or 'updatedns foobar' etc. )
# then it will set the dns record to point to $public_offlineip
#
# all of this is logged to /var/log/updatedns.log
#
# you must edit the variables below to get this thing working for you
# important variables:
# $uid - your changeip.com userid
# $pwd - your changeip.com password
# $hostname - the hostname to which you want your computer to be bound
# $offlineip - the ip for your hostname so you can get to your own machine when you're offline
# $public_offlineip - the ip others should go to when you're offline
# $iface - your dynamic / dialup interface, this should be fine as it is for most people
# $hostsfile - location of your local hosts file, this should be fine for most people
# $logfile - the location of the logfile, this should be fine for most people
# $dnsserver - the server & port to go to to update - I don't see why you'd want to change this
## ##
## START MAIN PROGRAM ##
## ##
# make the environment safe
clean_env();
$ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin';
# variables
my $offline = $ARGV[0] ? 1 : 0;
my $uid = 'myuid'; # set this to your changeip.com userid
my $pwd = 'mypwd'; # set this to your changeip.com password
my $hostname = 'myhostname'; # set this to your hostname
my $offlineip = '127.0.0.1'; # set this to your own local interface
my $public_offlineip = $offlineip; # set this to the ip other should go to when you're offline
my $iface = 'ppp0';
my $hostsfile = '/etc/hosts';
my $logfile = '/var/log/updatedns.log';
my $dnsserver = 'www.changeip.com:443';
my $pppip = get_router_ip();
my $dns_entry = get_dns();
print \"ip: $pppip\\n\";
print \"dns: $dns_entry\\n\";
my $ruid = 'myrouteradmin:myrouterpwd';
my $rurl = 'http://192.168.1.1/wancfg.cmd?action=view';
print \"checking match\\n\";
# if we already match the dns record, exit now
#( ! $offline && $pppip eq $dns_entry ) and exit( 0 );
( $pppip eq $dns_entry ) and exit( 0 );
print \"updating records\\n\";
# update the dns
update_dnsset1();
## ##
## END MAIN PROGRAM ##
## ##
# subroutines
sub clean_env
{
foreach my $key ( %ENV ){
$ENV{$key} = untaint( $ENV{$key} );
}
}
sub untaint{
my $stringToClean = $_[0];
( ! defined( $stringToClean ) || $stringToClean eq '' ) and return '';
# remove invalid characters
$stringToClean =~ s/[;&\"`\\$\\\\<>\\|]//g;