ddclient - get your IP address from behind NAT, without configuring your 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
This gives a fine, fine page showing my IP address with all the headers. Chop it down to size with head and tail:
apt-get install curl (since it wasn't installed already on my Debian box)
curl -s checkip.dyndns.org
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=220.127.116.11So, 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` -vNotice 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.