V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
piero66
V2EX  ›  Linux

centos iptables

  •  
  •   piero66 · 2015-09-19 13:14:09 +08:00 · 2044 次点击
    这是一个创建于 3179 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    5 条回复    2015-09-19 23:14:07 +08:00
    onemoo
        1
    onemoo  
       2015-09-19 15:32:45 +08:00
    使用 recent 模块
    piero66
        2
    piero66  
    OP
       2015-09-19 20:54:33 +08:00
    @onemoo recent 模块也是限制单 IP 连接数的吧,而不是限制 IP 数
    onemoo
        3
    onemoo  
       2015-09-19 21:43:08 +08:00
    recent 可以设置为限制所有 TCP 连接的 syn 总数。不过单个 ip 可能多次 syn ,所以确实不适合你的需求。
    我看到还有 iplimit 模块,似乎可以: http://www.netfilter.org/documentation/HOWTO/netfilter-extensions-HOWTO-3.html#ss3.5
    piero66
        4
    piero66  
    OP
       2015-09-19 22:15:15 +08:00
    @onemoo 感谢回复,研究了下这个模块, For example, let's limit the number of parallel HTTP connections made by a single IP address to 4 , 也是限制同一个 IP 的连接数的。不是限制 IP 数的。
    onemoo
        5
    onemoo  
       2015-09-19 23:14:07 +08:00
    This match will allow you to restrict the number of parallel TCP connections from a particular host or network.
    你可以试试应用在一个网域中,不过这样也不是你的需求...而且掩码不能设置为 0...
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5799 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 02:22 · PVG 10:22 · LAX 19:22 · JFK 22:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.