DynDNS update script
I recommend using the ddclient
utility to update your hostname when using a dynamic IP address with http://www.dyndns.org/ or similar services.
I wrote the following script on my Red Hat Linux system to update my dyndns.org hostname when my
dynamically-assigned IP address changes. The script makes use of nslookup, lynx, and dyndnsupdate.
Since I am using Network Address Translation with my router, and am
using a private class C IP address internally, I use the http://whatismyip.com/ Web site to
determine my external (router's) IP address.
I am also running BIND as a caching nameserver; I restart BIND when my
IP address changes to clear the DNS cache.
Since my IP address changed very infrequently, I am using DynDNS'
# This script uses
"dyndnsupdate" available at http://www.bebits.com/app/2927
# HOSTNAME is your DynDNS
# NSLOOKUP is the current DNS
entry for your DynDNS hostname
$HOSTNAME | tail -2 | head -1 | cut -d" " -f2`
# CURRENT_IP is your router's
| grep -A2 "Your current IP Address is:" | tail -n1 | tr -d ' '`
# Is CURRENT_IP returning
if [ "$CURRENT_IP" = "unknown" ]
# Is our current IP in the
DynDNS DNS records? If not, update them.
if [ "$NSLOOKUP" !=
"$CURRENT_IP" ] ; then
-a $CURRENT_IP -h your_hostname.dyndns.org -m \
-s statdns \
# Flush local DNS
cache of $HOSTNAME
Back to brandonhutchinson.com.
Last modified: 01/26/2004