Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Stop DDoS attack using IPTables  (Read 1211 times)

0 Members and 1 Guest are viewing this topic.

joseletk

  • Guest
Stop DDoS attack using IPTables
« on: April 21, 2018, 11:22:00 am »
A distributed denial of service attack (or DDoS) will either bring your server down or significantly degrade its performance. This article explains a quick way to tackle the problem.

The IPTables firewall rules that follow ensure packets are limited to a set number per period of time. This rule will ensure only 10 new requests can hit the server in a 20 second period. It won’t stop the attack but it will keep your server up.

Code: [Select]
iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m recent --update --seconds 20 --hitcount 10 -j DROP

The above is ideal for a web server. However, you can apply this to any port. I’d suggest not to use this for SSH as you’ll also limit your ability to administer the server.

Also, you can use this on a router/proxy in-front of the server by changing INPUT to FORWARD.
===========================================================================