This shows you the differences between two versions of the page.
— |
dnsactual.sh [2017/04/15 21:45] (current) zeppo created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | **dns script** | ||
+ | The original | ||
+ | |||
+ | <code> | ||
+ | ############################################################################## | ||
+ | # | ||
+ | # application name: dnsactual | ||
+ | # other files: dnsactual.conf (keeps the last updated ip) | ||
+ | # dnsactual.log (register date & time of the actualization) | ||
+ | # Author: Ernest Danton | ||
+ | # Date: 01/29/2007 | ||
+ | ############################################################################## | ||
+ | |||
+ | if test -f /etc/freedns/dnsactual.conf | ||
+ | then | ||
+ | CacheIP=$(cat /etc/freedns/dnsactual.conf) | ||
+ | fi | ||
+ | #echo $CacheIP | ||
+ | CurreIP=$(wget http://freedns.afraid.org/dynamic/check.php -o /dev/null -O /dev/stdout | grep Detected | cut -d : -f 2 | cut -d '<' - | ||
+ | f 1 | tr -d " ") | ||
+ | #echo $CurreIP | ||
+ | if [ "$CurreIP" = "$CacheIP" ] | ||
+ | then | ||
+ | # Both IP are equal | ||
+ | echo "Update not required..." | ||
+ | else | ||
+ | # The IP has change | ||
+ | echo "Updating http://free.afraid.org with " $CurreIP | ||
+ | wget http://freedns.afraid.org/dynamic/update.php?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -o /dev/null -O /dev/stdout | ||
+ | echo `date` "Updating log with IP " $CurreIP >> dnsactual.log | ||
+ | fi | ||
+ | rm -f /etc/freedns/dnsactual.conf | ||
+ | echo $CurreIP > /etc/freedns/dnsactual.conf | ||
+ | </code> | ||
+ | |||
+ | This is what I worked it into | ||
+ | |||
+ | <code> | ||
+ | ############################################################################## | ||
+ | # | ||
+ | # application name: dnsactual. orginally from Ernest Danton 01/29/07 | ||
+ | # | ||
+ | # I chaned it to to make more sense to me, but it is mostly the same | ||
+ | # | ||
+ | # | ||
+ | ############################################################################## | ||
+ | |||
+ | echo `date` "running dnsactual.sh " >> /home/pi/freedns/dnsrun.log | ||
+ | |||
+ | CurreIP=$(wget http://freedns.afraid.org/dynamic/check.php -o /dev/null -O /dev/stdout | grep Detected | cut -d : -f 2 | cut -d '<' -f 1 | tr -d " ") | ||
+ | |||
+ | echo $CurreIP > myip.conf | ||
+ | DOMAIN="www.domain-name.org" | ||
+ | registered=$(nslookup $DOMAIN|tail -n2|grep A|sed s/[^0-9.]//g) | ||
+ | echo $registered > /home/pi/freedns/dnslkup.txt | ||
+ | |||
+ | if [ "$CurreIP" = "$registered" ] | ||
+ | then | ||
+ | # Both IP are equal | ||
+ | echo `date` "Update not required..Current IP " $CurreIP > /home/pi/freedns/dnsactual.log | ||
+ | else | ||
+ | # The IP has change | ||
+ | echo "Updating http://free.afraid.org with " $CurreIP | ||
+ | wget http://freedns.afraid.org/dynamic/update.php?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -o /dev/null -O /dev/stdout | ||
+ | echo `date` "Updating log with IP " $CurreIP > /home/pi/freedns/dnsactual.log | ||
+ | echo `date` "Updating log with IP " $CurreIP >> /home/pi/freedns/dnschange.log | ||
+ | fi | ||
+ | |||
+ | </code> |