Mark Sanborn Mark Sanborn Fishing Mark Sanborn

Coder, Entrepreneur, Blogger, and Coffee Addict

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

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.



This entry was posted in Howto and tagged , , , . Bookmark the permalink.

5 Responses to My Router Doesn’t Support Dynamic DNS, No Problem!

  1. Jade Robbins says:

    Ahh yes love dyndns :D

  2. Tyghe says:

    So I’m assuming that this script checks your ip before it tries to do the update. DynDns will disable your hostname if you try to update more than like 1 time per ~20 days or something.

    I found this out when I did this and the stupid client I used just tries to update regardless if your ip is already correct or not.

  3. Mark Sanborn says:

    Tyghe,

    Good point.

    I actually got banned after using this script after a few hours. I rewrote it so that it only updates if the IP actually changes.

    If you want it I can upload it up here.

  4. sz says:

    can’t you just use the one provided by dyndns? you are guaranteed not to be banned as they say.

  5. Mark Sanborn says:

    sz,

    Good point, for Windows machines please use their updater. They also have recommended third-party Linux clients, but I didn’t see any that I liked.

© 2011 All rights reserved

1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216| generic buying erythromycin alesse next day delivery without a prescription motilium no prescription needed buy cytotec pills canadian pharmacy no prescription needed provera actos by internet buying orlistat pharmacy without prescription lisinopril no prescription needed purchase femara medication buy lipitor cod actonel buy online cheap buy carbozyne online without prescription femara prescription discounts elavil without prescriptions pills buying isotretinoin online pharmacy trazodone no prescription order no prescription metformin birth control no prescriptionAccutane Online Doxycycline online Buy Cheap Lexapro Online No Prescription Prednisone Online Buy Accutane No Prescription