Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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
up vote 7 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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