After test, I found it is much faster than the DNSlookup .
Also, with a simply modification by adding a loop, I can use it as a stressing tools to test the new LINUX based DNS server.
Here is it:
#!/usr/local/bin/perl
use Socket;
$counter = 0;
$errorfile = "/home/user/Desktop/dnserror.log";
open ERRORFILE, ">$errorfile" or die "unable to open $errorfile $!";
open (MYFILE, 'host.list');
while (
chomp;
$name = $_;
my($subname,$aliases,$type,$len,@thisaddr)=gethostbyname($name);
my $subaddr = inet_ntoa(scalar(gethostbyname($subname || 'localhost')));
if ($subaddr == '127.0.0.1') {
print "========> $name lookup failed\n" ;
$counter = $counter + 1;
print ERRORFILE "$name lookup failed at\n";
} else {
print " resolved name: $name \t IP address: $subaddr \n";
}
}
close (MYFILE);
print " total failed : $counter \n";
close (ERRORFILE);
All the hostname should be keep in a host files in this format:
example:
www.yahoo.com
www.google.com
123.com.hk
www.ingo.gov.hk
ww.hk
There is an error counter, so you may check the no. of failed lookup.
output like this :
[root@redhat1 Desktop]# perl dnslook.pl
resolved name: www.yahoo.com.hk IP address: 202.43.220.99
resolved name: www.google.com.hk IP address: 74.125.71.106
========> 123.com.hk lookup failed
resolved name: www.info.gov.hk IP address: 202.128.238.115
resolved name: ww.hk IP address: 222.87.2.134
========> 123.hkex lookup failed
total failed : 3
沒有留言:
張貼留言