http://qs321.pair.com?node_id=309380
Category: Web stuff
Author/Contact Info Ryan Whitworth lithron@gmail.com
Description: A "smart" client that will update your Dyndns.org (or other domain from the company) to your current IP address. Works from behind a NAT (via www.whatismyip.com). Only tested under Win32 with Cygnus' Cygwin tools installed. Requires LWP::Simple and Socket.
Updated : removed the call to nslookup thanks to code provided by TheFluffyOne
#!/usr/bin/perl -w
use strict;
use warnings;
use LWP::Simple;
use Socket;

my $login = 'test';
my $password = 'test';
my $domain = 'test.mine.nu';
my $mx = 'mail.test.mine.nu';

my $ipaddress = LWP::Simple::get("http://www.whatismyip.com");
if ($ipaddress =~ /([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/) 
{ 
  $ipaddress = $1; 
}

my $nslookup = "0.0.0.0";
if ($nslookup = gethostbyname($mx)) {
  $nslookup = inet_ntoa($nslookup);
} else {
  print "Could not resolve domain name, check $domain is correct\n";
  print "Going to try to update information for $domain anyway ...\n";
}

if ($ipaddress eq $nslookup) {
  print "Nothing to update.  Current IP ($nslookup)";
  print " = DNS address ($ipaddress)\n";
  exit(0);
}

print "Updating the IP address ($ipaddress) now ... \n";

my $response = LWP::Simple::get("http://$login:$password\@" .
"members.dyndns.org/nic/update?system=dyndns&hostname=$domain" .
"&myip=$ipaddress&wildcard=ON&mx=$mx&backmx=NO&offline=NO");

print "Status : $response\n";