Created
January 22, 2019 13:42
-
-
Save pgasiorowski/464fb0d61b17a528335eebb5e679fd17 to your computer and use it in GitHub Desktop.
Compares DNS records across two nameservers. List of subdomains is taken from zone file
This file contains hidden or 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
#!/bin/bash | |
# Compares DNS records across two nameservers. List of subdomains is taken from zone file | |
# | |
# Based on https://stackoverflow.com/questzions/11024797/compare-dns-on-two-different-nameservers | |
DOMAIN=example.com | |
OLD=ns1.nameserver.com | |
NEW=ns2.nameserver.com | |
ZONEFILE=example.com.zone | |
SLEEPT=0.5 | |
# Extract unique fully qualified domain names from zone file | |
DOMAINS=`cat $ZONEFILE | egrep -v '^\s' | egrep -v '^[;$]' | egrep -v '^$' | awk -v domain=$DOMAIN '$1 ~ /\.$/{ print $1; next }{ print $1 "." domain "."; next }' | sort | uniq` | |
# Query each record from both nameservers to get the differences | |
diff <(sort -u <(for host in $DOMAINS; do sleep $SLEEPT; dig +nottlid +noall +answer @$OLD $host ANY; done) ) <(sort -u <(for host in $DOMAINS; do sleep $SLEEPT; dig +nottlid +noall +answer @$NEW $host ANY; done) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment