|
环境:三网卡,eth0连接ADSL,eth1连接局域网,eth2暂未启用,要限制192.168.0.155的上传带宽
我是这样做的:
iptables -t mangle -A PREROUTING -i eth1 -s 192.168.0.155/32 -j MARK --set-mark 4
tc qdisc add dev eth0 root handle 1:0 htb default 10
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 4Mbit burst 15k
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 4Mbit burst 15k
tc class add dev eth0 parent 1:1 classid 1:20 htb rate 4kbit ceil 4kbit burst 15k prio 4
tc qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 10
tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 4 fw classid 1:20
问题:
iptables打标之后tc不起作用,敢问何解?
这是mangle表
[root@x100plus ~]# iptables -v -t mangle -nL
Chain PREROUTING (policy ACCEPT 589K packets, 136M bytes)
pkts bytes target prot opt in out source destination
2325 254K MARK all -- eth1 * 192.168.0.155 0.0.0.0/0 MARK set 0x4
Chain INPUT (policy ACCEPT 476K packets, 91M bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 113K packets, 45M bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 463K packets, 94M bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 576K packets, 138M bytes)
pkts bytes target prot opt in out source destination
这是tc qdisc表
[root@x100plus ~]# tc -s -d qdisc
qdisc htb 1: dev eth0 r2q 10 default 10 direct_packets_stat 0 ver 3.17
Sent 935648 bytes 4596 pkts (dropped 0, overlimits 0 requeues 0)
qdisc sfq 10: dev eth0 parent 1:10 limit 128p quantum 1514b flows 128/1024 perturb 10sec
Sent 935648 bytes 4596 pkts (dropped 0, overlimits 0 requeues 0)
qdisc sfq 20: dev eth0 parent 1:20 limit 128p quantum 1514b flows 128/1024 perturb 10sec
Sent 0 bytes 0 pkts (dropped 0, overlimits 0 requeues 0)
qdisc pfifo_fast 0: dev eth1 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
Sent 168854951 bytes 676186 pkts (dropped 0, overlimits 0 requeues 0)
qdisc pfifo_fast 0: dev eth2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
Sent 0 bytes 0 pkts (dropped 0, overlimits 0 requeues 0)
qdisc pfifo_fast 0: dev eth3 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
Sent 0 bytes 0 pkts (dropped 0, overlimits 0 requeues 0)
qdisc pfifo_fast 0: dev ppp0 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
Sent 43985124 bytes 143910 pkts (dropped 0, overlimits 0 requeues 0)
eth0网卡的class状态
[root@x100plus ~]# tc -s -d class ls dev eth0
class htb 1:1 root rate 4Mbit ceil 4Mbit burst 15Kb/8 mpu 0b overhead 0b cburst 2099b/8 mpu 0b overhead 0b level 7
Sent 973430 bytes 4754 pkts (dropped 0, overlimits 0 requeues 0)
rate 1361bit 5pps
lended: 0 borrowed: 0 giants: 0
tokens: 31261 ctokens: 4104
class htb 1:10 parent 1:1 leaf 10: prio 0 quantum 50000 rate 4Mbit ceil 4Mbit burst 15Kb/8 mpu 0b overhead 0b cburst 2099b/8 mpu 0b overhead 0b level 0
Sent 973430 bytes 4754 pkts (dropped 0, overlimits 0 requeues 0)
rate 1361bit 5pps
lended: 4754 borrowed: 0 giants: 0
tokens: 31261 ctokens: 4104
class htb 1:20 parent 1:1 leaf 20: prio 4 quantum 1000 rate 4Kbit ceil 4Kbit burst 15Kb/8 mpu 0b overhead 0b cburst 1599b/8 mpu 0b overhead 0b level 0
Sent 0 bytes 0 pkts (dropped 0, overlimits 0 requeues 0)
lended: 0 borrowed: 0 giants: 0
tokens: 31457280 ctokens: 3276800 |
|