Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use a Linksys NSLU2 to update dynamic DNS info Internet
A number of people use dynamic DNS clients (notably DNSUpdate) to point their domains to their computers at home or any where the the host computer is connected via a dynamic IP. This allows some limited web site hosting, email, or some external network troubleshooting. However, it does involve keeping host computer on at all times, which for some, may not be an option.

Enter the Linksys NSLU2. It was originally sold by Linksys to put USB disks on the network. It apparently didn't do too well (there were a number of design decisions that made it very a bit unintuitive), but thanks to the hacker community, it has since become an excellent little server for all things from web services and email to DNS and DHCP. And in this case, this will allow you to use it as nice lightweight Dynamic DNS client with Apple AirPort Extreme.

First all, this assumes that you understand that this may cause some issues with you and your ISP. If you are willing to deal with the consequences, then continue on.

Next, this hint assumes that you have the following:
  • A Dynamic DNS provider (in this case, EasyDNS.com).
  • An NSLU2 with SlugOS installed. There are others distributions you can use as well. SlugOS, however, is the least invasive, since this allows you to keep the Linksys interface, which you will need in case something breaks.
  • Apple AirPort Extreme 2.0
If you do not have Unslug installed, go right ahead and put it on using these instructions. Note that when you download the binary distribution, follow exactly what the README says, or the SlugOS install will not go through (or worse).

Configuring NSLU2:

Next, login into the NSLU2 device and install the following using ipkg:
ipkg install snmp
ipkg install wget 
ipkg install cron
Reasons:

We will need snmp to query the Apple AirPort Extreme Router for the WAN IP (as you will see in a moment). SlugOS already has wget, but it didn't have all the features we needed (namely, http authentication), so we need to install our own (which usually defaults to /opt/bin/wget). And since for some reason, Unslug didn't have cron, we have to install that as well so that we can update DNS at regular intervals.

Configuring AirPort SNMP:

On the AirPort side, make sure that SNMP is enabled by clicking on to Manual Setup » Advanced » Logging and SNMP. By default, it is set to public (which we will use in this case). Don't try to enable 'Allow SNMP over WAN' -- not unless you want outsiders to query your Apple Extreme route; that and SNMP traffic is NOT encrypted. Now from the NSLU2 router (you can also test from your Mac OS X Terminal), assuming that your AirPort Extreme IP is 172.16.1.1, type:
snmpwalk -Os -c public -v 1 172.16.1.1
If you get all sorts of output, then it works. Now let's narrow it down a bit by typing:
snmpwalk -Os -c public -v 1 172.16.1.1 ipAdEntAddr IpAddress
This will get your localhost address, a loopback network address, your router address -- and your WAN address, i.e. the address assigned to your router by your ISP. Now we are ready. Putting it all together:

Here is a script you can use to push your IP over to your Dynamic DNS provider (update_dns.sh):
#!/bin/sh                                                                       
                                                                                
exec_cmd="/opt/bin/wget"                                                        
                                                                                
IP=`snmpwalk -Os -c public -v 1 172.16.1.1 ipAdEntAddr IpAddress |             
    grep -E -v '(127.0.0|169.254.233|172.16.1.1)' |                        
    cut -d : -f 2 | 
 	sed 's/ //g'`                                           
                                                                                
$exec_cmd --http-user=username --http-password=password -q -O -                
http://members.easydns.com/dyn/dyndns.php?hostname=domain.com&myip=$IP
Explanation:

Line three is the path to our own wget binary. Lines five to seven basically query the router (Line 5), then we strip the local address, the loopback addresses, and the routers addresses (line 6), then cut out the WAN address (line 7). However, you will get a leading space in front of the IP, so we strip off that as well using sed (line 8).

Line 10 does the actual update. It will will log you into the Easy DNS update page (using wget) on line 11; in that URL (assuming that you were able to authenticate), your domain name and WAN IP get pushed. If all goes well, you will see this when you run the script:
NOERROR
That means you were able to successfully update your DNS zone. Otherwise, if you have already updated earlier and the zone has not yet expired, you may get:
TOOSOON - back off update frequency
Try again in a few minutes. At this point, if you were successfully, verify by typing this in Terminal:
dig domain.com
(Replace domain.com with your domain, of course.) This will pull up the DNS zone. If your script worked, you can use the Port Mapping feature (Manual Setup » Advanced » Port Mapping) to point specific ports to your NSLU2 device, whether it is ssh, httpd, ftp or any other port. At this point, add the following into crontab (in this case, /etc/opt/crontab):
0,15,30,45 * * * * /root/scripts/update_dns.sh
This updates DNS every 15 minutes, but you can make update at shorter or longer intervals. Now if you use dyndns.org, ovh.net, no-ip.org, ods.org, and hn.org, you can install updatedd:
ipkg install updatedd
and then update your DNS that way instead. However, if you are like me and updatedd doesn't work for you, your provider may have an API you can use to work with instead -- as long as you have your WAN IP, your username and password. This concludes this hint. Have fun!
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[13,025 views]  

Use a Linksys NSLU2 to update dynamic DNS info | 2 comments | Create New Account
Click here to return to the 'Use a Linksys NSLU2 to update dynamic DNS info' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use a Linksys NSLU2 to update dynamic DNS info
Authored by: stomer on Dec 31, '07 08:50:12AM
I think that there might be an easier way of doing this.

ipkg install ddclient

Then edit the conf file as necessary:

vi /etc/ddclient.conf

Check here for help configuring ddclient: http://linux.cudeso.be/linuxdoc/ddclient.php

[ Reply to This | # ]
Use a Linksys NSLU2 to update dynamic DNS info
Authored by: rilindo on Dec 31, '07 08:40:17PM

Hi!

I could be wrong, but it looks like it'll work if it is directly connected to your ISP. However, it may be a bit more problematic if you are behind a router.

And this is where it has to do with the Mac (which is not terribly clear from the title - SORRY! Can somebody fix it?) - with the Apple Air Extreme router, you can get the external IP using SNMP and then you can post the info to your DDNS provider to update the DNS zone.

It should be noted that you can the exact do the same thing from your Mac desktop*, so if you don't mind keeping your desktop on all the time, just run the script off from cron or from launchd (I don't think you don't need to install additional software - just use curl instead of wget and you should be able to get it working with little modification). Of course, if you are concerned about power consumption, this is where this hint is handy

Then there is using third party option i.e. DNSUpdate. That said, this method should be OS independent, so if you upgrade to the next version of Mac OS X, this most likely will still work, wher as the third party option may be a different story.

*First hint to this site and it's already crashing and burning. :/



[ Reply to This | # ]