User Tools

Site Tools


Example2: plain simple bandwidth sharing (aka traffic shaping) with HTB

# We have 1000kbit upload and want to guarantee each user a certain amount of it.
# If one user does not use its full quota, the unused quota get evenly distributed amongst the other users.
# Variables
TC=$(which tc)
IPT=$(which iptables)
insmod sch_htb
$TC qdisc add dev $IF_DSL root       handle 1:    htb default 40
$TC class add dev $IF_DSL parent 1:  classid 1:1  htb rate 1000kbit
$TC class add dev $IF_DSL parent 1:1 classid 1:10 htb rate 250kbit #-- 25% to user1
$TC class add dev $IF_DSL parent 1:1 classid 1:20 htb rate 250kbit #-- 25% to user2
$TC class add dev $IF_DSL parent 1:1 classid 1:30 htb rate 350kbit #-- 35% to user3
$TC class add dev $IF_DSL parent 1:1 classid 1:40 htb rate 150kbit #-- 15% to user4
$IPTMOD -s $IP_USER1 -j CLASSIFY --set-class 1:10
$IPTMOD -s $IP_USER2 -j CLASSIFY --set-class 1:20
$IPTMOD -s $IP_USER3 -j CLASSIFY --set-class 1:30
$IPTMOD -s $IP_USER4 -j CLASSIFY --set-class 1:40
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
docs/guide-user/network/traffic-shaping/packet.scheduler.example2.txt · Last modified: 2019/08/26 09:02 by vgaetera