Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Last active June 21, 2021 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mttjohnson/313f06a8ac8d295ac6b5e1457dc8456a to your computer and use it in GitHub Desktop.
Save mttjohnson/313f06a8ac8d295ac6b5e1457dc8456a to your computer and use it in GitHub Desktop.
dns name sever query comparison
nameserver_source="a.iana-servers.net"
nameserver_comparison="b.iana-servers.net"
dns_records="
example.com a
ftp.example.com a
mail.example.com a
ns1.example.com a
www.example.com cname
example.com mx
example.com txt
example.com ns
example.com soa
"
source_output=""
comparison_output=""
NEWLINE=$'\n'
while read domain
do
source_output+="$(dig +nocmd +noall +answer @${nameserver_source} ${domain} | grep -v "^;")${NEWLINE}"
comparison_output+="$(dig +nocmd +noall +answer @${nameserver_comparison} ${domain} | grep -v "^;")${NEWLINE}"
done < <(echo "${dns_records}")
echo "${source_output}"
echo "${comparison_output}"
@davidalger
Copy link

Ran into this not outputting anything for NS records on sub-domains, adding +authority to the query when an NS record is being looked up solves the issue. The use case being Dotmailer NS records on something like events.example.com. Added these lines in my forked copy of the script: https://gist.github.com/davidalger/a33891d3a2e6858f3a8987bb7f1ab062#file-nsq_compare-sh-L33-L35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment