QOS on ubuntu server

qostc

I want to run the following script on ubuntu server. eth1 is NAT interface, and eth2 is the WAN interface which has a static public ip:

TCA="tc class add dev eth2"
TFA="tc filter add dev eth2"
TQA="tc qdisc add dev eth2"
SFQ="sfq perturb 10"
tc qdisc del dev eth2 root
tc qdisc add dev eth2 root handle 1: htb
tc class add dev eth2 parent 1: classid 1:1 htb rate 4560kbit
$TCA parent 1:1 classid 1:10 htb rate 2280kbit ceil 4560kbit prio 0
$TCA parent 1:1 classid 1:11 htb rate 912kbit ceil 4560kbit prio 1
$TCA parent 1:1 classid 1:12 htb rate 912kbit ceil 4560kbit prio 2
$TCA parent 1:1 classid 1:13 htb rate 10kbit ceil 10kbit prio 4
$TQA parent 1:10 handle 10: $SFQ
$TQA parent 1:11 handle 11: $SFQ
$TQA parent 1:12 handle 12: $SFQ
$TQA parent 1:13 handle 13: $SFQ
$TFA parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10
$TFA parent 1:0 prio 1 protocol ip handle 11 fw flowid 1:11
$TFA parent 1:0 prio 2 protocol ip handle 12 fw flowid 1:12
$TFA parent 1:0 prio 4 protocol ip handle 13 fw flowid 1:13
iptables -t mangle -A POSTROUTING -p tcp --sport 80 -j MARK --set-mark 10
iptables -t mangle -A POSTROUTING -p tcp --sport 443 -j MARK --set-mark 11
iptables -t mangle -A POSTROUTING -p tcp --sport 995 -j MARK --set-mark 12
iptables -t mangle -A POSTROUTING -p tcp --sport 1024:65535 -j MARK --set-mark 13
TCAU="tc class add dev imq0"
TFAU="tc filter add dev imq0"
TQAU="tc qdisc add dev imq0"
modprobe imq
modprobe ipt_IMQ
ip link set imq0 up
tc qdisc del dev imq0 root
tc qdisc add dev imq0 root handle 1: htb
tc class add dev imq0 parent 1: classid 1:1 htb rate 4560kbit
$TCAU parent 1:1 classid 1:13 htb rate 10kbit ceil 10kbit prio 4
$TQAU parent 1:13 handle 13: $SFQ
$TFAU parent 1:0 prio 4 protocol ip handle 13 fw flowid 1:13
iptables -t mangle -A PREROUTING -p tcp --dport 1024:65535 -j MARK --set-mark 13
iptables -t mangle -A PREROUTING -j IMQ --todev 0  

When I do modprobe imq and modprobe ipt_IMQ I get the error kernel module is not found. Is there any way I can make this script work on ubuntu server?

Best Answer

You should patch your kernel to add support for IMQ. Here you find the patches http://www.linuximq.net/patches.html and here you will find details instructions how to compile it: http://ubuntuforums.org/showthread.php?t=1404537

Regards