Is it possible to prevent DDos Attack by cpanel configuration and php scripting?

Ahmad picture Ahmad · Jul 30, 2012 · Viewed 10.7k times · Source

My site is under DDos Attacks (UDP Flooding)!

I have no access to linux shell and only cpanel is available for me! :(

Is it possible to prevent this attacks by php scripting?

Is there a way to configure cpanel to reduce or redirect attacks? How?

According to web hosting help desk: Attack is between 6 to 10 Gbit/s !!!

Is the following code useful?

 <?PHP 

 if (!isset($_SESSION)) { session_start(); }
 // anti flood protection 
 IF($_SESSION['last_session_request'] > time() - 2){ 
 // users will be redirected to this page if it makes requests faster than 2 seconds 
  header("Location: /flood.html");
 exit; } 
 $_SESSION['last_session_request'] = time(); 


 ?>

Hardware firewall is too expensive.

Answer

Exos picture Exos · Jul 31, 2012

First, if you are under attack, protect by sessions is not effective.

Second, if you implements an anti-dos method under php, you are adding process, and the DOS attack is ever effective.

The web server listen on TCP protocol, a udp attack is to the server, no your site, prevent the attack is on side of the server, a.k.a, your hosting provider.

Sorry my english