Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
bytenoob
V2EX  ›  Linux

请教如何限制某一范围区间的端口速率

  •  
  •   bytenoob ·
    bufrr · Aug 31, 2020 · 2215 views
    This topic created in 2171 days ago, the information mentioned may be changed or developed.
    比如我想要限制所有 40000-50000 的端口速度,每个端口不能超过 2MB/s
    尝试过先用 tc 创建规则,然后
    iptables -A OUTPUT -p tcp -m multiport --sports 40000:50000 -j MARK --set-mark 5
    发现把整个 4-5w 端口的总速率限制了,请教如何能实现分配给每个端口的速率?
    3 replies    2020-09-01 10:11:17 +08:00
    Foxkeh
        1
    Foxkeh  
       Aug 31, 2020
    开机场?
    bytenoob
        2
    bytenoob  
    OP
       Aug 31, 2020
    @Foxkeh 机场的限速都是现成的吧,个人用途
    bytenoob
        3
    bytenoob  
    OP
       Sep 1, 2020   ❤️ 1
    看到有人收藏了,我说下我找到的方案,使用 iptables 的 hashlimit
    iptables -A OUTPUT -p tcp -m hashlimit --hashlimit-above 512kb/s --hashlimit-mode dstport --hashlimit-name out -j DROP --sport 10000:50000
    这个只限制了 OUTPUT,INPUT 同理,可以根据文档酌情添加 hashlimit 的其他参数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5758 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 03:06 · PVG 11:06 · LAX 20:06 · JFK 23:06
    ♥ Do have faith in what you're doing.