BASH Script to query all authoritative COM Name servers for a particular domain

This BASH Script looks up all the authoritative name server for the .COM zone and queries each one to test if an update to “example.com” domain in this case, has been applied to each instance (a through m).

Even though this tests all 13 authoritative .COM name servers, be aware that there may be almost 100 if not more instances distributed globally using BGP Anycast routing.


#!/bin/bash
SERVERS=$(dig com. ns +short)
for f in $SERVERS
do
dig example.com @$f
done

Here is some sample output: (total output is over 300 lines so it might be best to redirect the output to a file)


; <<>> DiG 9.9.1-P3 <<>> example.com @f.gtld-servers.net.
;; global options: +cmd
;; Got answer:
;; ->>HEADER< ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 2, ADDITIONAL: 5
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.com. IN A

;; AUTHORITY SECTION:
example.com. 172800 IN NS a.iana-servers.net.
example.com. 172800 IN NS b.iana-servers.net.

;; ADDITIONAL SECTION:
a.iana-servers.net. 172800 IN A 199.43.132.53
a.iana-servers.net. 172800 IN AAAA 2001:500:8c::53
b.iana-servers.net. 172800 IN A 199.43.133.53
b.iana-servers.net. 172800 IN AAAA 2001:500:8d::53

;; Query time: 83 msec
;; SERVER: 192.35.51.30#53(192.35.51.30)
;; WHEN: Tue Sep 25 02:50:32 2012
;; MSG SIZE rcvd: 176

Comments are closed.