To: admin@ddns.nu From: Andrew Cowan Date: Sat, 2 Feb 2002 06:10:56 +1100 Subject: Perl Script that checks before updating handle. I have attached a perl script I use for Bigpond ADSL from freebsd to update IP. Hope it might be useful to other people who are busy spamming your box. I have used it for 2 years now no problem. Thanks for the magnificent service you provide :) Best Regards, Andrew Cowan -------------------------------------------------------------------- #!/usr/bin/perl $_ = `/sbin/ifconfig tun0 | grep -w 0xffffff00`; print $_ (/inet ((\d{1,3}\.?){4})/m) ? ( $ipaddr = $1 ) : (warn 'ifconfig failed'); #print "$ipaddr\n"; print "\nUpdating dynamic dns...\n"; if (-e "/etc/bpaipaddress") { open(IN,"/etc/bpaipaddress"); while() { $oldip = $_; } close(IN); #print "$oldip\n"; if ($oldip ne $ipaddr) { print "No Match!!\n"; $password = '"secret"'; $return = `/sbin/ddns3 -u username -p $password -s handle $ipaddr`; print $return; if ( $return =~ m/OK/ ) { open(OUT,">/etc/bpaipaddress"); print OUT $ipaddr; close(OUT); } } } else { open(OUT,">/etc/bpaipaddress"); print OUT $ipaddr; close(OUT); } print "This is the new ip ($ipaddr)\n"; print "This is the old ip ($oldip)\n\n";