Solved

Compare DNS Zone Transfers

Posted on 2006-11-20
5
322 Views
Last Modified: 2007-02-12
Hello-

I am looking for a way to compare AXFRs from two servers.  We have upgraded our VitalQIP Enterprise server and want to make sure no DNS entries were dropped from the central database during the upgrade process.  We want to pull the DNS Zone from the production server and compare entry for entry with that in a test environment.  

Thank you!
0
Comment
Question by:aaeandcee
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:mikebernhardt
Comment Utility
Just put both db files on the same machine with ftp or something, and use diff to compare. If you're on Windows, there's freeware called CSDiff that does the same thing (compares 2 files and shows you what's different. Or write a little perl script that will parse the file, pull only lines that start with an IP address, sort them and count them. If the count is different, it should be easy to find the missing entries if they're sorted.
0
 

Author Comment

by:aaeandcee
Comment Utility
I'm dealing with zones that are several thousand entries in all.  We have tried WinDiff in the past, but with WinDiff we have missed entries.  We are looking for something that would definitively compare zone files, not just line placement, count, etc.
0
 
LVL 28

Expert Comment

by:mikebernhardt
Comment Utility
I don't think you'll find a tool that's made to do the somewhat uncommon job you have in mind, and why pay more? I would definitely write a perl script to do it then. I mean, it's a text file. Let it parse for only the actual host entries, then sort and count them (that way you don't get caught because of an extra line with a semicolon in it or something). If the count is the same, you're good. If not, THEN use diff and you'll find the exact spot where the mismatch occurs.
0
 

Author Comment

by:aaeandcee
Comment Utility
That doesn't sound like too bad of an idea.  I'm not that proficient with Perl, any examples on how to write the script?
0
 
LVL 28

Accepted Solution

by:
mikebernhardt earned 250 total points
Comment Utility
Here you go. This script finds sorts lines that begin with numbers 1-9, dumps them into 2 new files and tells you how many lines are in the new files. If they don't match, then use diff on the new files and you'll find the problems quickly. Fix them in the original files and run the script again. You may have to do a few iterations of this if there are numberous problems.

#!/bin/perl
# read the zone files
open (ZONE1, "./zone1.db");
open (ZONE2, "./zone2.db");
@zone1 = <ZONE1>;
@zone2 = <ZONE2>;
# set counter
$x = 0;
$y = 0;
# open new writeable files
open (SORTED1, ">./sortedzone1.db");
open (SORTED2, ">./sortedzone2.db");
# sort the data
@zone1 = sort  {$a <=> $b} @zone1;
@zone2 = sort  {$a <=> $b} @zone2;
#parse out junk and create new file for checking
foreach (@zone1) {
#      chomp;
      if ($_ =~ /^[1-9]/) {
        $x++;
        print SORTED1;
        }
}
foreach (@zone2) {
#      chomp;
      if ($_ =~ /^[1-9]/) {
        $y++;
        print SORTED2;
        }
}
print "\@zone1 has $x lines\n\@zone2 has $y lines\n";
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is an article about my experiences with remote access to my clients (so that I may serve them) and eventually to my home office system via Radmin Remote Control. I have been using remote access for over 10 years and have been improving my metho…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now