Iptables – Limit bandwidth per connection in Linux

bandwidthiptablestctcp

I wasn't really able to google this which surprises me but maybe I was just looking the wrong way… I would like to limit bandwidth per one TCP connection ie. all the connections are coming to a single interface, using the same source address, have the same destination port and each of these connections should be limited to eg. 5 Mbit/s. The idea is to simulate hundreds of users having slow DSL lines using one 20 Gbit/s interface.

I guess there has to be a way to mark all the packets belonging to a particular connection with unique mark and then use this mark to limit the speed but I've never used iptables/tc in such way :/

Thanks a lot for any advice!
Tomas

Best Answer

Limit bandwidth on the client side with trickle.