OpenDNS Updater script - there is not a linux updater client like there is for windows, but the update is simple. Here is the detail at the OpenDNS forums here:
Linux Update Client.
Here I added some code to check if the IP is different, attempt to update, then write result to a log file.
There are some extra print statements that cron will generate emails, can comment them out ....
#!/usr/bin/perl
# Gregg Lain May 5th, 2009
# gregg@mochabomb.com
# Update OpenDNS when IP changes
$updateOpenDNS = 0;
$updateresult = 0;
$writeLogEveryXHours = 2; # integer, 1 to 23
$DATE = (localtime);
$MIN = ((localtime(time))[1]);
$HOUR = ((localtime(time))[2]);
$LOGFILE="/home/user/working/IPupdater.log";
open LOG, ">>$LOGFILE";
$OLDIPFILE="/home/user/working/oldIP.txt";
open OLDIP, "<$OLDIPFILE";
$TMPIPFILE="/home/user/working/tmpIP.txt";
$ipcheck = `wget http://mochabomb.com/publicscripts/ip.php -o /dev/null -O $TMPIPFILE`;
open TMPIP, "<$TMPIPFILE";
# OpenDNS Account Info
$USERNAME='USERNAME';
$PASSWD='PASSWD';
$oldip = join '', ;
chomp $oldip;
$tmpip = join '', ;
chomp $tmpip;
$tmpip =~ s/Remote IP: //;
# Attempt to update OpenDNS..
if ( $tmpip ne $oldip ) {
$updateOpenDNS = 1;
$newip = $tmpip; # to make thing simple..
$updateresult = `wget -O - -q --http-user=$USERNAME --http-passwd=$PASSWD https://updates.opendns.com/nic/update`;
$updateresult =~ s/\\n//g;
$updatewasgood = 1 if ( $updateresult =~ good ); # Flag if result was good or not..
}
# Now that we have results, log it some way or another.
# We had a good update - save this IP, log result...
if (( $updatewasgood == 1 ) && ( $updateOpenDNS == 1 )) {
close OLDIP; # need to close and reopen, else file is wiped out...
open OLDIP, ">$OLDIPFILE";
print OLDIP $newip; #update the file with new IP
print "OpenDNS Update Result: $result\n";
print "Old IP was $oldip; was updated to $newip\n";
print LOG "$DATE OpenDNS updated. old IP: $oldip, new IP $newip OpenDNS said: $updateresult\n"; # update log file
}
# We had bad update - log result...
if (( $updatewasgood == 0 ) && ( $updateOpenDNS == 1 )) {
close OLDIP;
print "ERROR: OpenDNS Update Result: $result\n";
print "Old IP was $oldip; was NOT updated to $newip\n";
print LOG "$DATE ERROR: OpenDNS update FAILED. old IP: $oldip, new IP $newip\n"; # update log file
}
if ( $updateOpenDNS == 0 ) {
print "No update made\n";
}
# Log every X hours - unless we ran a update.. just so we see its working...
$leftover = $HOUR % $writeLogEveryXHours;
if (( $leftover == 0 ) && ( $updateOpenDNS == 0 ) && ( $MIN == 15 )) {
print LOG "$DATE OpenDNS updater running.. Updated IP: $oldip, Current IP $tmpip\n"; # update log file
}
# Housecleaning...
close TMPIP;
close OLDIP;
close LOG;