Enom/Dynu Dynamic IP: A quick registration/protocol rundown.

eNom, a rather cheap domain registrar, offers dynamic DNS forwarding services, so you can always access your system, despite being stuck with a dynamic IP. They offer quite a bit more than just dynamic DNS, but they’ve currently only published source code for dynamic domains.

I was intrigued by this, as they (at least by proxy) handle a few of my domains, and I’d like to eventually have other external sites accessable via a static name, wether I’m working from my home office, or out on the lam. I was pleased to find that their API is amazingly trivial – it’s an HTTP POST!

It’s sent to a specific server, which is noted in the Perl script I whipped up below – and here’s an example of variables, each noted for clarity. Please note that the \\ notes a line break for legibility; there is none in the actual request!

GET /interface.asp?Command=SetDNSHost&HostName=enomRegisteredName \\ &Zone=enomDomainName&DomainPassword=enomRegisteredPass \\ &Address=enomForcedIP HTTP/1.0

The “enomRegisteredName” is the same as the host name you’ve specified when you signed up for enom service, “enomDomainName” specifies your domain name, “enomRegisteredPass” refers to the password you specified when you signed up for service, and “enomForcedIP” will force enom to register the given IP address with the name; if it is not specified, enom will use the IP address the request is coming from.

It’s possible to actually make this request manually via a browser, or even easier with a JavaScript bookmarklet, but for the sake of completeness, let’s whip it up in Perl. That should be fairly platform inspecific.

It will take one argument on the command line – and if it is set, it will attempt to register that as your forced IP. Everything else is hard-coded, so you can hide your information from prying eyes.

#!/usr/bin/perl -w
  1. A horrible little “socket only” client for enom/dynu Basic DNS #services, see
  2. enom.com for further information.
  3. Hacked together in 10 minutes by Shawn Holwegner,
  4. Absolutely no warranty is expressed or implied. Permission is given to enom.com,
  5. dynu.com, or any clients to use this code and modify at will, but if functionality is
  6. added, I’d appreciate any additional functionality so I might update this little script!
  1. Let’s not assume we have Net::Socket::INET or anything fancy, just Socket.. use Socket; ## Set this to what your host is, e.g. “foo”, for “foo.enom.com”. $host = “foo”; ## Set this to your password for the above domain name. $pass = “foo”; ## Set this for your proper domain name (foo.com). $domain = “foo.com”; ## You shouldn’t have to change anything below here! $remoteaddr = gethostbyname(“dynamic.name-services.com”); die “Socket: $!\\n” unless socket(S, PF_INET, SOCK_STREAM, 6); die “Connect: $!\\n” unless connect(S, pack(‘S n a4×8’, AF_INET, 80, $remoteaddr)); ## The below is broken to better fit the screen.. $path = ”/interface.asp?Command=SetDNSHost&HostName”; $path .= ”=$host&Zone=$domain&DomainPassword=$pass”; ## This is icky. I should fix this some time. if (@ARGV) { $forceip = shift; } else { $forceip = “”; } if (length($forceip) != 0) { $path .= “&Address=$forceip”; } select(S); $| = 1; select(STDOUT); print S “GET $path HTTP/1.0\\r\\n\\r\\n”; while(sysread(S, $buf, 10240)) { $retstring .= $buf; } print ”$retstring”; close(S); exit;

    Yes, this was intentionally written “from top to bottom” with no frivolous things such as error checking ;) – any perl hacker will most certainly want to return $retstring and parse it properly, if not test for a valid IP address, &c. I’m sure they probably offer an SSL POST ability, but this is beyond the scope of this sample code, and I wouldn’t want to rely on just ‘Socket’ for rolling my own SSL!

    Conversely, for Dynu, the format is:

    $remoteaddr = gethostbyname(“basicupdate.dynu.com”); $path=”GET http://basicupdate.dynu.com:80/basic/update.asp?domain=$host&password=$pass&ip_address=$forceip HTTP/1.0\\r\\n\\r\\n”;;

    Enjoy your dynamic hostname!

    [Edit: Fixed margins, added information for Dynu.]