No-IP Dynamic DNS Provider Update script from Owncloud - no client

I am sharing this script I did to update my hosts on  www.no-ip.com

install DNSUtil from my repos

echo "deb http://viewatbusiness.my.to:8080 wheezy-64k main sid jessie" > /etc/apt/sources.list

apt-get update

apt-get install dnsutils_9.9.5.dfsg-9_armhf.deb libbind9-90_9.9.5.dfsg-9_armhf.deb libdns100_9.9.5.dfsg-9_armhf.deb libisc95_9.9.5.dfsg-9_armhf.deb libisccfg90_9.9.5.dfsg-9_armhf.deb liblwres90_9.9.5.dfsg-9_armhf.deb bind9-host_9.9.5.dfsg-9_armhf.deb host_9.9.5.dfsg-9_all.deb libgeoip1_1.6.2-4_armhf.deb

mkdir -p /shares/scriptsmkdir -p /shares/logs
nano /shares/scripts/noip.sh

copy and past the following into noip.sh

* change USERNAME : PASSWORD with your noip username and password

* change HOSTNAME with the name of teh host you want to update or the group you want to update

PATH=/DataVolume/shares/logs:/DataVolume/shares/scripts:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

now="$(date)"

ip1="$(dig +short myip.opendns.com @resolver1.opendns.com)"
url="http://USERNAME:PASSWORD@dynupdate.noip.com/nic/update?hostname=HOSTNAME&myip="
currentip="$(dig +short HOSTNAME)"
if ["$currentip" == "$ip1"];then
                echo "No update is needed" "$now" >> /shares/logs/noip.log
        else
                ipaddress="$ip1"
                content="$url""$ipaddress"
                echo "$content"
                result="$(curl -s "$content")"
                echo "$result" "$now" >> /shares/logs/noip.log
        fi

 Ctrl +x then Y - enter

chmod a+x /shares/scripts/noip.sh

now set the script to run every 30 Min to check if update is needed by crontab

crontab -e

add the following entry to crontab

30 * * * * sh /shares/scripts/noip.sh

* the script automatically chick if update is needed it send the update to no-ip if the ip-address has not change then it skip the update

full log can be found in /shares/logs/noip.log

2 Likes

Thank you very much for sharing this script. There are some specific situations that could benefit from this.