Notify me if IP is propagated in DNS

Posted by: gdelmatto  :  Category: Memos

So here’s my short snipped of a bash shell loop I hacked up.
It’s only purpose is to check in DNS repeatedly if a certain IP address is propagated for a given fully qualified domain name.

If the script sees the IP address, it would “ring the bell” and exit, otherwise it sleeps for a while and repeats the check.

This way I could leave it running in the console and – whenever the IP appeared in DNS – I’d get an audible alert.
No big trick after all 😉

Here’s the code:

$ while [ : ] ; do echo scanning ... ; dig @DNSSERVER FQDN | grep IPADDR && { echo -e "\a"; break; } || sleep 5;   done

And here’s what it looks like in action:

scanning ...
scanning ...
scanning ...
scanning ...
scanning ...
scanning ...
my-cool-fqdn.some.domain.tld. 3600 IN	A	192.0.2.1
[you would hear a "bing" tone at this point as well]

Comments are closed.