What I Learned Today
Using TC to limit bandwidth

This code will limit the bandwidth between the source host and the destination IP set.



bw=$1  ## desired bandwidth in megabits per sec
destip=$2  ## destination host to limit traffic to
tc qdisc del dev peth0 root
tc qdisc add dev peth0 root handle 1: htb
tc class add dev peth0 parent 1: classid 1:1 htb rate ${bw}mbit ceil ${bw}mbit
tc class add dev peth0 parent 1:1 classid 1:11 htb rate ${bw}mbit ceil ${bw}mbit
tc filter add dev peth0 protocol ip parent 1:0 prio 1 u32 match ip dst $destip flowid 1:11