Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.