Setting up Qos_ng on IPCOP
This tutorial is valid for IPCOP 1.4.21 with Qos_ng 1.5.2 (version is seen on Qos_ng configuration page).
The easiest way to see if qos_ng is working is by downloading a large file via bittorrent (such as Knoppix) and watching your bandwidth change as you turn on Qos_ng.
WARNING: Changing to the modified kernel means you will be unable to update IPCOP as you are unable to revert the kernel change. This may also break other mods which are kernel dependent. Conduct all tests on a test box before moving into a production environment.
Settings used in example
Summary of settings used in this example (if you are impatient to read through the entire tutorial).
Connection information
| Maximum Speed | 90% | 30% | |
|---|---|---|---|
| Download | 6847 | 6150 | 2050 |
| Upload | 486 | 420 | 140 |
Root class settings
| Root Class | Maximum Rate |
|---|---|
| 199 (Upload) | 420 (aka 90%) |
| 299 (Download) | 6150 (aka 90%) |
Class settings
| Class | Priority | Min Bandwidth | Max Bandwidth | Burst | Cell Burst |
|---|---|---|---|---|---|
| 100 | 1 | 100 | 420 (aka 90%) | 50 | 50 |
| 150 | 3 | 140 (aka 30%) | 420 (aka 90%) | [blank] | [blank] |
| 175 | 7 | 0 | 140 (aka 30%) | [blank] | [blank] |
| 199 | 4 | 0 | 420 (aka 90%) | [blank] | [blank] |
| 200 | 1 | 1000 | 6150 (aka 90%) | 50 | 50 |
| 250 | 3 | 2050 (aka 30%) | 6150 (aka 90%) | [blank] | [blank] |
| 275 | 7 | 0 | 2050 (aka 30%) | [blank] | [blank] |
| 299 | 4 | 0 | 6150 (aka 90%) | [blank] | [blank] |
Layer7 rules
| Name | Protocol | Mark |
|---|---|---|
| dns_up | dns | 100 |
| dns_down | dns | 200 |
| torrent_up | bittorrent | 175 |
| torrent_down | bittorrent | 275 |
Preparing IPCOP
- Standard install of IPCOP 1.4.20
- Upgrade to 1.4.21 from web interface
- Restart IPCOP
Installing Modified Kernel
- Download layer7 mod for IPCOP 1.4.21 to your computer (non-embeded version)
- Copy over ipcop-1.4.21-kernel-2.4.36.tar.bz2 to /tmp folder on IPCOP
- On IPCOP:
cd /tmp tar xjf ipcop-1.4.21-kernel-2.4.36.tar.bz2 -C / touch /var/run/need-depmod-2.4.36
- Restart IPCOP
Installing Qos_ng
- Download latest version of Qos_ng for IPCOP 1.4.21 to your computer
- Copy over qos_ng_ipcop_1.4.21.tar.gz to /tmp folder on IPCOP
- On IPCOP:
cd /tmp tar xfz qos_ng_ipcop_1.4.21.tar.gz cd qos_ng ./install
- During install, say 'Y' to auto version check
- During install, say 'N' to update layer7 (need to modify files before this will work)
- Restart IPCOP
Configuring Qos_ng
Setting up root class
- Navigate to the Qos page
- Under the first section (either eth1 or ppp0) set the default class for upload to 199 and a speed of 420 (aka 90%)
- Click save
- Click on 'Add a new root class'
- Under the second section (imq0) set the default class for download to 299 and a speed of 6150 (aka 90%)
- Click save
Setting up classes
Upload classes
- Click the Red pencil next to the first class (Handle 1)
- Select Class 199, set Priority to 4, minimum upload to 0, and maximum upload to 420 (aka 90%) [leave the next two sections blank]
- Click save
- Click the Red pencil next to the first class (Handle 1)
- Select Class 100, set Priority to 1, minimum upload to 100, maximum upload to 420 (aka 90%), burst to 50, and ceil burst to 50
- Click save
- Click the Red pencil next to the first class (Handle 1)
- Select Class 150, set Priority to 3, minimum upload to 140 (aka 30%), and maximum upload to 420 (aka 90%) [leave the next two sections blank]
- Click save
- Click the Red pencil next to the first class (Handle 1)
- Select Class 175, set Priority to 7, minimum upload to 0, and maximum upload to 140 (aka 30%) [leave the next two sections blank]
- Click save
Set Ack priority
- Click on 'set ack priority'
- Select 100
- Click save
Download classes
- Click the Red pencil next to the second class (Handle 2)
- Select Class 299, set Priority to 4, minimum upload to 0, and maximum upload to 6150 (aka 90%) [leave the next two sections blank]
- Click save
- Click the Red pencil next to the second class (Handle 2)
- Select Class 200, set Priority to 1, minimum upload to 1000, maximum upload to 6150 (aka 90%), burst to 50, and ceil burst to 50
- Click save
- Click the Red pencil next to the second class (Handle 2)
- Select Class 250, set Priority to 3, minimum upload to 2050 (aka 30%), and maximum upload to 6150 (aka 90%) [leave the next two sections blank]
- Click save
- Click the Red pencil next to the second class (Handle 2)
- Select Class 275, set Priority to 4, minimum upload to 0, and maximum upload to 2050 (aka 30%) [leave the next two sections blank]
- Click save
Fixing layer7
- Edit /var/ipcop/l7filter/l7update and replace contents with
#!/bin/bash
#
#modification to change the year automatically
setyear=2009
thisyear=2009
if [ "x$setyear" != "x$thisyear" ]
then
sed -i -e "s/$setyear/$thisyear/g" $0
echo -e "\nautomatically updated download-link, please start l7update again!\n"
exit 0
fi
# end modification
if [ "x$1" != "x" -a "x$1" != "xstartup" ]
then
MIRROR=$1
else
MIRROR=switch
fi
cd /var/ipcop/l7filter
#
#link to donwloadsection of "Linux layer 7 packet classifier" sourceforge project may change!
#
/var/ipcop/l7filter/wget -O "/var/ipcop/l7filter/index.html" -q "http://sourceforge.net/projects/l7-filter/files/"
#
currentY=$(cat localversion | cut -f1 -d"-")
currentM=$(cat localversion | cut -f2 -d"-")
currentD=$(cat localversion | cut -f3 -d"-")
currentV="$currentD$currentM$currentY"
#echo $currentV
#
#changes may be necessary due to changes in the structure of the htmlcode!
#
lastY=2009
lastM=05
lastD=28
#
lastV="$lastD$lastM$lastY"
lastupdate="$lastY-$lastM-$lastD"
#echo $lastV
#echo $lastupdate
[ "$lastV" == "" ] && echo -e "Unable to detect online Version, exiting..........." && exit 1
[ "$currentV" == "" ] && echo -e "Unable to detect installed Version, exiting..........." && exit 1
/bin/rm index.html
if [ "$lastV" != "$currentV" ]
then
#
#changes may be necessary due to changes in the structure of the downloadlinks!
#
CHECK=`/var/ipcop/l7filter/wget --spider http://$MIRROR.dl.sourceforge.net/project/l7-filter/Protocol%20definitions/"$lastupdate"/l7-protocols-"$lastupdate".tar.gz 2>&1`
#
#echo $CHECK
SIZE=`/bin/echo $CHECK| cut -dL -f2| awk {'print $2'}|cut -d, -f1`
NOTFOUND=`/bin/echo $SIZE|grep http`
NOTFOUND="x${NOTFOUND}"
FAILED=`/bin/echo $CHECK| grep failed| cut -d: -f6`
FAILED="x${FAILED}"
#echo $SIZE
#echo;echo;echo
#echo $NOTFOUND
#echo;echo;echo
#echo $FAILED
if [ "$FAILED" != "x" ]
then
if [ "x$1" != "xstartup" ]
then
/bin/echo "Error while downloading file."
exit 0
else
/bin/echo -e "[\033[1;31m Failed \033[0m]"
exit 0
fi
fi
if [ "$NOTFOUND" != "x" ]
then
if [ "x$1" != "xstartup" ]
then
/bin/echo "File is not on the mirror right now."
exit 0
else
/bin/echo -e "[\033[1;31m Failed \033[0m]"
exit 0
fi
fi
if [ $SIZE -le 2 ]
then
if [ "x$1" != "xstartup" ]
then
/bin/echo "File is not on the mirror right now."
exit 0
else
/bin/echo -e "[\033[1;31m Failed \033[0m]"
exit 0
fi
fi
#
#changes may be necessary due to changes in the structure of the downloadlinks!
#
/var/ipcop/l7filter/wget -q http://$MIRROR.dl.sourceforge.net/project/l7-filter/Protocol%20definitions/"$lastupdate"/l7-protocols-"$lastupdate".tar.gz
#
/bin/echo $lastupdate > localversion
/bin/tar xfz l7-protocols-"$lastupdate".tar.gz
/bin/rm -rf /etc/l7-protocols/
/bin/mv l7-protocols-"$lastupdate" /etc/l7-protocols
/bin/chown -R root.root /etc/l7-protocols
/bin/rm l7-protocols-"$lastupdate".tar.gz
/bin/echo "$(date) : Layer7 protocols updated successefully" >>/var/log/messages
if [ "x$1" == "xstartup" ]
then
echo -e "[\033[1;32m Done \033[0m]"
fi
else
/bin/echo "$(date) : Your Layer7 protocols are up to date" >>/var/log/messages
if [ "x$1" == "xstartup" ]
then
echo -e "[\033[1;32m Done \033[0m]"
fi
fi
- After the above changes have been made, click on 'update layer 7'
- After updates finish, click 'return to main menu'
Creating rules
DNS rule
- Click the Green pencil next to the 100 class
- Enter name dns_up
- Select protocol dns
- Click save
- Click the Green pencil next to the 200 class
- Enter name dns_down
- Select protocol dns
- Click save
Bittorrent
- Click the Green pencil next to the 175 class
- Enter name torrent_up
- Select protocol bittorrent
- Click save
- Click the Green pencil next to the 275 class
- Enter name torrent_down
- Select protocol bittorrent
- Click save
Starting Qos
- Click the Start button
- Click 'return to main menu'
- Click 'start collector'
- Click 'return to main menu'
You should now have Qos running and be able to see graphs of qos's performance
