How to limit network bandwidth?

We are hosting an application on remote server. We need to test it with a limited network bandwidth (for users with bad Internet access).

Can I limit my internet bandwidth? For instance: 128 KB per second.

This question focuses on system-wide or container-wide solutions on Linux. See Limiting a specific shell's internet bandwidth usage for process- or session-specific solutions.

Asked By: Kiril Kirilov


You can throttle the network bandwidth on the interface using the command called tc Man page available at

For a simple script, try wondershaper.

An example from using tc:
tc qdisc add dev eth0 root tbf rate 1024kbit latency 50ms burst 1540

Answered By: Nikhil Mulley

Limiting network resources based on some criterias is the subject of QoS. There are several different ways to control user traffic on Linux systems.

There is a good How-to about advanced routing techniques and traffic control on Linux by Bert Hubert.

Answered By: Emre Yazici

If you already have an Apache setup somewhere, you can use mod_bw, which also works on proxied connections (i.e. Apache just forwards everything to the proper server, but slows the responses down.)

Answered By: Ulrich Schwarz

Dummynet does what you want and more, you can even control the latency, random packet loss and lots more.

Answered By: Ammar Alammar

As noted in previous answer, wondershaper does the job easily.
I include the information from above link by Jwalanta Shrestha

apt-get install wondershaper

wondershaper – An easy tool to limit bandwidth of a particular interface.

$ sudo wondershaper {interface} {down} {up}

the {down} and {up} are bandwidth in kpbs

So for example if you want to limit the bandwidth of interface eth1 to 256kbps downlink and 128kbps uplink,

$ sudo wondershaper eth1 256 128

To clear the limit,

$ sudo wondershaper clear eth1 
Answered By: Eden

You can also use iptables hashlimit module.
Here is a simple example:

iptables -A FORWARD -m hashlimit –hashlimit-above 512kb/sec
–hashlimit-burst 1mb –hashlimit-mode srcip,dstip –hashlimit-name bwlimit -j DROP

That rule limits traffic that pass through FORWARD chain as 512kb/sec with 1mb burst for each source and destination pair.

Check hashlimit section of iptables manual for more information.

Answered By: ibrahim
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.