iptables: Protocol wrong type for socket.

2013-06-06 19:35:25 +08:00
 orzfly
于是想给centOS6服务器加点安全措施于是打算限制连接数可是……

# iptables -I FORWARD -p tcp --syn --dport 80 - m connlimit --connlimit-above 20 -j DROP
iptables: Protocol wrong type for socket.

语法明显没错...
但是为啥会有这么奇葩的提示啊=A=
5598 次点击
所在节点    Linux
1 条回复
Sonic1997
2013-06-07 09:10:11 +08:00
麻烦囧叔发帖了...

CentOS's userspace tools are also incompatible with the connlimit module in our latest 3.x series kernels because the version of 'iptables' that is installed is too old:
//CentOS的用户空间工具在我们最新的3.x系列核心中与connlimit模块不兼容因为所安装的iptables版本太旧了:
-----
# iptables -V
iptables v1.4.7
-----

Please issue these commands, and again, remember that building from source means that this package will no longer be managed by your package management system (yum):
//输入以下指令,后面的懒得翻译,注意这会覆盖掉你的东西就行了
yum update
rpm -e --nodeps iptables-1.4.7-9.el6.i686
rpm -e --nodeps iptables-ipv6-1.4.7-9.el6.i686
yum groupinstall 'Development Tools'
wget http://www.netfilter.org/projects/iptables/files/iptables-1.4.19.tar.bz2
tar jxvf 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

When the installation is complete, run "iptables -V" and you should see the following output:
//当你完成安装时,输入“iptables -V” 然后你会看到下面的内容
-----
iptables v1.4.19
-----

Now try to load that iptables rule:
//现在你可以用了

iptables -I FORWARD -p tcp --syn --dport 80 -m connlimit --connlimit-above 20 -j DROP

It should succeed with no error message. You can verify that the rule was loaded with either of these commands:
//下载应该能运行的了,你可以通过以下任意一个指令来验证你的规矩是否已经加载

iptables-save
iptables -L -n -v





搞定,感谢Linode客服

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/71508

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX