DynamicDNS

From EpixStudios

Jump to: navigation, search

This is a cron script to check my IP address on DNS exit matches the server's real address

ipCheck.sh

#!/bin/bash

user=USERNAME
pass=PASSWORD
domain=DOMAIN_NAME


check()
{
       ipCurrent=$(curl http://checkip.dyndns.org/ 2> /dev/null | sed -e 's!.*: \(.*\)</body>.*!\1!')
       ipSaved=$(cat /etc/cron.hourly/ipAddress)

       echo "Saved IP Address:    $ipSaved"
       echo "Current IP Address:  $ipCurrent"

       if [ $ipCurrent != $ipSaved ]
       then
       {
               echo "IP address changed - update required"
               update $ipCurrent
               echo $ipCurrent | cat > /etc/cron.hourly/ipAddress
       }
       else
       {
               echo "IP addresses match - no update required"
       }
       fi;
} 



update()
{
        echo "IP address being updated to $1"
        curl "http://www.dnsexit.com/RemoteUpdate.sv?login=$user&password=$pass&host=$domain&myip=$1"
        echo
        echo "End of update"
}


check
Personal tools