Limit total bandwidth on Linux

Want to limit the total bandwidth available to a Linux server, and don’t want to do it at the switch or router? Here’s how!

Simply use the Linux traffic control tools as follows. First enter:

tc qdisc add dev eth0 root handle 1: cbq avpkt 1000 bandwidth 100mbit

Now enter the following line. This line sets the bandwidth rate; note the “256kbit”. This will limit our server to 256Kbps.

tc class add dev eth0 parent 1: classid 1:1 cbq rate 256kbit allot 1500 prio 5 bounded isolated

And lastly:

tc filter add dev eth0 parent 1: protocol ip prio 16 u32 match ip dst 0/0 flowid 1:1

For more informtation on how this works, type ‘man tc’ at your console.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>