如何在Ubuntu 12.04上使用ipset和iptables来阻止大量的IP

我想使用这个教程: http : //www.jsimmons.co.uk/2010/06/08/using-ipset-with-iptables-in-ubuntu-lts-1004-to-block-large-ip-范围/

在Ubuntu 12.04中,软件包ipset-source被从存储库中删除我想这就是为什么当我尝试像这样安装时我只会得到一个错误:

apt-get install module-assistant ipset ma ai ipset 

我将如何做到这一点在Ubuntu精确?

我觉得你做错了什么 那篇文章不是最新的,因为它大约是10.04 LTS。 现在你可以发行

 sudo apt-get install ipset 

我刚刚在我的12.04上安装了ipset,没有任何问题。 看看我的安装日志https://gist.github.com/3720382

这是jsimmons的tutoriall在 Ubuntu 12.04上的工作方式:

 sudo apt-get install ipset # enter the countrycode that you dont want to block here (for example de for Germay): DONTBLOCK=de # download the zonefiles into /tmp/zones/ cd /tmp wget http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz mkdir zones cd zones tar -xzvf ../all-zones.tar.gz # remove the zone you want to keep: rm /tmp/zones/$DONTBLOCK.zone FOLDER=/etc/zoneipblock/ mkdir $FOLDER BLOCKLIST=$FOLDER"non_$DONTBLOCK.zone_blocklist" cat /tmp/zones/*.zone > $BLOCKLIST #if you want to block only the biggest blocks, use the short list: BLOCKLIST_SHORT="$BLOCKLIST"_short cat $BLOCKLIST |grep /8>$BLOCKLIST_SHORT cat $BLOCKLIST |grep /9>>$BLOCKLIST_SHORT cat $BLOCKLIST |grep /10>>$BLOCKLIST_SHORT cat $BLOCKLIST |grep /11>>$BLOCKLIST_SHORT cat $BLOCKLIST |grep /12>>$BLOCKLIST_SHORT IPS=$(cat $BLOCKLIST_SHORT) exit #TODO: create the list with the right command #ipset create feckof ... ipset --create feckoff bitmap:ip range [fromip-toip|ip/cidr] for i in $IPS; do ipset add feckof $i done iptables -A INPUT -m set –set feckoff src -j DROP 

那就是脚本几乎完成了,只有feckof列表的创build声明丢失了。

有人可以添加此评论吗?

最糟糕的情况就是从Ipset下载源代码并手动编译。

 wget http://ipset.netfilter.org/ipset-6.13.tar.bz2 tar xvfj ipset-6.13.tar.bz2 cd ipset-6.13 ./configure make make check make install 

有关更多信息,请查阅READMEINSTALL或运行./configure --help以获得一些奇特的选项。