Comparing DNS on two different name servers

I am working on switching my domain name domains to a new DNS service. What is the best tool for comparing new settings with your existing DNS setting.

I tried using dig with and without @nameserver so that I can make sure that the DNS records match between the old and the new provider.

There is no success so far.

Any ideas?

+6
source share
3 answers

I answer this old question, I ran into this problem and I solved it like this:

For one domain:

diff <(sort -u <(dig +nottlid +noall +answer @ns.myfirstserver.com example.com ANY) ) <(sort -u <(dig +nottlid +noall +answer @ns.mysecondserver.com example.com ANY) ) 

For multiple domains or subdomains:

  • Create a text file with 1 domain per line (for example: alldomains.txt)

Command line:

 diff <(sort -u <(for host in $(cat alldomains.txt); do dig +nottlid +noall +answer @ns.myfirstserver.com $host ANY; done) ) <(sort -u <(for host in $(cat alldomains.txt); do dig +nottlid +noall +answer @ns.mysecondserver.com $host ANY; done) ) 

Comments:

  • diff: compare files line by line
  • sort: sort lines of text files
  • -u: make sure that there is only a unique string
  • dig: DNS lookup utility
  • + nottlid: do not display TTL when printing a record
  • + noall: clear all display flags
  • answer: display the authority section of the response.
  • @ ns.server.com: name or IP address of the name server for the request
  • ANY: indicates what type of request is required (ANY, A, MX, SIG, etc.).

You can redirect the file by adding > myresult.txt at the end.

I hope this can help someone.

+17
source

I would just like to say what an awesome bit of code - thanks!

0
source

And yes! Inspired by the answer from the source code, I created this to test from a well-known zone file. Since ANY request does not display the entire zone.

The input is in the format of the binding file with the first field, required and complete !! No support for an empty first field or shortened yet!

 zone=test.txt; ns1=ns1.test.com; ns2=ns2.test.com; \ zcl=$(basename ${zone} .txt)_cl.txt; zl1=$(basename ${zcl} .txt)_${ns1}.log; zl2=$(basename ${zcl} .txt)_${ns2}.log; \ echo "Diffing the stuff in $zcl (from $zone) for $ns1 <-> $ns2" >&2 ;echo " loggings to $zl1, $zl2" >&2 ; \ cat $zone | awk 'BEGIN {IFS=" "} $1 !~ /^;|^[[:space:]]+|^$/ {t=$4; if (!match($2,/[[:digit:]]/)) t=$3; n=$1; print n " " t }' | sort -u > $zcl ; \ diff <(sort -u <(while read host type; do echo "Q $host $type" >&2; dig +nottlid +noall +answer @$ns1 $host $type; done < $zcl) | tee $zl1 ) \ <(sort -u <(while read host type; do dig +nottlid +noall +answer @$ns2 $host $type; done < $zcl) | tee $zl2 ) && echo "OK" 
0
source

All Articles