Simple QoS HTB Shaper Script for DD WRT firmwares for shaping down and up traffic per ip
posted on: 22:42, August 15th , 2012tested on Firmware: DD-WRT v24-sp2 (07/20/12) std
#!/bin/sh
### clear any previous traffic controls
tc qdisc del dev br0 root 2> /dev/null > /dev/null
tc qdisc del dev vlan1 root 2> /dev/null > /dev/null
iptables -t mangle -F
iptables -t mangle -X
#load modules
#insmod imq
#insmod ipt_IMQ
#DOWNLOAD
#br0 is the LAN interface which is something like 192.168.0.1
TCA="tc class add dev br0"
TFA="tc filter add dev br0"
TQA="tc qdisc add dev br0"
SFQ="sfq perturb 10"
tc qdisc del dev br0 root
tc qdisc add dev br0 root handle 1: htb
tc class add dev br0 parent 1: classid 1:1 htb rate 92160kbit # set 90% of total available download speed in kilobits
$TCA parent 1:1 classid 1:10 htb rate 200kbit ceil 400kbit prio 2 # set guaranteed speed and if available total download speed in kilobits for ip .0.16
$TCA parent 1:1 classid 1:11 htb rate 1024kbit ceil 5120kbit prio 2 # set guaranteed speed and if available total download speed in kilobits for ip .0.51
$TQA parent 1:10 handle 10: $SFQ
$TQA parent 1:11 handle 11: $SFQ
$TFA parent 1:0 prio 2 protocol ip handle 10 fw flowid 1:10
$TFA parent 1:0 prio 2 protocol ip handle 11 fw flowid 1:11
iptables -t mangle -A POSTROUTING -d 192.168.0.16 -j MARK --set-mark 10 # start marking download packets for ip .0.16
iptables -t mangle -A POSTROUTING -d 192.168.0.51 -j MARK --set-mark 11 # start marking download packets for ip .0.51
#UPLOAD
#vlan1 is the WAN interface which is something like 194.145.63.12
TCAU="tc class add dev vlan1"
TFAU="tc filter add dev vlan1"
TQAU="tc qdisc add dev vlan1"
ip link set vlan1 up
tc qdisc del dev vlan1 root
tc qdisc add dev vlan1 root handle 1: htb
tc class add dev vlan1 parent 1: classid 1:1 htb rate 10240kbit # set 90% of total available upload speed in kilobits
$TCAU parent 1:1 classid 1:10 htb rate 200kbit ceil 400kbit prio 2 # set guaranteed speed and if available total upload speed in kilobits for ip .0.16
$TCAU parent 1:1 classid 1:11 htb rate 1024kbit ceil 2048kbit prio 2 # set guaranteed speed and if available total upload speed in kilobits for ip .0.51
$TQAU parent 1:10 handle 10: $SFQ
$TQAU parent 1:11 handle 11: $SFQ
$TFAU parent 1:0 prio 2 protocol ip handle 10 fw flowid 1:10
$TFAU parent 1:0 prio 2 protocol ip handle 11 fw flowid 1:11
iptables -t mangle -A PREROUTING -s 192.168.0.16 -j MARK --set-mark 10 # start marking upload packets for ip .0.16
iptables -t mangle -A PREROUTING -s 192.168.0.51 -j MARK --set-mark 11 # start marking upload packets for ip .0.16
iptables -t mangle -A PREROUTING -j vlan --todev 1
Comments:
All materials on this site are licensed under the following license: "Steal every piece of information you can get your hands on and run as fast as you can "