iptables Bandwidth Limit Under Linux
To limit the bandwidth on a linux box the following modules are needed:
cls_u32
sch_cbq
ip_tables
Load the modules and issue the following:
tc qdisc add dev eth0 root handle 1: cbq avpkt 1000 bandwidth 100mbit
tc class add dev eth0 parent 1: classid 1:1 cbq rate 256kbit allot 1500 prio 5 bounded isolated
tc filter add dev eth0 parent 1: protocol ip prio 16 u32 match ip dst 0/0 flowid 1:1
Don’t know why but this doesn’t seem to be really accurate since I’m limiting here at 256kbits/s but the MRTG graph is showing 232kbits/s