用perl写的,实时黑名单列表可以自己添加。

注意:一定要选择没有被劫持的DNS服务器(比如google的8.8.8.8、8.8.4.4)。如果非得用被劫挂的,需要在后面添加代码判断返回的IP是否为127.X.X.X,如果不是则一般不是被列入黑名单。

 

#!/usr/bin/perl -w
use Net::Nslookup;
use strict;
my @rbl=qw/l2.apews.org b.barracudacentral.org bl.spamcop.net cblplus.anti-spam.org.cn dnsbl.njabl.org dnsbl.sorbs.net rbl.anti-spam.cn sbl-xbl.spamhaus.org zen.spamhaus.org /;

print "please input the IP:";
chomp(my $IP = <STDIN>);

my @IP = split /\W/,$IP;
   @IP = reverse @IP;
my $PI = join ".",@IP;
#my $PI="$IP[3].$IP[2].$IP[1].$IP[0]";
foreach my $rbl (@rbl) {
my $host=($PI.".$rbl");
print "Looking up ",$rbl,"\n";
my $addr = nslookup(host=>$host,type=>"A");
if($addr){
print "*_*!*_*!*_*!In the blacklist $rbl*_*!*_*!*_*!\n";
$addr= "";
}
#else {print "$IP is not in the RBL.\n"} 
}