« 5. ip usage 4 - iproute2 - the most powerful tool - [FWD] ip命令手册(四) |
Main
| cdimage v.s. mkisofs (+gbk+md5) - 挑战多启动ISO »
April 4, 2004
6. tc sample - iproute2 - the most powerful tool
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
https://windtear.net/archives/2004/04/04/000477.html
% tail rc.local . # qos cbq trafic control sh _iptables.sh sh _qos.sh
-----> sample 1 % cat _iptables.sh #!/bin/sh
IPTABLES=/sbin/iptables
$IPTABLES -F OUTPUT -t mangle $IPTABLES -A OUTPUT -t mangle -p tcp --sport 1020 -j MARK --set-mark 1 $IPTABLES -A OUTPUT -t mangle -p tcp --sport 10000:11000 -j MARK --set-mark 1 $IPTABLES -A OUTPUT -t mangle --match owner --uid-owner 500 -j MARK --set-mark 2
% cat _qos.sh #!/bin/sh
TC=/sbin/tc
#$TC qdisc add dev eth0 root handle 1: cbq bandwidth 100Mbit allot 1514 cell 8 avpkt 1000 mpu 64 #$TC class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 5Mbit rate 5Mbit allot 1514 weight 50Kbit prio 8 maxburst 20 avpkt 1000 bounded #$TC filter add dev eth0 protocol ip prio 3 handle 1 fw classid 1:1
$TC qdisc add dev eth0 root handle 100: cbq bandwidth 10Mbit avpkt 1000
$TC class add dev eth0 parent 100:0 classid 100:1 cbq bandwidth 10Mbit rate 5Mbit allot 1514 weight 5Mbit prio 8 maxburst 20 avpkt 1000 $TC class add dev eth0 parent 100:1 classid 100:11 cbq bandwidth 10Mbit rate 4Mbit allot 1514 weight 4Mbit prio 5 maxburst 20 avpkt 1000 bounded $TC class add dev eth0 parent 100:1 classid 100:21 cbq bandwidth 10Mbit rate 1Mbit allot 1514 weight 1Mbit prio 5 maxburst 20 avpkt 1000 bounded $TC qdisc add dev eth0 parent 100:11 sfq quantum 1514b perturb 15 $TC qdisc add dev eth0 parent 100:21 sfq quantum 1514b perturb 15
$TC filter add dev eth0 protocol ip prio 25 handle 1 fw classid 100:11 $TC filter add dev eth0 protocol ip prio 25 handle 2 fw classid 100:21
#$TC filter add dev eth0 parent 100:0 protocol ip prio 100 u32 match ip src 166.111.Local.Host/32 port 20 flowid 100:10
-----> sample 2 % cat _iptables.sh #!/bin/sh
IPTABLES=/sbin/iptables
$IPTABLES -F OUTPUT -t mangle $IPTABLES -A OUTPUT -t mangle -p tcp --sport TH_PO -j MARK --set-mark 1 $IPTABLES -A OUTPUT -t mangle -p tcp --sport OU_PO -j MARK --set-mark 2 $IPTABLES -A OUTPUT -t mangle -p tcp --sport TH_PAS:TH_PAE -j MARK --set-mark 1 $IPTABLES -A OUTPUT -t mangle -p tcp --sport OU_PAS:OU_PAE -j MARK --set-mark 2
% cat _qos.sh #!/bin/sh
TC=/sbin/tc
#$TC qdisc add dev eth0 root handle 1: cbq bandwidth 100Mbit allot 1514 cell 8 avpkt 1000 mpu 64 $TC qdisc add dev eth0 root handle 1: cbq bandwidth 100Mbit avpkt 1000
$TC class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate 100Mbit allot 1514 weight 10Mbit prio 8 maxburst 20 avpkt 1000 $TC class add dev eth0 parent 1:1 classid 1:11 cbq bandwidth 100Mbit rate 70Mbit allot 1514 weight 7Mbit prio 5 maxburst 20 avpkt 1000 bounded $TC class add dev eth0 parent 1:1 classid 1:21 cbq bandwidth 100Mbit rate 10Mbit allot 1514 weight 1Mbit prio 5 maxburst 20 avpkt 1000 bounded $TC qdisc add dev eth0 parent 1:11 sfq quantum 1514b perturb 15 $TC qdisc add dev eth0 parent 1:21 sfq quantum 1514b perturb 15
$TC filter add dev eth0 protocol ip prio 25 handle 1 fw classid 1:11 $TC filter add dev eth0 protocol ip prio 25 handle 2 fw classid 1:21
|
|
Posted by windtear at April 4, 2004 1:53 AM