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
makeinstall

上面就編譯完了

需要停止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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章