QoS with OpenWRT

I use the following script for my Linksys WRT54GS Wireless router running OpenWRT White Russian -RC4 to setup a QoS firewall that uses Hierarchical Token Bucket (HTB) and Stochastic Fair Queueing (SFQ) to classify the traffic in three cathegories:

  1. Interactive, high priority traffic:
    This class is used for DNS traffic and SSH traffic.
  2. Interactive, normal priority traffic:
    This class is used for HTTP and HTTP/S traffic.
  3. Low priority traffic:
    This class is used for traffic which doesn’t fit any of the previous classes.

Each class is also subclassed with Stochastic Fair Queueing (SFQ) to distribute traffic utilization among the same class evenly.

To make the script run every time the router is powered up, save the script as /etc/init.d/S41qos and turn the executable bit on it.

#!/bin/ash # Executables GREP=/bin/grep INSMOD=/sbin/insmod TC=/usr/sbin/tc DEV=vlan1 # Load kernel modules $GREP -q ^sch_htb /proc/modules || $INSMOD /lib/modules/`uname -r`/sch_htb.o $GREP -q ^sch_sfq /proc/modules || $INSMOD /lib/modules/`uname -r`/sch_sfq.o $GREP -q ^cls_u32 /proc/modules || $INSMOD /lib/modules/`uname -r`/cls_u32.o # Hierarchical Token Bucket (HTB) $TC qdisc add dev $DEV root handle 1: htb default 30 $TC class add dev $DEV parent 1: classid 1:1 htb rate 1mbit burst 20k cburst 20k # HTB Classes $TC class add dev $DEV parent 1:1 classid 1:10 htb rate 768kbit ceil 1mbit burst 15k cburst 15k $TC class add dev $DEV parent 1:1 classid 1:20 htb rate 256kbit ceil 1mbit burst 20k cburst 20k $TC class add dev $DEV parent 1:1 classid 1:30 htb rate 128kbit ceil 512kbit burst 5k cburst 5k $TC qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10 $TC qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10 $TC qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10 # Filters $TC filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dport 53 0xffff flowid 1:10 $TC filter add dev $DEV protocol ip parent 1:0 prio 2 u32 match ip dport 22 0xffff flowid 1:10 $TC filter add dev $DEV protocol ip parent 1:0 prio 10 u32 match ip dport 80 0xffff flowid 1:20 $TC filter add dev $DEV protocol ip parent 1:0 prio 10 u32 match ip dport 443 0xffff flowid 1:20

8 thoughts on “QoS with OpenWRT

  1. Dude thanks for this “help”, I always forget the modules 🙂
    This is very helpfull for newcommers to OpenWRT

  2. I’m very happy to read this. This is the type of manual that needs to be given and not the accidental misinformation that’s at the other blogs. Appreciate your sharing this best doc.

  3. One thing is one of the most typical incentives for utilizing your credit cards is a cash-back or perhaps rebate provision. Generally, you’ll receive 1-5% back for various purchases. Depending on the credit cards, you may get 1% returning on most expenses, and 5% back on expenses made at convenience stores, gas stations, grocery stores and also ‘member merchants’.

  4. Wow! This website appears exactly like my own old one! It’s on a entirely different subject matter however has almost the exact same structure and design. Superb pick of colours!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s