简单测试dns列表中的dns服务器是否可用

#!/usr/bin/perl -w  
 
  
use strict;
use warnings; 
 
 
open FH, "list" or die("can't not open list\n");   

while (my $myline = <FH>) {    
	chomp $myline ;  
	if(length($myline)>0)
	{
		my $cmd = "dig www.sina.com @".$myline;
		my $ret = `$cmd`;
		if(length($ret)<10 || $ret =~  /timed/s )
		{
			print $ret;
			 
		}
		else
		{
			if(open(FHRET, '>>', "success"))
			{
				print FHRET $myline."\n";
				close(FHRET);
			}
		}
	}	  
}  
close FH;  

#注:只有无法解析www.sina.com的会得到结果 ;; connection timed out; no servers could be reached,正常解析的是不会出现timed out这个东西的

你可能感兴趣的:(简单测试dns列表中的dns服务器是否可用)