Baz has asked for the wisdom of the Perl Monks concerning the following question:

If I have an array of ip addresses can i use perl/cgi to convert them to their domain names. i.e. 199.5.67.1 to www.google.com
  • Comment on Reverse DNS lookup on a list of ip addresses

Replies are listed 'Best First'.
Re: Reverse DNS lookup on a list of ip addresses
by suaveant (Parson) on Sep 27, 2001 at 17:56 UTC
    Have you looked at Net::DNS?

                    - Ant
                    - Some of my best work - Fish Dinner

Re: Reverse DNS lookup on a list of ip addresses
by Ido (Hermit) on Sep 27, 2001 at 19:58 UTC
    Maybe that could help:
    use strict; my @ips=('208.201.239.56','216.239.33.101'); print join "\n",map {scalar gethostbyaddr pack('C4',split /\./),2} @ip +s;
Re: Reverse DNS lookup on a list of ip addresses (relevant thread)
by ybiC (Prior) on Sep 27, 2001 at 18:38 UTC
    "(code) Resolve list of DNS names" thread might be worth a looksee, Baz.   Is how I automate bulk forward lookups, and includes links to a few CPAN modules of possible interest for reverse-lookupping.
        cheers,
        Don
        striving toward Perl Adept
        (it's pronounced "why-bick")
Re: Reverse DNS lookup on a list of ip addresses
by smellysocks (Beadle) on Aug 18, 2005 at 14:48 UTC
    Well I "forgot" how I solved this problem in the past.

    When I searched perlmonks I found this thread, but I was not happy with the answers. Here is my simple non-CPAN way to solve this issue.
    use Socket; foreach my $key ( keys %report ) { my $hostname="-= Not in DNS =-"; $hostname=gethostbyaddr(inet_aton($key), AF_INET) or $hostname="-= Not in DNS =-"; if ( $report{$key} > 0 ) { print "-=" x 2, " Host: $key ( $hostname )", "-=" x 2, "\n"; } else { print "ERROR Why is this in hash? $key\n"; } }