If you're actually attempting to just resolve the FQDN of a host at an IP
address, (using what you provided) try the following (I replaced $the_domain
with $the_ip in your query):


use strict;
use Net::DNS;

my($the_ip,$the_domain,$rr,$the_query);

$the_ip='80.224.159.46';

#$the_ip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;

#$the_domain="$4.$3.$2.$1.sbl-xbl.spamhaus.org";

my $res = Net::DNS::Resolver->new(
        recurse => 1,
        debug => 0,
);

$the_query = $res->search($the_ip);

foreach $rr ($the_query->answer) {
        print $rr->address."\n";
}


Getting the FQDN of a host is a simple as just running a DNS query on the IP
address.  The DNS servers will then attempt to locate it through the reverse
files (in the case of the IP you provided, that would be
46.159.224.in-addr.arpa), looking for PTR records, and will return the name
of the host based on that PTR record.  If no PTR record exists, you will not
receive back the FQDN of the host.  Attempting to tack a domain name on the
end of a reversed IP address and run a domain name query on it will only
yield results if there is a host in the specified domain which uses that
reversed IP address.

If you are attempting to find something other than the FQDN of a host
specified by an IP address, please let the list know what your actual intent
is.  Otherwise, this should solve your problem.

Chad Uretsky
Lead Network and Security Engineer, IT | NetIQ Corporation





-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Chris
Sent: Tuesday, July 05, 2005 4:04 PM
To: perl-win32-users
Subject: NET-DNS & Regex


I'm attempting to convert an ip address (80.224.159.46) info a fully
qualified domain (46.159.244.80.sbl-xbl.spamhaus.org) and then make a dns
query to determine if any records exist. I cant seem to figure our what I'm
doing wrong here.


use strict;
use Net::DNS;

my($the_ip,$the_domain,$rr,$the_query);

$the_ip='80.224.159.46';

$the_ip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
$the_domain="$4.$3.$2.$1.sbl-xbl.spamhaus.org";

my $res = Net::DNS::Resolver->new(
        recurse => 1,
        debug => 0,
);

$the_query = $res->search($the_domain);

foreach $rr ($the_query->answer) {
        print $rr->address."\n";
}

_______________________________________________
Perl-Win32-Users mailing list [email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to