Don't mean to beat this horse, but I ran across an MX
script  that really worked out for us at work. Here it
is. Hope it helps someone out there. Comments welcome,
as I've got a long way to go!! I think most of it
comes from the docs, though:

#!/usr/bin/perl -w
# This one compares mx data from 2 servers
use strict;
use Net::DNS;
#### Parse the file
open IN, "C:/Documents and
Settings/mcauthorn/Desktop/perl_crap/zones_final.txt"
|| die "can't open \n";

my (@lines,@domain_names);
@lines=(<IN>);
chomp @lines;
close IN;
my %name_servers=(
        'xxx.xxx.xxx.xxx'=>'servera',
        'xxx.xx.xxx.xxxj'=>'severb'
        );
my $res = new Net::DNS::Resolver;
foreach my $zone (@lines){
        foreach my $server(keys %name_servers){
        $res->nameservers($server);     
        my $query = $res->query($zone);
        sleep 1;
          if (!$query){
            print "Query error for $zone! \n";
            next;
        }
foreach my $rr ($query->answer) {
 print "$server -->$zone : ", $rr->address ,"\n";
     my @mx=mx($res, $zone); 
        if (@mx){
         foreach $rr (@mx){
         print "MX: ", $rr->preference, " ",$rr->exchange,
"\n";
        }
           } else {print "No mx data for $server \n";}
                                        
              }                                                  } print "\n";
 }#top foreach close ($zone)


# Sorry about the crappy copy / paste.

~Matt

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to