原文2008年1月30日写在MSN SPACE上
 
这是为公司上LINUX做的网关上的QOS设置,请自行研究,详细说明以后补上。
#!/bin/sh
CEIL=1600
tc qdisc add dev eth1 root handle 1: htb default 13
tc class add dev eth1 parent 1:1 classid 1:10 htb rate 800kbit ceil ${CEIL}kbit prio 0
tc class add dev eth1 parent 1:1 classid 1:11 htb rate 300kbit ceil ${CEIL}kbit prio 1
tc class add dev eth1 parent 1:1 classid 1:12 htb rate 200kbit ceil ${CEIL}kbit prio 2
tc class add dev eth1 parent 1:1 classid 1:13 htb rate 300kbit ceil ${CEIL}kbit prio 3
tc qdisc add dev eth1 parent 1:12 handle 120: sfq perturb 10
tc qdisc add dev eth1 parent 1:13 handle 130: sfq perturb 10
tc filter add dev eth1 parent 1:0 protocol ip prio 1 handle 1 fw classid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 2 handle 2 fw classid 1:11
tc filter add dev eth1 parent 1:0 protocol ip prio 3 handle 3 fw classid 1:12
tc filter add dev eth1 parent 1:0 protocol ip prio 4 handle 4 fw classid 1:13
iptables -t mangle -A PREROUTING -s 192.168.1.32/29 -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -s 192.168.1.32/29 -j RETURN
iptables -t mangle -A PREROUTING -s 192.168.1.0/28 -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -s 192.168.1.0/28 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j MARK --set-mark 0x2
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 25 -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 25 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 110 -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 110 -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j MARK --set-mark 0x2
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Cost -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Cost -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Maximize-Throughput -j MARK --set-mark 0x4
iptables -t mangle -A PREROUTING -m tos --tos Maximize-Throughput -j RETURN
iptables -t mangle -A PREROUTING -j MARK --set-mark 0x4
#-----END-----
 
查看:tc -s class show dev eth1