I'm trying to configure some basic traffic classification to limit the maximum ingress bandwidth for every machine in my local network to 3 Mbps. I'm operating the gateway 192.168.2.1, where the interface eth1
is attached to a switch to provide Internet connection for hosts at 192.168.2.0/24
.
The classification is simple: ingress traffic is classified info two classes, the first class 1:20
is for the unclassified traffic by default as fallback, the second class 1:30
would limit the ingress bandwidth to 3 Mbps. Then I use a tc filter
to classify the traffic originated from every host as class 1:30
.
# Clear the qdisc first.
tc qdisc del root dev eth1
# Set a HTB qdisc on the root, and use class 1:20 by default
tc qdisc add dev eth1 root handle 1: htb default 20
# Create class 1:1, limit the total ingress bandwidth to 8 Mbps.
tc class add dev eth1 parent 1: classid 1:1 htb rate 8mbit burst 15k
# Class 1:20
tc class add dev eth1 parent 1:1 classid 1:20 htb rate 5mbit ceil 5.5mbit burst 15k
# Class 1:30
tc class add dev eth1 parent 1:1 classid 1:30 htb rate 3mbit ceil 4mbit burst 15k
# Attach fq_codel w/ ECN on each class to control latency / bufferbloat.
tc qdisc add dev eth1 parent 1:20 handle 20: fq_codel ecn
tc qdisc add dev eth1 parent 1:30 handle 30: fq_codel ecn
# Match the LAN range and classify them as class 1:30
tc filter add dev eth1 parent 1: protocol ip prio 2 u32 match ip src 192.168.2.0/24 flowid 1:30
However, the rule doesn't work as intended. The download speed for hosts is still the higher bandwidth specified in 1:20
, not 1:30
. What is my mistake?
Best Answer
Whats Your kernel version?
I'm trying to configure similar thing, and becoming to have strong feeling that kernel debian 4.15.0-23-generic is broken. Problem is not with HTB itself, but with classifying packets fo correct classid flow.
Even this educational example fails:
when do
You see, that all packets go correctly through 1:13
but if You do
works in strange way, only few packets every few minutes goes as expected, other still go through default
next example of try to classify:
works same (it seems that statistically more packets goes right than in previous example)
There is no errors or warning in logs, just work like this
Some kernel networking developer here?
I will try other versions before report it :)