DNS is so simple! Unfortunately it seems like it's simple to screw up also, here's a little script I wrote the other day to verify that all my reverse dns was setup correctly. I've written this script before at least twice, so I thought I would post it. Just feed it a CIDR range via command line and it will check all those ips. Like this:
# perl ptrchecker.pl 192.168.0.0/24
#!/usr/bin/perl
use NetAddr::IP;
use Socket;
use strict;
foreach my $cidr(@ARGV) {
my $n = NetAddr::IP->new( $cidr );
for my $ip( @{$n->hostenumref} ) {
next if ($ip->addr() =~ /\.[0|1|2]5?5?$/);
my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyaddr($ip->aton(), AF_INET);
my $addr = join ".", unpack('C4', (gethostbyname $name)[4]);
print "busted ip: " . $ip->addr() . " PTR is $name, A is $addr\n" if ($ip->addr() ne $addr);
#select(undef, undef, undef, 0.05);
}
}
No comments:
Post a Comment