Is there an easy way to limit user bandwidth usage to say 10kpbs? Other users should not be affected. The best I've found is tc, but it seems way too complicated to do such a simple thing.

  • If the given answer solves your problem (i hope so), please select it as accepted, so that this issue can be marked as solved..
    – heemayl
    May 23 '15 at 14:54

tc is the correct answer to your configuration needs.
tc may seem complicated because it manages classfull (and less) queuing disciples which gives it unlimited flexibility and layers of shaping and filtering.
This however is not the case. As tc utilizes the built in (or modular) queuing disciples in the kernel it the simplest/best way of limiting bandwidth on a per user basis.
Here is a sample set-up, I left it in Mbit format but you can change the rate measure to kbps.

tc qdisc add dev eth0 root handle 1:0 htb
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 1Mbit ceil 1Mbit prio 1

For you iptables rule just change --uid-owner to the uid of the user you wish to limit, documentation says you can use the users name instead of UID, have not tested that.

iptables -t mangle -A POSTROUTING -o eth0 -p tcp -m owner --uid-owner 1000 -j CLASSIFY --set-class 1:1

FYI even though you do not need an HTB I would recommend it based on the available options and what speed you are limiting to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.