I have been trying to convert an IP address into it's DNS name using DNS::Resolver without much joy.
I have used DNS::Resolver to convert DNS names to IP addresses successfully.
 
OS: WIN32
Perl V 5.8.2
 
The return value fails with the following error message:
query failed: NXDOMAIN
Any thoughts on where I'm going wrong?
Thank you for any help.
 
 
#!/user/bin/perl
 
my $res = Net::DNS::Resolver->new;
 
my $ipaddress ="10.80.0.2";
 
my $query = $res->search($ipaddress);
if ($query) {
    foreach my $rr ($query->answer) {
        next unless $rr->type eq "PTR";
        print "Server name is ",$rr->ptrdname, "\n";
    }
} else {
      warn "query failed: ", $res->errorstring, "\n";
}
 
#End code
 


------------------------------------------------------------
The information contained in or attached to this email is
intended only for the use of the individual or entity to
which it is addressed. If you are not the intended
recipient, or a person responsible for delivering it to the
intended recipient, you are not authorised to and must not
disclose, copy, distribute, or retain this message or any
part of it. It may contain information which is confidential
and/or covered by legal professional or other privilege (or
other rules or laws with similar effect in jurisdictions
outside England and Wales).
The views expressed in this email are not necessarily the
views of Centrica plc, and the company, its directors,
officers or employees make no representation or accept any
liability for its accuracy or completeness unless expressly
stated to the contrary.

Reply via email to