-
-
Save davidalger/a33891d3a2e6858f3a8987bb7f1ab062 to your computer and use it in GitHub Desktop.
dns name sever query comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
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 | |
if [[ $domain = "" ]]; then | |
source_output+="${NEWLINE}" | |
comparison_output+="${NEWLINE}" | |
continue | |
fi | |
if [[ $domain =~ NS$ ]]; then | |
domain+=" +authority" | |
fi | |
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 "==> ${nameserver_source}" | |
echo "${source_output}" | |
echo "==> ${nameserver_comparison}" | |
echo "${comparison_output}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment