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?