Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare DNS on two different nameservers

I am working on switching the nameserves of my domain to a new DNS service. What is the best tool to compare the new settings with the existing DNS setup.

I have tried to use dig with and without @nameserver to allow me to make sure that the DNS records match between the old and the new provider.

No success so far.

Any ideas ?

like image 846
gkof Avatar asked Jun 13 '12 23:06

gkof


2 Answers

This script was made to compare two zone files during a migration.

It uses colour coding and a final status output to indicate what records are different

SOA and NS records will be different during a migration - just note the differences

ANY record will probably be different too as it includes above types in it.

A MX and TXT records should be the same , if they exist - difference here means a problem !

See Example Screenshot

Source: https://github.com/geek4unix/compare-zones/

like image 192
Neil M Avatar answered Oct 04 '22 21:10

Neil M


I answer that old question, I was confronted with this problem and I solved it this way:

For a single 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 by line (by example: alldomains.txt)

The 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 unique line
  • dig: DNS lookup utility
  • +nottlid: do not display the TTL when printing the record
  • +noall: clear all display flags
  • answer: display the authority section of a reply.
  • @ns.server.com: name or IP address of the name server to query
  • ANY: indicates what type of query is required (ANY, A, MX, SIG, etc.)

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

I hope this can help someone.

like image 31
Code-Source Avatar answered Oct 04 '22 19:10

Code-Source