My Router Doesn't Support Dynamic DNS, No Problem!

Last updated: Oct 23, 2008

Well I just recently hooked up a DSL connection via a DSL modem that was also a router. For regular home users this DSL modem/router is probably good enough but for more complex setups it is useless. In this particular setup we had a custom built firewall. This firewall had a built in dynamic DNS service for ISP’s that rotate IP addresses. The problem however, is that the firewall was behind the DSL modem’s NAT. So it was reporting a private 192.168 number to Dyndns.

We couldn’t turn off NAT on the DSL modem unless we purchased a block of static IPs. The DSL modem, being home orientated, didn’t allow for dynamic DNS.

Fortunately dyndns offers a service to detect your public IP address. They also have an API to change your IP for dynamic DNS. Knowing this I quickly did a search on my favorite perl code repository, CPAN. Sure enough someone made a module that sends updated IP info to dyndns.

Updating DynDNS with Perl

The first thing you will want to do is download the module, Net::DNS::DynDNS. On a Linux box it is super easy.

cpan install Net::DNS::DynDNS

On windows you will need to compile it with dmake and mingw since there are no ppm for Active Perl.

Then create a file called, dyndns.pl, replacing username, password, and yourdomain.selfip with your own values.

#!/usr/bin/perl use Net::DNS::DynDNS; print Net::DNS::DynDNS->new('username', 'password')->update('yourdomain.selfip.com');

You can then update your IP by simply doing

perl dyndns.pl

To setup automatic updating we can use our favorite scheduler, cron.

crontab -e

Then add the following line, pointing to where you saved dyndns.pl

1 * * * * /usr/bin/perl /home/youruser/crons/dyndns.pl

This will update every hour which is plenty for my needs. Feel free to change it to fit yours.

Need to print shipping labels on your site?

Checkout my product RocketShipIt for simple easy-to-use developer tools for UPS™ FedEx™ USPS™ and more.

Get notified on new posts or other things I'm working on

Share: