1: UPWAN1=90000
2: DOWNWAN1=90000
3: OTHERUPOne=60
4: OTHERDOWNOne=60
5: OTHERUPTwo=30
6: OTHERDOWNTwo=30
7: OTHERUPThree=10
8: OTHERDOWNThree=10
9: OTHERUPMax=90
10: OTHERDOWNMax=90
11:
12: insmod imq
13: insmod ipt_IMQ
14: ifconfig imq0 up
15: ifconfig imq1 up
16: insmod xt_web.ko
17: insmod xt_length.ko
18: insmod xt_hashlimit.ko
19: wan1=$(nvram get wan_iface)
20: iptables -t mangle -N QOSDOWN
21: iptables -t mangle -N QOSUP
22: iptables -t mangle -F QOSDOWN
23: iptables -t mangle -F QOSUP
24: iptables -t mangle -F FORWARD
25: iptables -t mangle -I FORWARD -j IPTRAFFIC_I
26: iptables -t mangle -I FORWARD -i br0 -j QOSDOWN
27: iptables -t mangle -I FORWARD -o br0 -j QOSUP
28: iptables -t mangle -A FORWARD -i br0 -j IMQ --todev 1
29: iptables -t mangle -A FORWARD -o br0 -j IMQ --todev 0
30:
31:
32: DOWNOTHEROne=$(($DOWNWAN1*$OTHERDOWNOne/100))
33: UPOTHEROne=$(($UPWAN1*$OTHERUPOne/100))
34: DOWNOTHERTwo=$(($DOWNWAN1*$OTHERDOWNTwo/100))
35: UPOTHERTwo=$(($UPWAN1*$OTHERUPTwo/100))
36: DOWNOTHERThree=$(($DOWNWAN1*$OTHERDOWNThree/100))
37: UPOTHERThree=$(($UPWAN1*$OTHERUPThree/100))
38: DOWNOTHERMax=$(($DOWNWAN1*$OTHERDOWNMax/100))
39: UPOTHERMax=$(($UPWAN1*$OTHERUPMax/100))
40:
41: DOWN=$(($DOWNOTHEROne))
42: UP=$(($UPOTHEROne))
43: DOWNWEB=$(($DOWNOTHERTwo))
44: UPWEB=$(($UPOTHERTwo))
45: DOWNP2P=$(($DOWNOTHERThree))
46: UPP2P=$(($UPOTHERThree))
47:
48: DOWNLITTLE=$(($DOWN*20/100))
49: DOWNSYN=$(($DOWN*20/100))
50: DOWNGUA=$(($DOWN*60/100))
51: DOWNWWW=$(($DOWNWEB*60/100))
52: DOWNMEDIA=$(($DOWNWEB*40/100))
53: DOWNDOWN=$(($DOWNP2P*60/100))
54: DOWNDOWNP2P=$(($DOWNP2P*40/100))
55:
56: UPLITTLE=$(($UP*20/100))
57: UPSYN=$(($UP*20/100))
58: UPGUA=$(($UP*60/100))
59: UPWWW=$(($UPWEB*60/100))
60: UPMEDIA=$(($UPWEB*40/100))
61: UPUP=$(($UPP2P*60/100))
62: UPUPP2P=$(($UPP2P*40/100))
63:
64:
65:
66: tc qdisc del dev imq1 root
67: tc qdisc add dev imq1 root handle 1: htb default 50 r2q 2
68: tc class add dev imq1 parent 1: classid 1:11 htb rate ${DOWN}kbps ceil ${DOWN}kbps prio 0
69: tc class add dev imq1 parent 1: classid 1:12 htb rate ${DOWNWEB}kbps ceil ${DOWNOTHERMax}kbps prio 1
70: tc class add dev imq1 parent 1: classid 1:13 htb rate ${DOWNP2P}kbps ceil ${DOWNOTHERMax}kbps prio 1
71: tc class add dev imq1 parent 1:11 classid 1:10 htb rate ${DOWNLITTLE}kbps ceil ${DOWN}kbps prio 0
72: tc class add dev imq1 parent 1:11 classid 1:20 htb rate ${DOWNSYN}kbps ceil ${DOWN}kbps prio 1
73: tc class add dev imq1 parent 1:11 classid 1:40 htb rate ${DOWNGUA}kbps ceil ${DOWN}kbps prio 2
74: tc class add dev imq1 parent 1:12 classid 1:50 htb rate ${DOWNWWW}kbps ceil ${DOWNOTHERMax}kbps prio 0
75: tc class add dev imq1 parent 1:12 classid 1:30 htb rate ${DOWNMEDIA}kbps ceil ${DOWNOTHERMax}kbps prio 1
76: tc class add dev imq1 parent 1:13 classid 1:80 htb rate ${DOWNDOWN}kbps ceil ${DOWNOTHERMax}kbps prio 0
77: tc class add dev imq1 parent 1:13 classid 1:90 htb rate ${DOWNDOWNP2P}kbps ceil ${DOWNOTHERMax}kbps prio 1
78: tc qdisc add dev imq1 parent 1:10 handle 10: sfq perturb 10
79: tc qdisc add dev imq1 parent 1:20 handle 20: sfq perturb 10
80: tc qdisc add dev imq1 parent 1:30 handle 30: sfq perturb 10
81: tc qdisc add dev imq1 parent 1:40 handle 40: sfq perturb 10
82: tc qdisc add dev imq1 parent 1:50 handle 50: sfq perturb 10
83: tc qdisc add dev imq1 parent 1:80 handle 80: sfq perturb 10
84: tc qdisc add dev imq1 parent 1:90 handle 90: sfq perturb 10
85: tc filter add dev imq1 parent 1: protocol ip handle 1 fw flowid 1:10
86: tc filter add dev imq1 parent 1: protocol ip handle 2 fw flowid 1:20
87: tc filter add dev imq1 parent 1: protocol ip handle 3 fw flowid 1:30
88: tc filter add dev imq1 parent 1: protocol ip handle 4 fw flowid 1:40
89: tc filter add dev imq1 parent 1: protocol ip handle 5 fw flowid 1:50
90: tc filter add dev imq1 parent 1: protocol ip handle 8 fw flowid 1:80
91: tc filter add dev imq1 parent 1: protocol ip handle 9 fw flowid 1:90
92: tc qdisc del dev imq0 root
93: tc qdisc add dev imq0 root handle 1: htb default 50
94: tc class add dev imq0 parent 1: classid 1:11 htb rate ${UP}kbps ceil ${UP}kbps prio 0
95: tc class add dev imq0 parent 1: classid 1:12 htb rate ${UPWEB}kbps ceil ${UPOTHERMax}kbps prio 1
96: tc class add dev imq0 parent 1: classid 1:13 htb rate ${UPP2P}kbps ceil ${UPOTHERMax}kbps prio 1
97: tc class add dev imq0 parent 1:11 classid 1:10 htb rate ${UPLITTLE}kbps ceil ${UP}kbps prio 0
98: tc class add dev imq0 parent 1:11 classid 1:20 htb rate ${UPSYN}kbps ceil ${UP}kbps prio 1
99: tc class add dev imq0 parent 1:11 classid 1:40 htb rate ${UPGUA}kbps ceil ${UP}kbps prio 2
100: tc class add dev imq0 parent 1:12 classid 1:50 htb rate ${UPWWW}kbps ceil ${UPOTHERMax}kbps prio 0
101: tc class add dev imq0 parent 1:12 classid 1:30 htb rate ${UPMEDIA}kbps ceil ${UPOTHERMax}kbps prio 1
102: tc class add dev imq0 parent 1:13 classid 1:80 htb rate ${UPUP}kbps ceil ${UPOTHERMax}kbps prio 0
103: tc class add dev imq0 parent 1:13 classid 1:90 htb rate ${UPUPP2P}kbps ceil ${UPOTHERMax}kbps prio 1
104: tc qdisc add dev imq0 parent 1:10 handle 10: sfq perturb 10
105: tc qdisc add dev imq0 parent 1:20 handle 20: sfq perturb 10
106: tc qdisc add dev imq0 parent 1:30 handle 30: sfq perturb 10
107: tc qdisc add dev imq0 parent 1:40 handle 40: sfq perturb 10
108: tc qdisc add dev imq0 parent 1:50 handle 50: sfq perturb 10
109: tc qdisc add dev imq0 parent 1:80 handle 80: sfq perturb 10
110: tc qdisc add dev imq0 parent 1:90 handle 90: sfq perturb 10
111: tc filter add dev imq0 parent 1: protocol ip handle 1 fw flowid 1:10
112: tc filter add dev imq0 parent 1: protocol ip handle 2 fw flowid 1:20
113: tc filter add dev imq0 parent 1: protocol ip handle 3 fw flowid 1:30
114: tc filter add dev imq0 parent 1: protocol ip handle 4 fw flowid 1:40
115: tc filter add dev imq0 parent 1: protocol ip handle 5 fw flowid 1:50
116: tc filter add dev imq0 parent 1: protocol ip handle 8 fw flowid 1:80
117: tc filter add dev imq0 parent 1: protocol ip handle 9 fw flowid 1:90
118:
119: iptables -t mangle -A QOSDOWN -j CONNMARK --restore-mark
120: iptables -t mangle -A QOSDOWN -m mark --mark 3 -j RETURN
121: iptables -t mangle -A QOSDOWN -p ! tcp -m length --length :256 -j MARK --set-mark-return 1
122: iptables -t mangle -A QOSDOWN -p ! tcp -m hashlimit --hashlimit 20/sec --hashlimit-burst 100 --hashlimit-mode dstip --hashlimit-name fastconn_down -j MARK --set-mark-return 4
123: iptables -t mangle -A QOSDOWN -p ! tcp -j MARK --set-mark-return 9
124: iptables -t mangle -A QOSDOWN -p tcp --syn -j MARK --set-mark-return 2
125: iptables -t mangle -A QOSDOWN -p tcp --sport 443 -j MARK --set-mark-return 5
126: iptables -t mangle -A QOSDOWN -p tcp --sport ! 80 -m state --state ESTABLISHED -m length --length :256 -j MARK --set-mark-return 1
127: iptables -t mangle -A QOSDOWN -p tcp --sport ! 80 -m hashlimit --hashlimit 20/sec --hashlimit-burst 100 --hashlimit-mode dstip --hashlimit-name fastconn_down -j MARK --set-mark-return 4
128: iptables -t mangle -A QOSDOWN -p tcp --sport ! 80 -j MARK --set-mark-return 9
129: iptables -t mangle -A QOSDOWN -p tcp --sport 80 -j BCOUNT
130: iptables -t mangle -A QOSDOWN -p tcp --sport 80 -m bcount --range :500000 -j CONNMARK --set-return 0x5/0xff
131: iptables -t mangle -A QOSDOWN -p tcp --sport 80 -m bcount --range 500001: -j CONNMARK --set-return 0x8/0xff
132: iptables -t mangle -A QOSUP -j CONNMARK --restore-mark
133: iptables -t mangle -A QOSUP -m mark --mark 3 -j RETURN
134: iptables -t mangle -A QOSUP -p ! tcp -m length --length :256 -j MARK --set-mark-return 1
135: iptables -t mangle -A QOSUP -p ! tcp -m hashlimit --hashlimit 15/sec --hashlimit-burst 100 --hashlimit-mode srcip --hashlimit-name fastconn_up -j MARK --set-mark-return 4
136: iptables -t mangle -A QOSUP -p ! tcp -j MARK --set-mark-return 9
137: iptables -t mangle -A QOSUP -p tcp -m web --path ".flv .mp4 .f4v .swf" -j CONNMARK --set-return 0x3/0xff
138: iptables -t mangle -A QOSUP -j CONNMARK --restore-mark
139: iptables -t mangle -A QOSUP -m mark --mark 3 -j RETURN
140: iptables -t mangle -A QOSUP -p tcp --syn -j MARK --set-mark-return 2
141: iptables -t mangle -A QOSUP -p tcp --dport 443 -j MARK --set-mark-return 5
142: iptables -t mangle -A QOSUP -p tcp --dport ! 80 -m length --length :256 -j MARK --set-mark-return 1
143: iptables -t mangle -A QOSUP -p tcp --dport ! 80 -m hashlimit --hashlimit 15/sec --hashlimit-burst 100 --hashlimit-mode srcip --hashlimit-name fastconn_up -j MARK --set-mark-return 4
144: iptables -t mangle -A QOSUP -p tcp --dport ! 80 -j MARK --set-mark-return 9
145: iptables -t mangle -A QOSUP -p tcp --dport 80 -j BCOUNT
146: iptables -t mangle -A QOSUP -p tcp --dport 80 -m bcount --range :40000 -j MARK --set-mark-return 5
147: iptables -t mangle -A QOSUP -p tcp --dport 80 -m bcount --range 40001: -j MARK --set-mark-return 8
阅读(418) | 评论(0) | 转发(0) |