How to limit network bandwidth?

You can throttle the network bandwidth on the interface using the command called tc Man page available at http://man7.org/linux/man-pages/man8/tc.8.html

For a simple script, try wondershaper.

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


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 

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.