歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux管理 >> Linux維護 >> Linux系統iptables報錯iptables:Protocol wrong怎麼辦?

Linux系統iptables報錯iptables:Protocol wrong怎麼辦?

日期:2017/3/2 10:27:03   编辑:Linux維護

Linux系統中,iptables有利於Linux防火牆的配置,能夠控制ip信息包過濾,可有用戶遇到了iptables: Protocol wrong type for socket.錯誤,不知是由什麼原因引起的,下面小編就給大家介紹下Linux系統iptables出現該報錯的解決方法。

想在linode vps centos 6.4上iptables加入限制ip連接數不能超過100的規則:

iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 100 -j REJECT

出現錯誤:

iptables: Protocol wrong type for socket.

問過Linode客服,說是內核與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 http://www.netfilter.org/projects/iptables/files/iptables-1.4.19.tar.bz2

tar jxf iptables-1.4.19.tar.bz2

cd iptables-1.4.19

LDFLAGS=“-L$PWD/libiptc/.libs” 。/configure --prefix=/usr --exec-prefix= --bindir=/usr/bin --with-xtlibdir=/lib/xtables --with-pkgconfigdir=/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

可以看到上面已經有一條規則了。

上面就是Linux系統下iptables報錯iptables: Protocol wrong type for socket的解決方法介紹了,主要是iptables版本太低所導致,因進行升級。

Copyright © Linux教程網 All Rights Reserved