in reply to Re: hostname from ip
in thread hostname from ip
Far too complex!
#! /usr/bin/perl -w use strict; use Socket; for( @ARGV ) { if( my $host = gethostbyaddr( inet_aton($_), AF_INET )) { print "$_ is $host\n"; } else { print "$_ NXDOMAIN\n"; } }
Works on my machine :)
Note that this will return one record. If you are doing funky things with multiple A or PTR records it might miss the information you're interested in. In which case the Net::DNS module will let you iterate through the RR set. Otherwise it's overkill.
|
|---|