tc+htb 请问这样的配置为什么不能工作?

发布于 2022-09-11 03:00:52 字数 2845 浏览 17 评论 2

# tc -s -d class show parent 3:0 dev ppp0_2
class htb 3:8 parent 3:1 leaf 140: prio 7 quantum 1000 rate 36000bit ceil 458000bit burst 1603b/8 mpu 0b overhead 0b cburst 1656b/8 mpu 0b overhead 0b level 0
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: 348089 ctokens: 28264

class htb 3:1 root rate 458000bit ceil 458000bit burst 1656b/8 mpu 0b overhead 0b cburst 1656b/8 mpu 0b overhead 0b level 7
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: 28264 ctokens: 28264

class htb 3:2 parent 3:1 leaf 80: prio 1 quantum 3662 rate 293000bit ceil 458000bit burst 1635b/8 mpu 0b overhead 0b cburst 1656b/8 mpu 0b overhead 0b level 0
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: 43621 ctokens: 28264

class htb 3:4 parent 3:1 leaf 100: prio 3 quantum 1537 rate 123000bit ceil 458000bit burst 1614b/8 mpu 0b overhead 0b cburst 1656b/8 mpu 0b overhead 0b level 0
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: 102578 ctokens: 28264

> iptables -t mangle -nvL
Chain PREROUTING (policy ACCEPT 1070 packets, 193K bytes)
pkts bytes target     prot opt in     out     source               destination         
    0     0 MARK       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           source IP range 192.168.1.2-192.168.1.2 tcp spt:5000 MARK set 0x8
    0     0 MARK       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           source IP range 192.168.1.2-192.168.1.2 tcp spt:6000 MARK set 0xa
    0     0 MARK       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           source IP range 192.168.1.2-192.168.1.2 tcp spt:7000 MARK set 0xe

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

狼性发作 2022-09-11 06:52:17

tc 规则

tc qdisc add dev ppp0_2 parent 2:8 handle 3:0 htb default 1

tc class add dev ppp0_2 parent 3:0 classid 3:1 htb rate 458kbit ceil 458kbit

tc class add dev ppp0_2 parent 3:1 classid 3:2 htb prio 1 rate 407kbit ceil 458kbit
tc qdisc add dev ppp0_2 parent 3:2 handle 80: sfq perturb 10
tc filter add dev ppp0_2 protocol ip parent 3:0 prio 1 handle 8 fw classid 3:2

tc class replace dev ppp0_2 parent 3:1 classid 3:2 htb prio 1 rate 343kbit ceil 458kbit

tc class add dev ppp0_2 parent 3:1 classid 3:4 htb prio 3 rate 101kbit ceil 458kbit
tc qdisc add dev ppp0_2 parent 3:4 handle 100: sfq perturb 10
tc filter add dev ppp0_2 protocol ip parent 3:0 prio 1 handle 10 fw classid 3:4

tc class replace dev ppp0_2 parent 3:1 classid 3:2 htb prio 1 rate 293kbit ceil 458kbit

tc class replace dev ppp0_2 parent 3:1 classid 3:4 htb prio 3 rate 123kbit ceil 458kbit

tc class add dev ppp0_2 parent 3:1 classid 3:8 htb prio 7 rate 36kbit ceil 458kbit
HTB: quantum of class 30008 is small. Consider r2q change.
tc qdisc add dev ppp0_2 parent 3:8 handle 140: sfq perturb 10
tc filter add dev ppp0_2 protocol ip parent 3:0 prio 1 handle 14 fw classid 3:8

七色彩虹 2022-09-11 04:31:17

测试结果

# tc -s -d class show parent 3:0 dev ppp0_2
class htb 3:8 parent 3:1 leaf 140: prio 7 quantum 1000 rate 36000bit ceil 458000bit burst 1603b/8 mpu 0b overhead 0b cburst 1656b/8 mpu 0b overhead 0b level 0
Sent 10491344 bytes 10345 pkt (dropped 0, overlimits 0 requeues 0)
rate 46776bit 6pps backlog 0b 0p requeues 0
lended: 1658 borrowed: 8687 giants: 0
tokens: 38949 ctokens: 27153

class htb 3:1 root rate 458000bit ceil 458000bit burst 1656b/8 mpu 0b overhead 0b cburst 1656b/8 mpu 0b overhead 0b level 7
Sent 14827573 bytes 14819 pkt (dropped 15, overlimits 0 requeues 0)
rate 70192bit 9pps backlog 0b 0p requeues 0
lended: 9487 borrowed: 0 giants: 0
tokens: 27155 ctokens: 27155

class htb 3:2 parent 3:1 leaf 80: prio 1 quantum 3662 rate 293000bit ceil 458000bit burst 1635b/8 mpu 0b overhead 0b cburst 1656b/8 mpu 0b overhead 0b level 0
Sent 2577050 bytes 2561 pkt (dropped 0, overlimits 0 requeues 0)
rate 14056bit 2pps backlog 0b 0p requeues 0
lended: 2451 borrowed: 110 giants: 0
tokens: 41742 ctokens: 27155

class htb 3:4 parent 3:1 leaf 100: prio 3 quantum 1537 rate 123000bit ceil 458000bit burst 1614b/8 mpu 0b overhead 0b cburst 1656b/8 mpu 0b overhead 0b level 0
Sent 1722006 bytes 1708 pkt (dropped 0, overlimits 0 requeues 0)
rate 8608bit 1pps backlog 0b 0p requeues 0
lended: 1223 borrowed: 485 giants: 0
tokens: 97811 ctokens: 27215

> iptables -t mangle -nvL
Chain PREROUTING (policy ACCEPT 31660 packets, 16M bytes)
pkts bytes target     prot opt in     out     source               destination         
2561 2577K MARK       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           source IP range 192.168.1.2-192.168.1.2 tcp spt:5000 MARK set 0x8
1708 1722K MARK       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           source IP range 192.168.1.2-192.168.1.2 tcp spt:6000 MARK set 0xa
10345   10M MARK       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           source IP range 192.168.1.2-192.168.1.2 tcp spt:7000 MARK set 0xe

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文