There are many ways to do PTR resolving in bulk, and this is just one of them. It doesn't pretend to be the fastest/coolest/best, the only thing I can claim - it works.
# Yuri # 19.02.2013 # this script accepts range of IP addresses to do PTr resolving for # the range has to be in this format: startIp-endIp.startIp-endIp.startIp-endIp.startIp-endIp. # Only answers are printed, i.e. if there is no answer nothing is printed use warnings; use strict; use Net::DNS ; my $res = Net::DNS::Resolver->new(); my $input = shift ; $input =~ /(.+)-(.+)\.(.+)-(.+)\.(.+)-(.+)\.(.+)-(.+)/ ; print "Resolving ptrs for the following range: $input\n" ; print "Started working at: " . scalar gmtime . "\n" ; my ($oct1_start,$oct1_end,$oct2_start,$oct2_end,$oct3_start,$oct3_end,$oct4_start,$oct4_end) = ($1,$2,$3,$4,$5,$6,$7,$8) ; foreach my $oct1 ($oct1_start..$oct1_end) { foreach my $oct2 ($oct2_start..$oct2_end) { foreach my $oct3 ($oct3_start..$oct3_end) { foreach my $oct4 ($oct4_start..$oct4_end) { my $answer = $res->query("${oct1}.${oct2}.${oct3}.${oct4}") ; if (defined $answer) { my @ptr = $answer->answer; foreach my $record_ptr (@ptr) { #print " NEw " . $record_ptr->print ; my $str = substr($record_ptr->string,rindex($record_ptr->string,'R')+1) ; print "$oct1.$oct2.$oct3.$oct4 " . $str . "\n"; } } } } }} print "Run completed at: " . scalar gmtime . "\n" ;
Example run: ** #perl script.pl 194-194.90-90.33-33.0-255**
Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.