Ubuntu – Iptables block layer 7 DDoS attacks

apache-2.2ddosiptablesUbuntuubuntu-12.04

Recently I've been experiencing lots of layer 7 ddos attacks to my website. Specifically an HTTP GET request flood on the index page. (~20k r/s), my server is at OVH, so it's not overloading the pipe, however is there a way using iptables I can detect IPs who're making excessive requests, and drop their connections to avoid overloading my web server ? Or is there a better solution to filter these packets all the same while not negatively affecting legitimate clients.

I'm using apache, on ubuntu 12.04.

Best Answer

Because HTTP is TCP and TCP requires bi-directional communication, the source addresses of the attacks are actually the attack sources.

Since the sources are known and not spoofed, you can rate-limit in iptables to greatly reduce the request volume per source.

If there are too many sources to get the load manageable that way, you will need to find something about the requests to be able to classify them as droppable, then have your web server drop them. Ideas:

  • Requests all for the same specific resource?
  • Irregular headers (are they not requesting compression? sending HTTP/1.0? sending no cookies when normal users would)
  • Same or predictable user agent?
Related Topic