Throttling Upload AND Download bandwidth on Linux with TC (Traffic Controller)

I had the need recently to test how a product responded when it hit its max bandwidth but didn’t want to saturate our connection. Having used tc before I was pretty sure it could do the job.

A quick google search found some nice scripts such as this one by Nathan Salt. The problem I quickly saw was that while upload was throttled, download was still maxing out my circuit.

After some digging I found the answer on a very valuable resource, the Linux Advanced Routing and Traffic Control How To.

Limit download speed

This is slightly trickier as we can’t really influence how fast the internet ships us data. We can however drop packets that are coming in too fast, which causes TCP/IP to slow down to just the rate we want. Because we don’t want to drop traffic unnecessarily, we configure a ‘burst’ size we allow at higher speed.

With this information I was able to find some references to adding a virtual IFB interface to loop the traffic through. More searching and I came across this article:
Using the information there from Sérgio Carvalho and the script provided by jmarceli I was finally able to limit both upload and download.

Only issue I’ve seen so far is that after reboot the interface I have this setup on is defaulting to a DOWN state. Not a big deal for me as I can console into the VM and set to UP, but something to be aware of before setting on a less accessible machine.

Also, as far as testing speed I used the CLI


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.