Feb 14 2009
Perl script to do Dynamic DNS update for the domains hosted at NearlyFreeSpeech.net [NFS.N]
If your domains are hosted at Nearlyfreespeech.net and if the webserver for one of your sub-domains is hosted on your home machine, then you need to update your sub-domain’s DNS info with the current IP address info. This is normally called as Dynamic DNS update. NFS.N provides a set of API’s to access their DNS services to update the DNS information. I have created a simple perl script that does the Dynamic DNS update to NFS.N DNS servers.
How to use this script
1) Pre-requisites
Perl ( Perl 5 and above should work. Mine is Perl 5.8 )
Perl Modules:
WebService::NFSN; LWP::Simple; XML::Simple; Data::Dumper; Text::Trim;
You can install all the above mentioned modules via CPAN.
NFS.N Credentials
username ( This is the name you use to log into NFS.N website )
API auth Key. ( If you don’t have it , raise a secure support request at NFS.N support website. They will mail you the key )
2) Download the script into your home directory. The script is available here
3) on the command prompt type, updateIP.pl username your-API-Auth-Key your-domain-name ttl_value name sub-domain-name type A
( All the bold words as it is )
for example, your user name is jonny, your API auth key is XYSDGFGJHK , your domain name is jonny.net, ttl_value is 600 and sub-domain-name is home_server, then the command will be
updateIP.pl jonny XYSDGFGJHK jonny.net 600 name home_server type A
4) You need to run this periodically. You can run a corn job that executes the above periodically. Recommended interval is 10 mins.
Acknowledgement
This script is based on a TTL_Value update script from C.J.Madsen. Infact, hs is the one who wrote Webservice::NFSN.
Additional Note:
NFS.N services requires that the time difference between your home server and its servers are not more than 5 secs. If it is , then the authentication step will result in error and hence you will not be able to update. The most reliable way to keep the time of your home server in sync with NFS.N server is to update your home server’s time using Network Time Protocol. pool.ntp.org is a global , distributed NTP time servers that i use for keeping my server’s time in synch with NFS.N. And I do this once a day.
Here is the command. You need to run this as root.
ntpdate pool.ntp.org