close
利用這支程式,來產生黑名單的規則
要先有一份/tmp/IP檔來存黑名單的IP
再產生出ipfw rule
=====================================================
#!/usr/bin/perl
open (F, "/tmp/IP");
@IP=<F>;
close(F);
@IP2 = sort ipsort @IP;
$num=60000;
foreach $i (@IP2) {
chop $i;
print "/sbin/ipfw add $num deny ip from $i"."to me\n";
$num++;
}
sub ipsort { #IP排序副程序
my ($a1, $a2, $a3, $a4) = $a =~ /(\d+).(\d+).(\d+).(\d+)/;
my ($b1, $b2, $b3, $b4) = $b =~ /(\d+).(\d+).(\d+).(\d+)/;
$a1 <=> $b1 or $a2 <=> $b2 or $a3 <=> $b3 or $a4 <=> $b4;
}
=====================================================
目前還在想辦法將產生出來的東西
寫入到/etc/rc.firewall的正確行數
全站熱搜
留言列表