From: =?ISO-8859-1?Q?=22Marcus_Sch=E4fer=22?= Date: Wed, 10 Nov 2004 14:48:35 +0000 Subject: [LARTC] HTB Message-Id: <2394.1100098115@www51.gmx.net> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: lartc@vger.kernel.org Hello folks,=20 =20 I=B4m a fully Beginner in Linux and Traffic Control.=20 I have a lot of Problems to realize the following Scenario(I need it for my scholastics):=20 =20 2 customers share one 2Mbit link. The packets of the customers are coming on=20 the interface with a NAT Adress each. Each of the customers should use only 1Mbit of the Line.=20 =20 192.168.0.1 - - - =20 customer1 eth0 | | eth1 customer1=20 -----------| |--------------=20 customer2 2Mbit| | 2Mbit customer2=20 192.168.1.99 - - -=20 =20 I think I have to use 2 Scripts, one for each interface (on every side).=20 =20 I have written a small skript, but i=B4m unsteady if it works. It would be= =20 very nice, if you can take a look at it and give me some hints.=20 =20 Greetings =20 Marcus Sch=E4fer=20 =20 =20 ###########################################################################= #Traffic Control=20 ########################################################################### =20 =20 #! /bin/sh=20 #variables=20 ext_dev_1=3Deth0=20 bw=3D1Mbps=20 =20 #####root qdisc for eth0=20 tc qdisc add dev $ext_dev_1 root handle 1: htb =20 #####root class for customer 1 on eth0=20 tc class add dev $ext_dev_1 parent 1: classid 1:1 htb rate $bw ceil $bw prio=20 0=20 =20 ##### 3 classes for customer 1 on eth0=20 tc class add dev $ext_dev_1 parent 1:1 classid 1:2 htb rate 450kbps ceil $bw=20 prio 0=20 tc class add dev $ext_dev_1 parent 1:1 classid 1:3 htb rate 450kbps ceil $bw=20 prio 1=20 tc class add dev $ext_dev_1 parent 1:1 classid 1:4 htb rate 100kbps ceil $bw=20 prio 2=20 =20 =20 #####root class for customer 2 on eth0=20 tc class add dev $ext_dev_1 parent 1: classid 2:1 htb rate $bw ceil $bw prio=20 0=20 =20 #####3 classes for customer 2 on eth0=20 tc class add dev $ext_dev_1 parent 1:1 classid 2:2 htb rate 450kbps ceil $bw=20 prio 0=20 tc class add dev $ext_dev_1 parent 1:1 classid 2:3 htb rate 450kbps ceil $bw=20 prio 1=20 tc class add dev $ext_dev_1 parent 1:1 classid 2:4 htb rate 100kbps ceil $bw=20 prio 2=20 =20 =20 =20 #####Filters which directs packets marked with iptables in the right classes=20 =20 =20 #####Filters for customer 1 on eth0=20 tc filter add dev ext_dev_1 parent 1: prio 0 protocol ip handle 1 fw flowid 1:2=20 tc filter add dev ext_dev_1 parent 1: prio 1 protocol ip handle 2 fw flowid 1:3=20 tc filter add dev ext_dev_1 parent 1: prio 2 protocol ip handle 3 fw flowid 1:4 =20 =20 #####Filters for customer 2 on eth0=20 tc filter add dev ext_dev_1 parent 1: prio 0 protocol ip handle 4 fw flowid 2:2=20 tc filter add dev ext_dev_1 parent 1: prio 1 protocol ip handle 5 fw flowid 2:3 =20 tc filter add dev ext_dev_1 parent 1: prio 1 protocol ip handle 6 fw flowid 2:4 =20 =20 =20 =20 =20 ############################################################################ iptables=20 ########################################################################### =20 $ipt=3D/sbin/iptables=20 =20 ########### mark packets for customer 1 on eth0 ########################### =20 # mark packets with 1 which come from 192.168.0.1 and have a source port #of=20 80=20 =20 $ipt -t mangle -A FORWARD -s 192.168.0.1 -p tcp --sport 80 -j MARK=20 --set-mark 1=20 =20 # mark packets with 2 which come from 192.168.0.1 and have a source port #of=20 22=20 =20 $ipt -t mangle -A FORWARD -s 192.168.0.1 -p tcp --sport 22 -j MARK=20 --set-mark 2=20 =20 ######## mark packets for customer 2 on eth0 ############################## =20 # mark packets with 4 which come from 192.168.1.99 and have a source port = #of 80=20 =20 $ipt -t mangle -A FORWARD -s 192.168.1.99 -p tcp --sport 80 -j MARK=20 --set-mark 4=20 =20 =20 # mark packets with 5 which come from 192.168.1.99 and have a source port = #of 22=20 =20 $ipt -t mangle -A FORWARD -s 192.168.1.99 -p tcp --sport 22 -j MARK=20 --set-mark 5=20 =20 =20 ######## mark unmatched packets ########################################### =20 #mark packets with 3 which come from 192.168.0.1=20 =20 $ipt -t mangle -A FORWARD -s 192.168.0.1 -j MARK --set-mark 3=20 =20 #mark packets with 6 which come from 192.168.1.99=20 =20 $ipt -t mangle -A FORWARD -s 192.168.1.99 -j MARK --set-mark 6=20 --=20 NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl GMX DSL-Netzanschluss + Tarif zum superg=FCnstigen Komplett-Preis! _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/