I have a number of uplinks to the internet. Some of them are charged when a bit per second value is exceeded. Some of these links reside on a Linux server. I wanted a way to manage the bandwidth in order to ensure costs are minimized.
stevedoria.net has a nice template to use for performing some traffic management.
tc qdisc add dev eth0 handle ffff: ingress tc filter add dev eth0 parent ffff: protocol ip prio 50 \ u32 match ip src 0.0.0.0/0 police rate 256kbit \ burst 10k drop flowid :1 tc qdisc add dev eth0 root tbf \ rate 256kbit latency 25ms burst 10k
Rate limiting a single host or netmask is another take on the scenario.
Linux Advanced Routing & Traffic Control is the starting point for the documentation.