[Wylug-help] How to Query the DNS

Jason Lander jason at env.leeds.ac.uk
Fri Oct 22 15:11:41 BST 2004


Dave,

> Is there any simple (linux) way of finding all the names associates
> with a particular IP address?

As James Holden says, if there is a valid DNS ptr record it should resolve
to all the names.

The following bit of Perl will collect names and aliases together

use Net::hostent;
use Socket;

$ip = $ARGV[0];

$h = gethostbyaddr(inet_aton($ip), AF_INET);
@names   = ($h->name(), @{$h->aliases()});
print join "\n", @names;
print "\n";

- Jason





More information about the Wylug-help mailing list