Advertisement
Bisqwit

Setting upload bandwidth limit for an user account

Mar 10th, 2018
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. # Setting upload bandwidth limit for an user.
  2. # This user is only for the purpose of uploading stuff to YouTube.
  3. # The purpose of this is to not inhibit normal web browsing / watching YouTube videos
  4. # while another video is being uploaded.
  5.  
  6. iptables -t mangle -F OUTPUT
  7. iptables -t mangle -A OUTPUT -p tcp -m owner --uid-owner yt_upload -j MARK --set-mark 10
  8. ip6tables -t mangle -F OUTPUT
  9. ip6tables -t mangle -A OUTPUT -p tcp -m owner --uid-owner yt_upload -j MARK --set-mark 10
  10.  
  11. # Configuration: Set device interface name and bandwidth limit.
  12. i=br0
  13. s=400kbit
  14.  
  15. tc qdisc del dev $i root
  16. tc qdisc replace dev $i root handle 1: htb default 30
  17. tc class replace dev $i parent 1: classid 1:1   htb rate $s burst 5k
  18. tc class replace dev $i parent 1:1 classid 1:10 htb rate $s ceil $s
  19. tc qdisc replace dev $i parent 1:10 handle 10:  sfq perturb 10
  20. tc filter add dev $i parent 1:0 prio 0 protocol ip   handle 10 fw flowid 1:10
  21. tc filter add dev $i parent 1:0 prio 0 protocol ipv6 handle 10 fw flowid 1:10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement