iptables出错18446744073709551615和2.6.23以后使用connlimit的方法

Jan 25th, 2010

转载本站文章请注明,转载自:扶凯[http://www.php-oa.com]

本文链接: http://www.php-oa.com/2010/01/25/iptables-18446744073709551615-connlimit.html

在2.6.23以上的内核中使用connlimit时,常常会出下面二个错
比如:当我们打

iptables -A INPUT -p tcp -s 192.168.1.10 -m connlimit --connlimit-above 3 -j DROP

iptables: Unknown error 18446744073709551615
iptables:Invalid argument

在tail -f /var/log/messages时能发下面的的出错提示
ip_tables: connlimit match: invalid size 32 != 16
ip_tables: connlimit match: invalid size 32 != 24

很多网上的文章超级麻烦,还讲怎么样编译内核什么之类,其实在2.6.23以后connlimit 的模块就变成了系统内核本身就支持的啦.不需要编译.
在07年的内核开发的邮件列表中

 

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=370786f9cfd430cb424f00ce4110e75bb1b95a19
见到了下面的内容.

[NETFILTER]: x_tables: add connlimit match

ipt_connlimit has been sitting in POM-NG for a long time.
Here is a new shiny xt_connlimit with:

 * xtables’ified
 * will request the layer3 module
   (previously it hotdropped every packet when it was not loaded)
 * fixed: there was a deadlock in case of an OOM condition
 * support for any layer4 protocol (e.g. UDP/SCTP)
 * using jhash, as suggested by Eric Dumazet
 * ipv6 support
 *
那么,现在只是支持的为什么不能使用的问题.会提示iptables: Unknown error 18446744073709551615和iptables:Invalid argument

其实很简单,内核是支持了还得我们的iptable支持.所以问题出在这个地方,网上无数的人都在不断的重复的编译.其实只要编译过iptables重新安装就好了.

先到ftp://ftp.netfilter.org/pub/iptables/ 选一个你喜欢的数字做版本号的iptables,最好新点比如1.4.0就支持.1.3.5是不支持的.

解压进入iptables的目录,做最常用的几步

cd /root/wh/iptables-1.4.6
./configure
make
make install

上面就编译完了

需要停止iptables服务

service iptables stop

用/usr/local/sbin/中的iptables(新版本)文件替换/sbin/iptables(这个是老版本的)

cp /usr/local/sbin/iptables /sbin/
cp /usr/local/sbin/iptables-restore /sbin/
cp /usr/local/sbin/iptables-save /sbin/

主要是上面三个文件,给整个目录也拿过去也行

测试一下

 

iptables -V
iptables v1.4.6
services iptables restart

 

注:2.6.23以前的内核的处理方法,请参照<

E点废墟 – Linux  xok.la/2008/02/rhel5_iptables_connlimit_success.html

 

 

Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪 ViVi 365Key 网摘 天极网摘 和讯网摘 博拉网 POCO 网摘 饭否 QQ 书签 Digbuzz 我挖网 Mister Wong
  1. 宁波SEO
    Jan 31st, 2010 at 06:39
    Reply | Quote | #1

    技术文章,支持。