Allow IPv6 address entry in tools>ping - Loosens valid character check
[tomato/davidwu.git] / release / src / router / nocat / libexec / iptables / throttle.fw
bloba25a7055fac39c21f7bda1aba43604c8b5e24292
1 #!/bin/sh
2 ##
3 #
4 # throttle.fw: Set the bandwidth policy, based on FWMARK
6 # Set your limits in the defines at the top. Someday this will be
7 # integrated into the nocat.conf...
9 ##
11 # Note: your PATH is inherited from the gateway process
14 TOTAL_DOWN=3mbit
15 TOTAL_UP=384kbit
17 OWNER_DOWN=3mbit # fw mark 1
18 OWNER_UP=384kbit
19 OWNER_OPTIONS=""
21 COOP_DOWN=1mbit # fw mark 2
22 COOP_UP=256kbit
23 COOP_OPTIONS=""
25 PUBLIC_DOWN=128kbit # fw mark 3
26 PUBLIC_UP=128kbit
27 PUBLIC_OPTIONS="bounded"
29 OPTIONS="allot 1514 maxburst 20 avpkt 1000 prio 1"
30 METHOD="sfq quantum 1514b perturb 15"
33 # Now, the rules
37 # First, flush any existing root queues
39 tc qdisc del dev $InternalDevice root handle 10:
40 tc qdisc del dev $ExternalDevice root handle 20:
43 # Specify the queue discipline for both interfaces
45 tc qdisc add dev $InternalDevice root handle 10: cbq bandwidth 10Mbit avpkt 1000
46 tc qdisc add dev $ExternalDevice root handle 20: cbq bandwidth 10Mbit avpkt 1000
49 # Specify the root class (filling all bandwidth.)
50 # All other classes descend from these.
52 tc class add dev $InternalDevice \
53 parent 10:0 classid 10:1 cbq bandwidth 10Mbit rate $TOTAL_DOWN $OPTIONS
55 tc class add dev $ExternalDevice \
56 parent 20:0 classid 20:1 cbq bandwidth 10Mbit rate $TOTAL_UP $OPTIONS
60 # Define the user classes
64 # Owner class
66 tc class add dev $InternalDevice \
67 parent 10:1 classid 10:100 cbq bandwidth 10Mbit rate $OWNER_DOWN $OPTIONS $OWNER_OPTIONS
69 tc class add dev $ExternalDevice \
70 parent 20:1 classid 20:100 cbq bandwidth 10Mbit rate $OWNER_UP $OPTIONS $OWNER_OPTIONS
73 # Coop class
76 tc class add dev $InternalDevice \
77 parent 10:1 classid 10:200 cbq bandwidth 10Mbit rate $COOP_DOWN $OPTIONS $COOP_OPTIONS
79 tc class add dev $ExternalDevice \
80 parent 20:1 classid 20:200 cbq bandwidth 10Mbit rate $COOP_UP $OPTIONS $COOP_OPTIONS
83 # Public class
86 tc class add dev $InternalDevice \
87 parent 10:1 classid 10:300 cbq bandwidth 10Mbit rate $PUBLIC_DOWN $OPTIONS $PUBLIC_OPTIONS
89 tc class add dev $ExternalDevice \
90 parent 20:1 classid 20:300 cbq bandwidth 10Mbit rate $PUBLIC_UP $OPTIONS $PUBLIC_OPTIONS
93 # Add the queue management rules
95 tc qdisc add dev $InternalDevice parent 10:100 $METHOD
96 tc qdisc add dev $InternalDevice parent 10:200 $METHOD
97 tc qdisc add dev $InternalDevice parent 10:300 $METHOD
99 tc qdisc add dev $ExternalDevice parent 20:100 $METHOD
100 tc qdisc add dev $ExternalDevice parent 20:200 $METHOD
101 tc qdisc add dev $ExternalDevice parent 20:300 $METHOD
104 # Finally, filter each fwmark to the above defined classes
107 tc filter add dev $InternalDevice protocol ip parent 10: prio 1 handle 1 fw classid 10:100
108 tc filter add dev $InternalDevice protocol ip parent 10: prio 1 handle 2 fw classid 10:200
109 tc filter add dev $InternalDevice protocol ip parent 10: prio 1 handle 3 fw classid 10:300
111 tc filter add dev $ExternalDevice protocol ip parent 20: prio 1 handle 1 fw classid 20:100
112 tc filter add dev $ExternalDevice protocol ip parent 20: prio 1 handle 2 fw classid 20:200
113 tc filter add dev $ExternalDevice protocol ip parent 20: prio 1 handle 3 fw classid 20:300
117 ## Now, the iptables rules
120 iptables -A OUTPUT -t mangle -p tcp --dport 22 -j TOS --set-tos Minimize-Delay
121 iptables -A OUTPUT -t mangle -p tcp --dport 80 -j TOS --set-tos Maximize-Throughput
122 iptables -A OUTPUT -t mangle -p tcp --dport 443 -j TOS --set-tos Maximize-Throughput
125 # Ende