Skip to contentSkip to conversation

matching classid with iptables and stuff

LARTC mdew 2 participants 3 messages Sep 5, 2002 – Sep 6, 2002

lore
Share & tools
lore

mdew

author
#0 lore raw

# 40.10 Paul 40.11 Mark
tc class add dev imq0 parent 40:1 classid 40:10 htb rate 5Kbps ceil
7Kbps burst 2k
tc class add dev imq0 parent 40:1 classid 40:11 htb rate 5Kbps ceil
6Kbps burst 3k
# 40:12 Mike 40:13 Brian
tc class add dev imq0 parent 40:1 classid 40:12 htb rate 200Kbps ceil
220Kbps burst 4k
tc class add dev imq0 parent 40:1 classid 40:13 htb rate 200Kbps ceil
240Kbps burst 4k

how do i show 40:1x is the ip w.x.y.z (and for the other ip's) ?

Working off the prensentation..
Basically we have a 256Kb connection (yes small fry)

## We Start at the root of the device, eth0
# Install HTB as the root qdisc, names it 1:0.
tc qdisc add dev eth0 root handle 1: htb
# This attaches a shaping HTB to the HTB root, 256kps with a 2k bucket tc gdisc add dev eth0 parent 1: classid 1:1 htb rate 256Kbps burst 20k

#The first class is guaranteed 5Kbps of the 256Kbps, but can grow to 7 if available
#The second class however can take up to 240kbits (changed) # 1.10 Paul 1.11 Mark
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 5Kbps ceil 7Kbps burst 2k
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 5Kbps ceil 6Kbps burst 3k
# 1:12 Mike 1:13 Brian
tc class add dev eth0 parent 1:1 classid 1:12 htb rate 200Kbps ceil 220Kbs burst 4k
tc class add dev eth0 parent 1:1 classid 1:13 htb rate 200Kbps ceil 240Kbs burst 4k

## Filtering to Classify traffic
# When a packet enters the qdisc it needs to be classified. This is done with 'tc filters':
U32="tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32" $U32 match ip dport 25 0xffff flowid 1:10
$U32 match ip sport 80 0xffff flowid 1:11

## Shape incoming Traffic (IMQ)
modprobe imq numdevs=1
tc qdisc add dec imq0 root handle 40: htb default 22
tc class add dev imq0 parent 40: classid 40:1 htb rate 256Kbps burst
20k
# 40.10 Paul 40.11 Mark
tc class add dev imq0 parent 40:1 classid 40:10 htb rate 5Kbps ceil
7Kbps burst 2k
tc class add dev imq0 parent 40:1 classid 40:11 htb rate 5Kbps ceil
6Kbps burst 3k
# 40:12 Mike 40:13 Brian
tc class add dev imq0 parent 40:1 classid 40:12 htb rate 200Kbps ceil
220Kbps burst 4k
tc class add dev imq0 parent 40:1 classid 40:13 htb rate 200Kbps ceil
240Kbps burst 4k

tc class add dev imq0 parent 40:10 classid 40:11 htb rate 240Kbps burst 4k

iptables -t mangle -A PREROUTING -i eth0 -j IMQ
# Push all Pauls traffic through IMQ
iptables -t mangle -A PREROUTING -i eth0 -p tcp -d 10.0.0.9 -j IMQ --todev 0
ip link setup imq0 up

am i close? :)

#2 lore raw
In reply to mdew
Quoted 11 lines · mdew

# 40.10 Paul 40.11 Mark
tc class add dev imq0 parent 40:1 classid 40:10 htb rate 5Kbps ceil
7Kbps burst 2k
tc class add dev imq0 parent 40:1 classid 40:11 htb rate 5Kbps ceil
6Kbps burst 3k
# 40:12 Mike 40:13 Brian
tc class add dev imq0 parent 40:1 classid 40:12 htb rate 200Kbps ceil
220Kbps burst 4k
tc class add dev imq0 parent 40:1 classid 40:13 htb rate 200Kbps ceil
240Kbps burst 4k

Quoted 1 line

how do i show 40:1x is the ip w.x.y.z (and for the other ip's) ?

What do you mean with "show"? Do you want to put the traffic from/to the different ip's in the different class? If yes, you need some filters (like u32 or fw).

Quoted 46 lines

Working off the prensentation..
Basically we have a 256Kb connection (yes small fry)

## We Start at the root of the device, eth0
# Install HTB as the root qdisc, names it 1:0.
tc qdisc add dev eth0 root handle 1: htb
# This attaches a shaping HTB to the HTB root, 256kps with a 2k bucket tc gdisc add dev eth0 parent 1: classid 1:1 htb rate 256Kbps burst 20k

#The first class is guaranteed 5Kbps of the 256Kbps, but can grow to 7 if available
#The second class however can take up to 240kbits (changed) # 1.10 Paul 1.11 Mark
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 5Kbps ceil 7Kbps burst 2k
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 5Kbps ceil 6Kbps burst 3k
# 1:12 Mike 1:13 Brian
tc class add dev eth0 parent 1:1 classid 1:12 htb rate 200Kbps ceil 220Kbs burst 4k
tc class add dev eth0 parent 1:1 classid 1:13 htb rate 200Kbps ceil 240Kbs burst 4k

## Filtering to Classify traffic
# When a packet enters the qdisc it needs to be classified. This is done with 'tc filters':
U32="tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32" $U32 match ip dport 25 0xffff flowid 1:10
$U32 match ip sport 80 0xffff flowid 1:11

## Shape incoming Traffic (IMQ)
modprobe imq numdevs=1
tc qdisc add dec imq0 root handle 40: htb default 22
tc class add dev imq0 parent 40: classid 40:1 htb rate 256Kbps burst
20k
# 40.10 Paul 40.11 Mark
tc class add dev imq0 parent 40:1 classid 40:10 htb rate 5Kbps ceil
7Kbps burst 2k
tc class add dev imq0 parent 40:1 classid 40:11 htb rate 5Kbps ceil
6Kbps burst 3k
# 40:12 Mike 40:13 Brian
tc class add dev imq0 parent 40:1 classid 40:12 htb rate 200Kbps ceil
220Kbps burst 4k
tc class add dev imq0 parent 40:1 classid 40:13 htb rate 200Kbps ceil
240Kbps burst 4k

Quoted 2 lines

tc class add dev imq0 parent 40:10 classid 40:11 htb rate 240Kbps burst 4k

??? Why are you doing this? The parent has a ceil of 7Kbps, so this class will get never more then 7Kbps.

Quoted 7 lines

iptables -t mangle -A PREROUTING -i eth0 -j IMQ
# Push all Pauls traffic through IMQ
iptables -t mangle -A PREROUTING -i eth0 -p tcp -d 10.0.0.9 -j IMQ --todev 0
ip link setup imq0 up

am i close? :)

Don't you have to put also the other traffic (Mark, Mike, Brian) traffic in the imq0 device ?

Stef

Signature · 8 lines
[email protected]
 "Using Linux as bandwidth manager"
     http://www.docum.org/
     #lartc @ irc.oftc.net

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/