Check if your Linux server is Under DDOS Attack or not!

How-to-Check-if-your-Linux-server-is-Under-DDOS-Attack

When your server is under DDoS(Distributed Denial of Service) attack it experiences high inflow of data that depletes the server performance or even leads to server crash. Hence you can login to your server as root and fire the following command, using which you can check if your Linux server is under DDOS attack or not:

netstat -anp |grep ‘tcp\|udp’ | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort –n

This command will show you the list of IP’s which have logged in is maximum number of connections to your server.

ddos becomes more complex as attackers use fewer connections with more number of attacking IP’s. In such cases, you should get less number of connections even when your server is under ddos. One important thing that you should check is the number of active connections that your server currently has. For that execute the following command:

netstat -n | grep :80 |wc –l

The above command will show the active connections that are open to your server.

You can also fire the following command:

netstat -n | grep :80 | grep SYN |wc –l

Result of active connections from the first command will vary but if it shows connections more than 500, then you will be definitely having problems. If the result after you fire second command is 100 or above then you are having problems with sync attack.

Once you get an idea of the ip attacking your server, you can easily block it.

Fire the following command to block that ip or any other specific ip:

route add ipaddress reject

Once you block a particular IP on the server, you can even crosscheck if the IP is blocked or not

by using the following command:

route -n |grep IPaddress

You can also block a IP with iptables on the server by using the following command.

iptables -A INPUT 1 -s IPADRESS -j DROP/REJECT

service iptables restart

service iptables save

After firing the above command, KILL all httpd connection and then restart httpd service by

Using following command:

killall -KILL httpd

Service httpd startssl

Hope this was helpful in detecting DDOS attack on linux server. Stay connected for more updates on  https://www.actsupport.com/blog/

Hope it helps. If you need any assistance Contact Us

Written by actsupp-r0cks