我正在寻找Linux中的命令来限制所有用户的上传/下载速率。
我有三个Linux命令限制了操作系统上的网络速率。
tc qdisc add dev eth0 root handle 1: htb default 10
tc class add dev eth0 parent 1: classid 1:1 htb rate 1000kbps ceil 1500kbps
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 10kbps ceil 20kbps
当我尝试用一个客户端从这个服务器下载时,下载速率是20 20Kbps,但是当尝试用两个客户端下载时,每个客户端的下载速率降低到9-10 20Kbps。
对于多个连接/用户,是否有任何方法将速率保持在20 20Kbps或任何固定值?
发布于 2019-09-22 10:29:29
当您使用HTB时,您应该为每个用户/连接创建一个单独的类,以限制带宽。
类树的典型配置:
host1
类(HTB,分类1:11,父级1:3,比率20 20Kbit)host2
类(HTB,分类1:12,父级1:3,比率20 20Kbit)hostN
类(HTB,分类1:13,父级1:3,比率20 20Kbit)tc命令应该如下所示:
# remove current configuration if exists
tc q del dev <iface> root || true
tc q del dev <iface> ingress || true
# create the root queue discipline
tc q add dev <iface> root handle 1:0 htb default 3
# attach the root class to the root qdisc
tc c add dev <iface> parent 1:0 classid 1:1 htb rate 100Mbit
# default class
tc c add dev <iface> parent 1:1 classid 1:2 htb rate 50Mbit ceil 100Mbit
# class to limit the hosts
tc c add dev <iface> parent 1:1 classid 1:3 htb rate 50Mbit ceil 100Mbit
# attach classes to limit every host (one class = one host)
tc c add dev <iface> parent 1:3 classid 1:11 htb rate 20Kbit
tc c add dev <iface> parent 1:3 classid 1:12 htb rate 20Kbit
tc c add dev <iface> parent 1:3 classid 1:13 htb rate 20Kbit
# classification of the downstream traffic to hosts
tc f add dev <iface> parent 1:0 protocol ip prio 10 handle 800::1 u32 match ip dst 192.0.2.2 flowid 1:11
tc f add dev <iface> parent 1:0 protocol ip prio 10 handle 800::2 u32 match ip dst 192.0.2.3 flowid 1:12
tc f add dev <iface> parent 1:0 protocol ip prio 10 handle 800::3 u32 match ip dst 192.0.2.4 flowid 1:13
发布于 2019-09-24 14:20:37
我还不能要求Anton Danilov发表评论,“如果我想将50%的带宽分配给争用,但我想将剩下的50%平均分配给用户,以确保最低限度的保证,我们该怎么做呢?”
https://serverfault.com/questions/985157
复制相似问题