#!/bin/bash NS="127.0.0.1" NSKEY="/etc/bind/ddns-key.blackgate.org.conf" TMPFILE="/var/www/html/new_dynamic_ip.txt" ZONE="blackgate.org" TIMEOUT=60 OLDIP=$(dig @$NS $ZONE A | grep ^$ZONE.*A | awk '{ print $5 }') NEWIP=$(cat $TMPFILE) echo "old: $OLDIP" echo "new: $NEWIP" if [ "$OLDIP" != "$NEWIP" ]; then echo -e " update delete $ZONE. A update add $ZONE. $TIMEOUT A $NEWIP show send" | /usr/bin/nsupdate -k $NSKEY rndc freeze $ZONE rndc thaw $ZONE else echo "no update required" fi