技术解析

centos iptables
0
2021-07-09 13:53:43
idczone

centos iptable 有没有办法限制一个端口最多只能有 10 个 ip 访问,第 11 个 ip 会被直接 drop 。

看到 iptable 有 connlimit 模块,但这个是限制连接数的,好像实现不了我上面的功能。因为我对每个 ip 的连接数没有要求。谢谢


使用 recent 模块

recent 模块也是限制单 IP 连接数的吧,而不是限制 IP 数

recent 可以设置为限制所有 TCP 连接的 syn 总数。不过单个 ip 可能多次 syn ,所以确实不适合你的需求。
我看到还有 iplimit 模块,似乎可以: http://www.netfilter.org/documentation/HOWTO/netfilter-extensions-HOWTO-3.html#ss3.5

感谢回复,研究了下这个模块, For example, let's limit the number of parallel HTTP connections made by a single IP address to 4 , 也是限制同一个 IP 的连接数的。不是限制 IP 数的。

This match will allow you to restrict the number of parallel TCP connections from a particular host or network.
你可以试试应用在一个网域中,不过这样也不是你的需求...而且掩码不能设置为 0...

数据地带为您的网站提供全球顶级IDC资源
在线咨询
专属客服