I tried playing with Net::Nslookup and couldn't get it to install either. Seems there's an issue with this module. However, there's another one that might do what you're trying to do, Net:NS::Nslookup. I just scribbled together this quickie that might do what you want:
Code:
#!/usr/bin/perl
use warnings;
use strict;
use Net::DNS::Nslookup;
my $outfile = "dnsResults.csv";
open( OUTPUT, ">", $outfile ) || die "Can't open file '$outfile' for writing: $!";
my $infile = $ARGV[0] || die "Need to enter a file with a list of IP Addresses";
open( INFILE, "<", $infile ) || die "Can't open the input file '$infile' for reading: $!";
while (<INFILE>) {
chomp;
my $dnsLookup = Net::DNS::Nslookup->get_ips( $_ );
print OUTPUT "$dnsLookup\n";
}
close( OUTPUT );
close( INFILE );
If you run it with:
Code:
perl nslookup.pl <file_with_sitenames>
the output will be (written to a file called dnsResults.csv):
Code:
www.google.com,173.194.73.147
www.google.com,173.194.73.105
www.google.com,173.194.73.106
www.google.com,173.194.73.99
www.google.com,173.194.73.103
www.google.com,173.194.73.104
www.ubuntuforums.org,91.189.94.12
www.cnn.com,157.166.240.13
www.cnet.com,64.30.224.103
www.perl.org,207.171.7.51
www.perl.org,207.171.7.41
I think that at least should give you a starting point.
Bookmarks