技術(shù)員聯(lián)盟提供win764位系統(tǒng)下載,win10,win7,xp,裝機純凈版,64位旗艦版,綠色軟件,免費軟件下載基地!

當前位置:主頁 > 教程 > 服務(wù)器類 >

linux中 iptables遇到iptables: Protocol wrong type for socket

來源:技術(shù)員聯(lián)盟┆發(fā)布時間:2018-05-01 12:27┆點擊:

下面琰各位介紹一篇關(guān)于Linode vps iptables遇到iptables: Protocol wrong type for socket.錯誤的解決方法,希望文章對各位有幫助

 

 


想在linode vps centos 6.4上iptables加入限制ip連接數(shù)不能超過100的規(guī)則:
iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 100 -j REJECT

出現(xiàn)錯誤:

iptables: Protocol wrong type for socket.

問過Linode客服,說是內(nèi)核與connlimit模塊不兼容,iptables版本太舊了,需要升級。
查看iptables版本:

[root@linode ~]# iptables -V
iptables v1.4.7

查看iptables安裝包:

[root@linode ~]# rpm -qa | grep iptables
iptables-1.4.7-9.el6.x86_64
iptables-ipv6-1.4.7-9.el6.x86_64

按以下方法解決問題,但注意iptables再也不能使用yum來管理:

yum update
rpm -e --nodeps iptables-1.4.7-9.el6.x86_64
rpm -e --nodeps iptables-ipv6-1.4.7-9.el6.x86_64
yum groupinstall 'Development Tools'
wget
tar jxf iptables-1.4.19.tar.bz2
cd iptables-1.4.19
LDFLAGS="-L$PWD/libiptc/.libs" ./configure --prefix=http://www.3lian.com/usr --exec-prefix= --bindir=http://www.3lian.com/usr/bin --with-xtlibdir=http://www.3lian.com/lib/xtables --with-pkgconfigdir=http://www.3lian.com/usr/lib/pkgconfig --enable-libipq --enable-devel
make
make install

查看iptables版本:

[root@linode ~]# iptables -V
iptables v1.4.19

[root@linode iptables-1.4.19]# iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 100 -j REJECT
[root@linode iptables-1.4.19]# iptables -L
Chain INPUT (policy ACCEPT)
REJECT     tcp  --  anywhere             anywhere             tcp dpt:http flags:FIN,SYN,RST,ACK/SYN #conn src/32 > 100 reject-with icmp-port-unreachable

可以看到上面已經(jīng)有一條規(guī)則了。