Hello folks,
I�m a fully Beginner in Linux and Traffic Control.
I have a lot of Problems to realize the following Scenario(I need it for my
scholastics):
2 customers share one 2Mbit link. The packets of the customers are coming
on
the interface with a NAT Adress each. Each of the customers should use only
1Mbit of the Line.
192.168.0.1 - - -
customer1 eth0 | | eth1 customer1
-----------| |--------------
customer2 2Mbit| | 2Mbit customer2
192.168.1.99 - - -
I think I have to use 2 Scripts, one for each interface (on every side).
I have written a small skript, but i�m unsteady if it works. It would be
very nice, if you can take a look at it and give me some hints.
Greetings
Marcus Sch�fer
############################################################################Traffic
Control
###########################################################################
#! /bin/sh
#variables
ext_dev_1=eth0
bw=1Mbps
#####root qdisc for eth0
tc qdisc add dev $ext_dev_1 root handle 1: htb
#####root class for customer 1 on eth0
tc class add dev $ext_dev_1 parent 1: classid 1:1 htb rate $bw ceil $bw
prio
0
##### 3 classes for customer 1 on eth0
tc class add dev $ext_dev_1 parent 1:1 classid 1:2 htb rate 450kbps ceil
$bw
prio 0
tc class add dev $ext_dev_1 parent 1:1 classid 1:3 htb rate 450kbps ceil
$bw
prio 1
tc class add dev $ext_dev_1 parent 1:1 classid 1:4 htb rate 100kbps ceil
$bw
prio 2
#####root class for customer 2 on eth0
tc class add dev $ext_dev_1 parent 1: classid 2:1 htb rate $bw ceil $bw
prio
0
#####3 classes for customer 2 on eth0
tc class add dev $ext_dev_1 parent 1:1 classid 2:2 htb rate 450kbps ceil
$bw
prio 0
tc class add dev $ext_dev_1 parent 1:1 classid 2:3 htb rate 450kbps ceil
$bw
prio 1
tc class add dev $ext_dev_1 parent 1:1 classid 2:4 htb rate 100kbps ceil
$bw
prio 2
#####Filters which directs packets marked with iptables in the right
classes
#####Filters for customer 1 on eth0
tc filter add dev ext_dev_1 parent 1: prio 0 protocol ip handle 1 fw flowid
1:2
tc filter add dev ext_dev_1 parent 1: prio 1 protocol ip handle 2 fw flowid
1:3
tc filter add dev ext_dev_1 parent 1: prio 2 protocol ip handle 3 fw flowid
1:4
#####Filters for customer 2 on eth0
tc filter add dev ext_dev_1 parent 1: prio 0 protocol ip handle 4 fw flowid
2:2
tc filter add dev ext_dev_1 parent 1: prio 1 protocol ip handle 5 fw flowid
2:3
tc filter add dev ext_dev_1 parent 1: prio 1 protocol ip handle 6 fw flowid
2:4
############################################################################
iptables
###########################################################################
$ipt=/sbin/iptables
########### mark packets for customer 1 on eth0 ###########################
# mark packets with 1 which come from 192.168.0.1 and have a source port
#of
80
$ipt -t mangle -A FORWARD -s 192.168.0.1 -p tcp --sport 80 -j MARK
--set-mark 1
# mark packets with 2 which come from 192.168.0.1 and have a source port
#of
22
$ipt -t mangle -A FORWARD -s 192.168.0.1 -p tcp --sport 22 -j MARK
--set-mark 2
######## mark packets for customer 2 on eth0 ##############################
# mark packets with 4 which come from 192.168.1.99 and have a source port
#of 80
$ipt -t mangle -A FORWARD -s 192.168.1.99 -p tcp --sport 80 -j MARK
--set-mark 4
# mark packets with 5 which come from 192.168.1.99 and have a source port
#of 22
$ipt -t mangle -A FORWARD -s 192.168.1.99 -p tcp --sport 22 -j MARK
--set-mark 5
######## mark unmatched packets ###########################################
#mark packets with 3 which come from 192.168.0.1
$ipt -t mangle -A FORWARD -s 192.168.0.1 -j MARK --set-mark 3
#mark packets with 6 which come from 192.168.1.99
$ipt -t mangle -A FORWARD -s 192.168.1.99 -j MARK --set-mark 6
--
NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
GMX DSL-Netzanschluss + Tarif zum superg�nstigen Komplett-Preis!
_______________________________________________
LARTC mailing list / [EMAIL PROTECTED]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/