由 THQ » 週五 9月 26, 2008 9:26 pm
只有一片網卡好像只能控制區網內的網速,ppp0的就不行了
#!/bin/sh
iptables -F -t mangle
)
tc qdisc del dev ppp0 root 2>/dev/null
tc qdisc add dev ppp0 root handle 20: htb default 20
tc class add dev ppp0 parent 20: classid 20:1 htb rate 25kbps ceil 25kbps
tc class add dev ppp0 parent 20:1 classid 20:10 htb rate 10kbps ceil 10kbps
tc class add dev ppp0 parent 20:1 classid 20:20 htb rate 10kbps ceil 25kbps prio 2
tc class add dev ppp0 parent 20:1 classid 20:40 htb rate 50kbps ceil 1000kbps prio 3
tc class add dev ppp0 parent 20:1 classid 20:100 htb rate 10kbps ceil 25kbps prio 0
tc class add dev ppp0 parent 20:1 classid 20:200 htb rate 10kbps ceil 25kbps prio 1
tc qdisc add dev ppp0 parent 20:20 handle 101: pfifo
tc qdisc add dev ppp0 parent 20:40 handle 102: pfifo tc qdisc add dev ppp0 parent 20:100 handle 201: pfifo
tc qdisc add dev ppp0 parent 20:200 handle 202: pfifo
tc filter add dev ppp0 parent 20: protocol ip prio 100 handle 20 fw classid 20:20
tc filter add dev ppp0 parent 20: protocol ip prio 100 handle 40 fw classid 20:40
tc filter add dev ppp0 parent 20: protocol ip prio 100 handle 100 fw classid 20:100
tc filter add dev ppp0 parent 20: protocol ip prio 100 handle 200 fw classid 20:200
#iptables -t mangle -A OUTPUT -p tcp --sport 80 -j MARK --set-mark 200
iptables -t mangle -A PREROUTING -i ppp0 -s 192.168.0.1 -j MARK --set-mark 100
iptables -t mangle -A PREROUTING -i ppp0 -s 192.168.0.2 -j MARK --set-mark 200
show出tc ppp0的情形
qdisc htb 20: root r2q 10 default 20 direct_packets_stat 1 ver 3.17
Sent 1230143448 bytes 3911613 pkt (dropped 189924, overlimits 384685 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 101: parent 20:20 limit 3p
Sent 1230143093 bytes 3911610 pkt (dropped 189924, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 102: parent 20:40 limit 3p
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 201: parent 20:100 limit 3p
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 202: parent 20:200 limit 3p
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
都沒有依規則分類流量
Linux才是最強的!!