Solved

Compare DNS Zone Transfers

Posted on 2006-11-20
5
332 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
ID: 17981261
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
ID: 17981358
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
ID: 17981718
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
ID: 17981829
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
ID: 17982626
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now