#!/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";