Ok, so you may or may not be using your DSL connection for hosting a website, or… perhaps you’d just like to be able to log into your boxes from the other side of the world
Anyhow, this perl script will help you keep a DHS.org domain up to date.
#!/usr/bin/perl################################################ pl Update DHS ################################################# By Freman ## http://fremnet.net/contact ################################################# For those of you who are woundering, DHS ## was a free domain service, but now requires ## donation. This script is was started ## because the most reliable shell script that ## was availible didn't work as well as I ## would have hoped. ################################################# Usage: ## Fill in the details, and chuck it in ## your crontab, it's as simple as that ## Features: ## Won't try to update unless your IP ## has changed (or the cache file is erased) ## More Information: ## Visit: www.dhs.org ################################################# Oh, and before you email me saying I could ## use sockets or something similar, I'm going ## to jump in and say NOPE, I'm happy with the ## way I've done it. It's much cleaner then ## the original SH script. ################################################ # What interface should I be probing for an IP?$Interface = "ppp0"; $DHS_UserName = "theuser";$DHS_Password = "thepass";$DHS_Host = "thehost";$DHS_Domain = "dhs.net"; #Example#$DHS_UserName = "methegreat";#$DHS_Password = "mypassword";#$DHS_Host = "box";#$DHS_Domain = "dhs.org"; $Log_Enabled = 1; #--== You shouldn't need to edit below here ==--# # File to cache the last known IP in# Note: $DHS_Host gets appended to this.$IP_Cache_File = "/var/run/ip.cache"; $ToolToUse = "/sbin/ifconfig"; $IP_Address = &Get_IP;$Cached_IP = &Get_Cached_IP; if (not($IP_Address eq $Cached_IP)) {#THE IP ADDRESS HAS CHANGED!!!use LWP::UserAgent;$ua = LWP::UserAgent->new;$ua->agent("plUpdateDHS/0.1"); $req = HTTP::Request->new(GET => "http://members.dhs.org/nic/hosts?hostscmd=edit&hostscmdstage=2&type=4&domain=".$DHS_Domain);$req->authorization_basic($DHS_UserName, $DHS_Password);$ua->request($req)->as_string; if ($Log_Enabled == 1) { open(LOG,">>/var/log/updatedhs"); print LOG "[".localtime(time)."] ($DHS_Host.$DHS_Domain) Address Change : $IP_Address\n"; close(LOG);}open(C,">$IP_Cache_File.$DHS_Host") || die "I can't open the IP Cache File: $1";print C "$IP_Address\n";close(C);system('/scripts/checkhost.pl &');} # Function to whip the current ip from thin air.sub Get_IP {my($IP) = '0.0.0.0';my($Line);open (IFINFO,"$ToolToUse $Interface |");while (<IFINFO>) { chomp; $Line = $_; if ($Line =~ /(\d*\.\d*\.\d*\.\d*)/) { $IP = $1; }}if ($IP eq "0.0.0.0") { die "I cannoh get the ip address capt`n\n";}close(IFINFO);return($IP);}# Function to pull the IP stored in the cache.sub Get_Cached_IP {my($IP) = '-.-.-.-';my($Line);if (-e "$IP_Cache_File.$DHS_Host") { open (CACHE,"<$IP_Cache_File.$DHS_Host"); while (<CACHE>) { chomp; $Line = $_; if ($Line =~ /(\d*\.\d*\.\d*\.\d*)/) { $IP = $1; } } close(CACHE);}return($IP);}Commenting is closed for this article.