Saturday, 1 September 2007

shell script to update dynamic dns using record route.

You do not need to fetch a page from whatismyip.com to get your own public IP address, traceroute -R (record route) may also give you the address of your WAN information.

A shell script like this might work if you add it to a cron job.
Be careful not to get banned. You must only update your records if your address has changed.
Read the rules at dyndns.org.

#!/bin/sh
ping -R www.cw.net -c 2 cat -n awk '{if ($1==4) print $2}' > newip
if [ `cat newip` != `cat previp` ]; then
wget http://"username:password@members.dyndns.org/nic/update?system=dyndns&hostname=www.yyyyyyy.com,yyyyyy.com&myip=`cat newip`"cat update*system*rm update*system*
fi
cp newip previp
exit

No comments: