Bandwidth Limiting


Here's my old recipe for outbound bandwidth limiting, using the arcane version of tc that comes bundled with RedHat 9.0 (I really should update the userland to match the current kernel or do a full update to Fedora...), based on Davi's notes:

#!/bin/sh
tc qdisc add dev eth0 root handle 1: cbq bandwidth 100mbit avpkt 1000 cell 8
tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate 192kbit \
 weight 6kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000 bounded
tc filter add dev eth0 protocol ip pref 1 parent 1: handle 1 fw classid 1:1
iptables -t mangle -I OUTPUT 1 -m tcp -p tcp --sport 80 -j MARK --set-mark 1
iptables -t mangle -I OUTPUT 1 -m tcp -p tcp --sport 443 -j MARK --set-mark 1

Inbound was not limited on this particular box.

Resources:

  • Trickle is a userland bandwidth shaper for UNIX-like systems

See Also: