Skip to contentSkip to conversation

CBQ by IP address

LARTC Gavin 2 participants 2 messages Mar 16, 2002

lore
Share & tools
lore

Gavin

author
#0 lore raw

Hello,

I have a Q running (script attached, from the how-to) which does the following:

1. Assign 6MBit to link
2. Assign 5MBit to 192.168.230.0/24
3. Assign 3MBit to 192.168.220.0/24

I have two questions:

1. Is it possible to set a limit for a particular IP address, rather than a range? I've tried the following:

match ip src 192.168.230.1 - the filter has no effect on traffic
match ip src 192.168.230.4/32 - the filter has no effect on traffic match ip src 192.168.230.1/24 - the filter affects the whole 192.168.230.0 network

2. With the attached script, bandwidth is set to 5MBit or 3Mbit for a single machine on the filtered networks. When I add another machine on the same network, both machines get half of the rate. Is there a way to say that all machines on a particular /24 are limited to a particular rate, rather than sharing it between them?

Many thanks,

Gavin

#!/bin/bash
#Test script
# One class, bounded at 6Mbit. Two classes, bounded, 3Mbit and 5Mbit, not sharing extra.

#Delete the existing eth0 root qdisc
tc qdisc del dev eth0 root

#Add root qdisc
tc qdisc add dev eth0 root handle 1:0 cbq bandwidth 100Mbit avpkt 1000 cell 8

#Add 1:0 class, with 6Mbit limit
tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate 6Mbit weight 0.6Mbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000 bounded

#Add first class, limited to 5Mbit
tc class add dev eth0 parent 1:1 classid 1:3 cbq bandwidth 100Mbit rate 5Mbit weight 0.5Mbit prio 5 allot 1514 cell 8 maxburst 20 avpkt 1000 bounded

#Add second class, limited to 3Mbit

tc class add dev eth0 parent 1:1 classid 1:4 cbq bandwidth 100Mbit rate 3Mbit weight 0.3Mbit prio 5 allot 1514
cell 8 maxburst 20 avpkt 1000 bounded

#Add qdisc for class 1:3
tc qdisc add dev eth0 parent 1:3 handle 30: sfq

#Add qdisc for class 1:4
tc qdisc add dev eth0 parent 1:4 handle 40: sfq

#Add filter for 192.168.230.0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src 192.168.230.0/24 flowid 1:3 #tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src 192.168.230.1 flowid 1:3 #tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src 192.168.230.1/24 flowid 1:3 #tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src 192.168.230.1/32 flowid 1:3

#Add filter for 192.168.220.0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src 192.168.220.0/24 flowid 1:4

#1 lore raw
Quoted 11 lines · you

Hello,

I have a Q running (script attached, from the how-to) which does the following:

1. Assign 6MBit to link
2. Assign 5MBit to 192.168.230.0/24
3. Assign 3MBit to 192.168.220.0/24

I have two questions:

Quoted 7 lines

1. Is it possible to set a limit for a particular IP address, rather than a range? I've tried the following:

match ip src 192.168.230.1 - the filter has no effect on traffic
match ip src 192.168.230.4/32 - the filter has no effect on traffic match ip src 192.168.230.1/24 - the filter affects the whole 192.168.230.0 network

This works for me :

tc filter add dev eth0 parent 10: protocol ip u32 match ip dst 192.168.1.253 flowid 10:10

Quoted 6 lines

2. With the attached script, bandwidth is set to 5MBit or 3Mbit for a single machine on the filtered networks. When I add another machine on the same network, both machines get half of the rate. Is there a way to say that all machines on a particular /24 are limited to a particular rate, rather than sharing it between them?

The only thing you can do is create a class and filter for each of the extra machines. The WRR qdisc can do this automatically, but I never tried it. It creates a class for each ip-address or mac-address it sees and gives each class an equal umount of bandwidth.

Stef

Signature · 7 lines
[email protected]
 "Using Linux as bandwidth manager"
     http://www.docum.org/
     #lartc @ irc.openprojects.net
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/