Dan*_*tor 5 linux traffic-shaping tc
如何限制 CentOS 服务器上的上传和下载带宽?这是一个带有单一界面的盒子,eth0
. 理想情况下,我想要一个命令行解决方案(我一直在尝试使用tc
),我可以在脚本中轻松打开和关闭它。
到目前为止,我一直在尝试做类似的事情,tc filter add dev eth0 protocol ip prio 50 u32 police rate 100kbit burst 10240 drop
但显然我缺少很多知识和信息。有人可以帮助快速单线吗?
非常感谢,丹
我在此处为您添加脚本代码时遇到问题,可通过此要点获得 - https://gist.github.com/akrasic/7242498#file-limit-tc-sh
该脚本使用 TC 和分层令牌桶 (HTB) 来定义规则,最后定义将作为包罗万象规则的过滤器。
如果interface
var 不同于eth0
? 和interface_speed
.
将脚本保存在您的服务器上,并通过以下方式启动它:
?ash limit-tc.sh start
停止:
bash limit-tc.sh stop
查看状态: bash limit.tc status
状态输出看起来像这样:
qdisc htb 1: root refcnt 2 r2q 10 default 30 direct_packets_stat 1
Sent 535666 bytes 6461 pkt (dropped 172, overlimits 7641 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc sfq 10: parent 1:10 limit 127p quantum 1514b perturb 10sec
Sent 535624 bytes 6424 pkt (dropped 172, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc sfq 20: parent 1:20 limit 127p quantum 1514b perturb 10sec
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
Run Code Online (Sandbox Code Playgroud)