Bash script to auto-update Dynamic DNS on FreeDNS

This bash script is especially useful when your router default dynamic dns function updates is not consistent and require reboot in order for it to update.

If you have a home machine that runs 24/7 connected to Internet, you can schedule a cronjob to execute this script on every 1 hour so your domain/subdomain always get updated with the latest dynamic IP.


if test -f /root/freedns/freedns-last-ip.conf
	CacheIP=$(cat /root/freedns/freedns-last-ip.conf)

CurreIP=$(wget -o /dev/null -O /dev/stdout | grep Detected | cut -d : -f 2 | cut -d '<' -f 1 | tr -d " ")

if [ "$CurreIP" = "$CacheIP" ]
	echo "Update not required..."
	echo "Updating with " $CurreIP
	wget -o /dev/null -O /dev/stdout
	echo `date` "Updating log with IP " $CurreIP >> /root/freedns/freedns-upd.log

rm -f /root/freedns/freedns-last-ip.conf
echo $CurreIP > /root/freedns/freedns-last-ip.conf

Leave a Reply

Your email address will not be published. Required fields are marked *