Throttle bandwidth via iptables
I have a need to throttle the bandwidth usage, similar to how some ISPs do it, so that after a couple of seconds, it throttles down the speed.
What you're looking for is called Traffic Shaping. The best source of information for it (that I know of) is Linux Advanced Routing and Traffic Control. It's a little bit dated, but still has a ton of good information. If you google for Linux Traffic Shaping
, you can find some scripts and tools to make the traffic shaping configuration a little bit easier.
The specific commands you will use, unless you find a tool or script to do the work for you, are tc and/or tcng. I also want to warn you that traffic shaping can get very complicated if you haven't done it before, particularly if you're trying to do it by hand.
Additionally, also remember that you can only reliably control the speed of data that you are sending out.
You might also want to check out these similar serverfault questions:
- Shaping Outbound Traffic to Control Download Speeds with Linux
- Linux Traffic Shaping Using tc
- Traffic Shaping Using tc
- Are there simpler ways to do traffic shaping in linux besides tc