More Perl - Reverse Lookup
All domain names translate to an IP address generally speaking, however if you have an IP address and wish to know who it belongs to... Do a reverse IP lookup.
#!/usr/bin/perl -w
use strict;
use Socket;
my $host =$ARGV[0]
or die "useage: $0 ipaddr";
print reverse_lookup($host)
|| "unknown", "\n";
##################################
sub reverse_lookup {
##################################
my ($ip) = inet_aton $_[0];
return (
gethostbyaddr(
$ip, AF_INET
)
)[0];
}
Labels: Perl, Reverse IP

1 Comments:
Oh and i am aware one could just do an nslookup to gain more information... But hey! I am new to Perl, any suggestions/tips/comments are appreciated.
Post a Comment
<< Home