J
J
joneleth2013-05-07 05:42:43
linux
joneleth, 2013-05-07 05:42:43

Linux shaping VLAN?

It is necessary to limit the speed of the Internet for vlan. Router on linux (Debian 6).
Let's do something like this

dev='eth0.111'
rate='1Mbit'
ceil="$rate"
mark='3'
iptables -D OUTPUT -t mangle -o $dev -j MARK --set-mark $mark
tc qdisc del dev $dev root
tc qdisc add dev $dev root handle 1:0 htb default 10
tc class add dev $dev parent 1:0 classid 1:10 htb rate $rate ceil $rate prio 0
tc filter add dev $dev parent 1:0 prio 0 protocol ip handle $mark fw flowid 1:$mark
iptables -A OUTPUT -t mangle -o $dev -j MARK --set-mark $mark

As a result, the speed drops to ~40 KB/s. Without enabling shaping - downloads 1-2 Mbps. There are no other shaping rules on the car.
What can you try, what can you check?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
J
joneleth, 2013-05-13
@joneleth

Shaping on the physical interface saved the father of Russian democracy:

root_device='eth0'
tc qdisc del dev $root_device dev root
tc qdisc add dev $root_device root handle 1: htb default 10
tc class replace dev $root_device parent 1:0 classid 1:$vlan_id htb rate $rate ceil $ceil prio 0
tc filter replace dev $root_device protocol 802.1q parent 1:0 prio 1 handle 800::$vlan_id u32 match ip dst "$subnet" match ip protocol 1 0xff flowid 1:$vlan_id

E
eiji, 2013-05-07
@eiji

I use wondershaper for tests, it cuts the channel quite accurately and without any special failures.

E
EvilMan, 2013-05-09
@EvilMan

You have mark="3". Also in the filter you have “handle $mark fw flowid 1:$mark”, but you don’t have something of this class. Hence the problems. In addition, since you are cutting all traffic, you can do without using iptables.
For example, like this (adapting your script):

tc qdisc del dev $dev root
tc qdisc add dev $dev root handle 1: htb default 10
tc class add dev $dev parent 1:0 classid 1:10 htb rate $rate ceil $rate prio 0

I
Ilya Evseev, 2013-06-08
@IlyaEvseev

You need to hang SFQ on the leaves: sysadmins.ru/post9847647.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question