19May/112

Dynamic DNS on the NSLU2

OpenWRT

Whoa hold it right there! Don't read this! It didn't work! Well, okay. Read it. Maybe you can tell us what we did wrong. DynDNS kept blocking us: It seems that Teh Slug kept forcing updates too often. We ended up going for a good ol' DD-WRT that Badger32d scrounged up from Iraq. Oh, don't worry, Teh Slug still gets lots'a love!

Now that you have flashed OpenWRT to your NSLU2 , you need to find a practical use for it. If you are like me, you don't own a fancy router that supports Dynamic DNS updating, and you don't want to leave your computer on all of the time, sucking power and money just to keep the door to your network open.

Enter the NSLU2. It's silent, sips power, and needs something to do, so let's get Dynamic DNS updating on it, shall we?

Now the first thing to note is that normally, OpenWRT runs on standard routers that have WAN ports and such. Usually, DDNS (the package that updates Dynamic DNS) can just watch for changes to your IP address on your WAN port. If you are like me, Teh Slug is sitting on your network, just being a client, while your router does the rest of the work.

 

Since Teh Slug isn't controlling the WAN port on your router, it has no idea what your public IP address is. It only knows it's own address, which in my case is 192.168.0.2. That doesn't help at all. What makes this article unique from all of the others is that we will deal with this problem specifically.

First, we need to install two packages: ddns-scripts and luci-app-ddns.

ssh root@192.168.0.2
opkg update
opkg install ddns-scripts luci-app-ddns

 

Dynamic DNS Configuration Page

This next part can be configured with the command line, but for simplicity I'll just show you how to configure it LuCI.

Head over to Services > Dynamic DNS and fill everything out. This is pretty self-explanatory, except for one key part. In the "Source of IP-Address" menu choose "URL". In the "URL" box enter "http://checkip.dyndns.com/". Now, Teh Slug won't try to send "192.168.0.2" to your dynamic DNS provider, instead checking the website to see what your real external IP is. Click "Save and Apply," and you are done right? Wrong.

At this point, Teh Slug SHOULD automatically keep DNS updated, but it doesn't. It appears to be a bug in the script. Fortunately, there is a fix. At the command line, you can force Teh Slug to check and update your IP if you type:

sh
. /usr/lib/ddns/dynamic_dns_functions.sh #note the leading period!
start_daemon_for_all_ddns_sections
exit

Of course, this isn't at all practical, because when your IP falls out of sync, Teh Slug won't automatically update. To fix this, we'll set up a cron job that will automatically take care of this every ten minutes. First, create a script.

vi /etc/ddns-cron.sh

In the new script:

#!/bin/sh
. /usr/lib/ddns/dynamic_dns_functions.sh
start_daemon_for_all_ddns_sections
exit

To exit vi, press Esc, then type :wq and press enter to write and quit vi. Now, make it executable.

chmod a+x /etc/ddns-cron.sh

 

Next, open the crontab file to edit it.

crontab -e

You are back in vi. Add this cron job:

10 * * * * sh /etc/ddns-cron.sh

Now, it will run that script every 10 minutes. Again, press Esc, type :wq to write and quit vi. Reboot Teh Slug.

reboot
exit

Wait at least 10 minutes, and have a friend on another connection try to ping you or attempt to access a service you are hosting. You have now configured Teh Slug to keep your dynamic DNS service updated!

Many thanks to badger32d for helping me find this fix.

 

 

 

 

 

 

  • http://www.isaiahjroberts.com/ Isaiah J Roberts (Izzy)

    Testing Disqus… <3

  • numb

    so, it did work after that cron was added?

    cool you didn’t go back to ddwrt. i think that distro is garbage nowadays and have since moved back to openwrt.

Switch to our mobile site