Arch Linux Bandwidth Limiting Rocks

It’s complicated, but it works great. I have a Linux box that I put up for http access on my DSL. I sometimes let friends download stuff, and I need to limit the bandwidth. Luckily, the system is running Arch linux and it comes with the ‘traffic control’ patches built into the iptables kernel.

So, today, I needed to turn it on. I did it before, so all I had to do was find the time capsule file with my instructions in it. Then it was just, copy/paste, bam…. running.

Here is my set of commands:

tc -s qdisc show tc qdisc add dev eth0 root handle 1: htb default 11 tc class add dev eth0 parent 1: classid 1:1 htb rate 512Kbit tc class add dev eth0 parent 1:1 classid 1:10 htb rate 220Kbit tc class add dev eth0 parent 1:1 classid 1:11 htb rate 512Kbit tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip sport 80 0xffff flowid 1:10

This essentially sets up a small tree of pipes. The max output is 512kb for normal traffic. Port 80 traffic can use up to 220kbit. Any other traffic can get at least 292kb and more if the port 80 stuff isn’t in use.

This entry was posted in General. Bookmark the permalink.

2 Responses to Arch Linux Bandwidth Limiting Rocks

  1. Chris says:

    I work in a small company that currently has 4 bonded t1’s. At any given time anyone in the office can take down the network with a single download/upload. I built a linux “snooper” box by bridging two network cards and plugging it in between the main office feed and the external router. I’ve been messing around with tc for bw limiting but hadn’t been able to get it to work yet. Seeing your example showed me what I was doing wrong and it works great. Thanks for the post!

  2. Nick says:

    Great command but you should also have shared the config file for us to see all the correspondents to your class id id’s … else it is kind of not not usable.



Leave a Reply

Your email address will not be published.