My perl based subroutine that does Net::DNS based checking follows,
comments please...
sub dns_rev_resolve()
{ # Check for a PTR record and try to match it up with an A query...
($ipsrc)=@_;
my $target_IP = join('.', reverse split(/\./,
$ipsrc)).".in-addr.arpa";
my $res = Net::DNS::Resolver->new;
my $query = $res->query("$target_IP", "PTR");
if ( $query ) # Okay, there is a PTR record...
{
foreach my $rr ($query->answer)
{
next unless $rr->type eq "PTR";
$rev_addr = $rr->rdatastr;
}
my $res2 = Net::DNS::Resolver->new;
my $forward_query = $res2->query("$rev_addr");
if ( $forward_query )
# Okay, the PTR record forward resolved...
{
foreach my $rr2 ($forward_query->answer)
{
next unless $rr2->type eq "A";
$forward_addr = $rr2->address;
}
}
}
else # NO PTR record will be treated as a match for now...
{
return "YES";
}
if ( $forward_addr =~ /$ipsrc/ )
# Check for a real match in this case...
{
return "YES";
}
else
{
return "NO";
}
} # END of dns_rev_resolve...
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug