Welcome to Server Circle. It's a friendly site and all levels of experience are welcome. Be aware that we use cookies for your login.
Server Circle - Ask questions about Servers and get answers from experts.
Beta (0.39 sec)
Traffic shaping for Linux using tc

I want to be able to control how much inbound traffic the IPs on my Server receive (I've replaced the IP with one from a private range in the example below).

DEV=eth0

tc qdisc del dev $DEV handle ffff: ingress

tc qdisc add dev $DEV handle ffff: ingress

tc filter add dev $DEV parent ffff: protocol ip prio 1 u32 match ip dst 10.10.10.10 police rate 1Mbit burst 250k drop flowid :111


This seems to work just fine but when I drop the 1Mbit parameter in tc to anything less than 256kbps the results go all screwy. Any fixes ? Is this just perculiar to the ingress qdisc ?
Asked by:
Moocher
625 points
 Report Abuse
 Share Page - Category: Networking - Tags: Traffic shaping for Linux using tc
 Enter your response
Please use Pastie.org to paste lengthy code or to fix formatting issues with code
  • Responses in reverse (3)

Best Answer

Your burst value may be too high. Ideally it should be somewhere between 10k and 100k, depending on the rate of traffic you want. I'd say try around 15k for 1Mbps of traffic. I normally reserve the full 100k for more than about 250Mbps of traffic.

However, if your worried about DoS attacks, this will not stop it, as it will only protect the services on the server from receiving too much traffic. The traffic will have already reached the server and if it's flooding your port, then this will not help.

Response by:
jonathan
335 points
It seems that tc is not much good at throttling low values after lots of testing, not to worry 256kbps is pretty low these days and that works fine.

Response by:
Moocher
625 points
Do you reduce the burst while you reduce the rate? Having a large burst might cause bad interference with the TCP congestion algorithm (wild guess).

Do you really need to do that on the ingress? You could also mark packets coming from eth0 and use that as a basis for classifying on the egress discipline of the interface where 10.10.10.10 is to be reached via. That would mean you could do shaping rather than policing.

You may also want to consider IMQ instead. You could also try using just iptables -m limit.

Response by:
s
3383 points


  • Related Questions
About Us : Contact Us : Etiquette : Terms : CDN Failover : ShorterURL : CDN Fallback : © 2013 Server Circle