Short guide on using TC to force users to obey a certain upload speed in linux.
#First add a 'root' for eth1 tc qdisc add dev eth1 root handle 1: htb default 30 #Second add a class (bucket) with bandwidth restrictions tc class add dev eth1 parent 1: classid 1:2 htb rate 64kbit #Then add a filter to force packets through the class tc filter add dev eth1 protocol ip parent 1:0 prio 1 handle 1 fw classid 1:2
tc filter is usually sufficient as it can analyze packets with u32; however, I used iptables for simplicity. I mark a single computer with ip 192.168.0.22.
#Use iptables to tag the packet with a '1' so the filter can 'handle' it iptables -t mangle -I PREROUTING -s 192.168.0.22/32 -j MARK --set-mark 0x1
Check whether packets are flowing through the class with
tc -s class show eth1