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

转自:http://www.php-oa.com/2010/01/25/iptables-18446744073709551615-connlimit.html


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

1
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的目录,做最常用的几步

1
2
3
4
cd /root/wh/iptables-1 .4.6
. /configure
make
make install

上面就编译完了

需要停止iptables服务

1
service iptables stop

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

1
2
3
cp /usr/local/sbin/iptables /sbin/
cp /usr/local/sbin/iptables-restore /sbin/
cp /usr/local/sbin/iptables-save /sbin/


so可能也需要拷贝或做链接
cp libxtables.so.10 /lib
cp libip4tc.so.0 /lib
cp libip6tc.so.0 /lib

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

测试一下

 

1
2
3
iptables -V
iptables v1.4.6
services iptables restart

 

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

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值