how to limit upload bandwidth per user in linux?
Posted
by
Gihan Lasita
on Server Fault
See other posts from Server Fault
or by Gihan Lasita
Published on 2012-12-09T13:45:02Z
Indexed on
2012/12/09
17:06 UTC
Read the original article
Hit count: 294
Can anyone provide the tc
command to limit upload bandwidth per user in Debian Lenny?
I found that to mark packets per user with iptables I can use the following command
iptables -t mangle -A OUTPUT -p tcp -m owner --uid-owner testuser -j MARK --set-mark 500
but I have no idea how to use tc
update
by running following commands, i managed to limit testuser upload bandwidth to 10Mbit
iptables -t mangle -N HTB_OUT
iptables -t mangle -I POSTROUTING -j HTB_OUT
iptables -t mangle -A HTB_OUT -j MARK --set-mark 30
iptables -t mangle -A HTB_OUT -m owner --uid-owner testuser -j MARK --set-mark 10
tc qdisc replace dev eth0 root handle 1: htb default 30
tc class replace dev eth0 parent 1: classid 1:1 htb rate 10Mbit burst 5k
tc class replace dev eth0 parent 1:1 classid 1:10 htb rate 10Mbit ceil 10Mbit
tc qdisc replace dev eth0 parent 1:10 handle 10: sfq perturb 10
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10
now the problem is, i do not want to limit testuser's FTP bandwidth but by running above commands FTP speed also limited to 10Mbit.
Regards
© Server Fault or respective owner