Wednesday, November 21, 2007

ddclient - get your IP address from behind NAT, without configuring your router

As previously mentioned, I had downloaded ddclient and was trying to make it work, but was getting errors because of NAT on my router.

My router's not specifically mentioned as one of the Linksys routers ddclient supports, and I played briefly with trying to set ddclient's options to log into my router, with no success. I wasn't patient enough to try every ddclient router option and see if any worked. Time to try a different option...

I can get my IP address in a webpage easily enough, using


apt-get install curl (since it wasn't installed already on my Debian box)

curl -s checkip.dyndns.org

This gives a fine, fine page showing my IP address with all the headers. Chop it down to size with head and tail:
curl -s checkip.dyndns.org head -c -16 tail -c 13
(Notice here, I decided not to use the cut command, which would introduce a subtle bug if my IP address changed).

You can feed ddclient an IP address like so:

ddclient ip=11.22.33.44
So, we can use good ol' page 4-4 of "Unix In A Nutshell" to do command substitution. We use the `` quotes to shove the IP address into the ddclient command:

ddclient -ip=`curl -s checkip.dyndns.org head -c -16 tail -c 13` -v
Notice that this still will give an error in both the Debian-okayed version of ddclient and ddclient version 3.7.3, but not a fatal one, as we can see with the -v (for verbose) flag. Success!

Feedback welcome, certainly. If you're putting this in as a cron job, don't run it crazily often. It's not like your IP address changes twice a minute. Thanks to the generous folks at DynDNS for providing such a useful tool, and thanks to the good people of ZoneEdit for the Dynamic DNS page that got me started on this path.

2 Comments:

OpenID Tams said...

Not necessary.

Just edit /etc/ddclient.conf and change the line starting with "use" to:

use=web, web=dyndns

5:17 PM  
Blogger Todd D. said...

Cool. I think I have the default of dnspark in there.

Are you using Zoneedit?

http://boardgamemadness.blogspot.com/2008/06/easy-fixes-how-to-fix-ddclient-for.html

5:28 PM  

Post a Comment

<< Home