Linux Download / Upload Limiter
Posted in Uncategorized on April 17th, 2013 by OneOfOneI recently ran into a bandwidth problem using Skype, and I found no easy way to limit it, trickled doesn’t work udp, and after some research I came across QoS / tc shaping.
I cooked 2 different scripts and here’s what I came with :
It works for me (TM)
#!/bin/sh IF=wlan0 ULIMIT=25kbps DLIMIT=40kbps U32="tc filter add dev $IF protocol ip parent 1:0 prio 1 u32" IP=xxx.xxx.xxx.xxx case "$1" in stop) tc qdisc del dev $IF root tc qdisc del dev $IF ingress ;; show) tc -s qdisc ls dev $IF ;; *) tc qdisc add dev $IF root handle 1: htb default 30 tc class add dev $IF parent 1: classid 1:1 htb rate $ULIMIT ceil $ULIMIT $U32 match ip dst $IP/32 flowid 1:1 tc qdisc add dev $IF handle ffff: ingress tc filter add dev $IF parent ffff: protocol ip prio 10 u32 match \ ip src $IP/32 police rate $DLIMIT burst 80kbit drop flowid :1 tc -s qdisc ls dev $IF ;; esac
References :
0154 | script limit bandwidth UDP
[LARTC] Qos wiht HTB for ADSL/Home