My new internet connection with NBN changes the IP on a regular basis, but I wanted visibility as to how often.
So I’ve written a bash script which records your IP and date, once it changes it records your new IP and sends you an email to notify you of the new change.
This is completed by querying your no-ip dns record.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/bin/bash domain="$1" log="ip_log_$domain.txt" email="name@gmail.com" currentip=$(nslookup ${domain} | grep Address | tail -n 1| awk '{print $2}') lastip=$(cat $log | tail -n 1 | awk -F ',' '{print $2}') if [ -z ${lastip} ] then echo "$(date),${currentip}" >> ${log} exit 0 fi if [ ${lastip} == ${currentip} ] then echo "Nothing changed." else echo "$(date),${currentip}" >> ${log} mail -s "IP Address Change" ${email} < /home/tdionisakos/ip_log_${domain}.txt fi |
Usage
1 |
./ip_checker.sh domain.no-ip.com |
Cron Entry. (runs every hour)
1 |
33 * * * * /home/tdionisakos/ip_change.sh hop.no-ip.com |
One thought on “Visibility when your IP changes and is updated by no-ip | email notification when ip changes home adsl nbn bash script”