Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com
Stopping a DDOS (distributed denial of service attack) or DOS (denial of service attack) is no simple task.  Frequently, these attacks become more than just a nuisance, they completely immobilize your server's services and keep your users from using your website.

We've found a few common sense ways to help ease the pain of DDOS and/or DOS attacks.  While no method is fool proof, we certainly can minimize the profound effect these attacks have on your users and subsystems.
Identify the Source

Good luck with that one.  Many DDOS and DOS attacks are from roaming IP addresses.  A distributed denial of service attack can come from many different IP addresses and it quickly becomes impossible for the Linux system administrator to isolate and confine each IP with a firewall rule.

Wikipedia does a great job of describing the various types of attacks here: http://en.wikipedia.org/wiki/Denial-of-service_attack.  For the purpose of this tutorial, I'll leave the research on the types of attacks up to you, and address the most common form that we've encountered over the years, the Apache directed DDOS or DOS attack.
Apache Based Attacks

Symptoms of the Apache DDOS or DOS attack:

  • Website(s) serve slow
  • You notice hanging processes
  • Apache Top tells you that the same IP address is requesting a system resource
  • The system resource continues to multiplex, causing more processes to spawn
  • The Command:
  • netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
  • Says that you have a few too many connections to feel comfortable with.

The end result:

  • Apache goes down
  • System load goes sky high
  • Server stops responding
  • You cant ssh to the server node
  • You've lost connectivity completely and a reboot is mandatory in order to restore access to the system

Preventative Measures and Counter Measures:

  • Enable SYN COOKIES at the kernel level
  • echo 1 > /proc/sys/net/ipv4/tcp_syncookies
  • Enable and Configure iptables to prevent the attack or at least work to identify the attack
  • /sbin/iptables -N syn-flood
  • /sbin/iptables -A syn-flood -m limit --limit 100/second --limit-burst 150 -j RETURN
  • /sbin/iptables -A syn-flood -j LOG --log-prefix "SYN flood: "
  • /sbin/iptables -A syn-flood -j DROP

 

Install the APF firewall to work to identify risky behavior
APF stands for Advanced Policy Firewall.  Its a rock solid firewall that normally plays nice with iptables.  You can grab a the most recent copy here: http://www.rfxn.com/projects/

Install (D)DosDeflate
Great software, rock solid, and plays nice with either APF or iptables.  Install and configure the service in seconds using the commands below.  Edit the .conf file to utilize whichever flavor of firewall you'd like to integrate it with.  Set a few configuration settings and you're done.

To Install (D)DosDeflate:

  • wget http://www.inetbase.com/scripts/ddos/install.sh
  • chmod 0700 install.sh
  • ./install.sh

If it doesnt workout, its simple to uninstall too.  To uninstall:

  • wget http://www.inetbase.com/scripts/ddos/uninstall.ddos
  • chmod 0700 uninstall.ddos
  • ./uninstall.ddos


So a few tools are outlined above.  We've found that this will stop 90% of the attacks that are out there.  Some nice firewall rules above your server (at the router or switch level) also help.  Most of the time we can identify suspicious traffic before it even hits your servers, so a shameless plug here is probably in order.

This has been sourced: http://www.liquidcomm.net/siterun_data/news/tech_tips/linux_os/How-to-manage-a-DDOS-or-DOS-attempt-directed-at-your-linux-server.html

Was this answer helpful? 222 Users Found This Useful (509 Votes)

Powered by WHMCompleteSolution