DDOS

How to to check connections count per IPs on cpanel Web Server?

If your server/sites are responding slowly, there could be lots of reasons and one of them is DDOS (Distributed Denial-of-service).  Its very hard to mitigate the attack on shared web server. We try to use different-different netstat commands for all possible attack ports.

But here using following script or command you will get a list of connections per IPs of Apache / POP3 / IMAP / SMTP(25) / SMTP(26) / FTP to stop port flooding.

cmd: netstat -plan | grep :80 | awk {‘print $5’} | grep -Eo “[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}” | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4|uniq -c | sort -nk 1 > /root/1.out; echo “Apache:”; tail -5 /root/1.out; rm -f /root/1.out; netstat -plan | grep :110 | awk {‘print $5’} | grep -Eo “[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}” | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4|uniq -c | sort -nk 1 > /root/2.out; echo “POP3:”; tail -5 /root/2.out; rm -f /root/2.out; netstat -plan | grep :143 | awk {‘print $5’} | grep -Eo “[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}” | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4|uniq -c | sort -nk 1 > /root/3.out; echo “IMAP:”; tail -5 /root/3.out; rm -f /root/3.out; netstat -plan | grep :25 | awk {‘print $5’} | grep -Eo “[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}” | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4|uniq -c | sort -nk 1 > /root/4.out; echo “SMTP(25):”; tail -5 /root/4.out; rm -f /root/4.out; netstat -plan | grep :26 | awk {‘print $5’} | grep -Eo “[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}” | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4|uniq -c | sort -nk 1 > /root/5.out; echo “SMTP(26):”; tail -5 /root/5.out; rm -f /root/5.out; netstat -plan | grep :21 | awk {‘print $5’} | grep -Eo “[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}” | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4|uniq -c | sort -nk 1 > /root/6.out; echo “FTP:”; tail -5 /root/6.out; rm -f /root/6.out

Its very easy to use. Its single line script/command to get all the connections information.

Here is the example for it.

 


HR-ADMIN

Recent Posts

Crafting a Professional Email: Step-by-Step Guide

Due to growing digitalization, Email Communication has become the backbone of professional interactions. Yet, surprisingly, many professionals struggle to craft…

1 day ago

Demystifying SSL: What Every Website Owner Should Know

As the digital landscape continues to evolve, securing your website has never been more crucial. SSL, or Secure Sockets Layer,…

1 week ago

Cyberduck and FileZilla: A Comprehensive Comparison

As a web designer and web developer your experience must have reached to new height, right? Further, you need to…

4 weeks ago

The Science Behind Social Media Posting Times

In today's digital landscape, timing is everything. Whether you're a social media manager, business owner, or content creator, the success…

1 month ago

Mastering Google Search Console: Tips for New Users

Are you a website owner? Maintaining the website is the prime concern for any website owner. Yes, it’s equally important…

1 month ago