When a domain is pending transfer it may be useful to be notified as soon as possibile when the DNS propagates to our location, so we can reach the new server immediately. This problem is particularly important with some hosting services because you don't have access ahead of that time.
There are some services online to control the DNS propagation, but no one serve the scope better than a script on our computer because no other place is closest than that!
Usually I used to run a simple ping (Debian/Ubuntu/Mint don't have DNS cache), but often I forgot to check regularly ending up with the new domain being accessibile for hours.
How to automate this process? On a Windows system we should use a programming language, but on a Linux system bash alone gives us great power! (and great responsibilities)
#!/bin/bash #DNSCHANGE - v 1.0.0 (19/10/2012) #www.riksoft.it #LGPL licence #This script notifies when a given domain changes IP. #Useful when transferring domains. #Syntax: dnschange <domain> <current ip> echo "Hit CTRL+C to stop checking IP"; stop=0; while [ $stop -lt 1 ] do pingRes=$(ping -c1 $1); #echo $pingRes; if [[ "$pingRes" != *$2* ]] then xmessage -nearmouse "__________IP HAS CHANGED_____________"; stop=1; else sleep 60; fi done
It checks every minute for a change and, if the domain/ip relation change, a message pops up near the mouse pointer.
For the notification I used xmessage instead of zenity because it's installed by default in the ubuntu/debian/mint distros.