Linux Commands

How to list connections on the server with netstat command

netstat
netstat

List connections on the server with netstat command

You can find the connections on the server using netstat command. This will help us to determine if the server is under DDOS attack.

 
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

An example output of the mentioned command is given below:

 
 2 177.177.215.117
 2 207.46.13.148
 2 62.212.75.234
 2 66.249.78.201
 2 68.180.229.109
 2 86.98.48.85
 3 86.96.48.123
 6 122.174.220.250
 9 108.162.229.84
 10 141.101.89.173
 13 220.227.139.194

That’s it!

Read More:

If you like this post and wish to receive more articles from us, please like our FB page: Grepitout

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at [email protected]

3 Comments

Click here to post a comment

  • This is a good utility, but there are some issues:
    1) The output of the netstat -ntu command has 2 header lines that should be ignored
    2) An IPV6 address contains “:” characters inside and is handled incorrect.

    I have reworked your idea and handle IPV4 and IPV6 in two commands. Here is my solution:

    netstat -ntu -v4 | awk ‘{if (NR > 2) print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
    netstat -ntu -v6 | awk ‘{if (NR > 2) print $5}’ | cut -d: -f1-5 | sort | uniq -c | sort -n

    Best regards
    Karel

  • My name is Luka Chachibaia, I am a citizen of Ukraine and the Vice President Operations of Tethys Petroleum, a multi national oil corporation operating from London-England, UK. I am seeking your assistance to retrieve the sum of($40,000.000) Forty Million Dollars in a bank in the US. this money was acquired from the company and it was in a bank in the U.S.A, my reason for this is because I have been cheated out of my entitlements by the company for too long simply because I am not a British. The contact details of the bank will be given to you if you indicate your interest to help me

    For your help I am ready to release 30% to you, The money has been there for the pass 4 month while I intend to look for a reliable partner. I will be leaving the country immediately you have the Forty Million Dollars for my private investment and I have vowed never to step back into London, England. Please, I need your urgent response before my plans to leave the company is discovered.

    Right now the safest form of correspondence is through my own e-mail address, please in the interest of confidentiality only reply through my direct email address.Reply along with your direct phone and fax number where I can alternatively reach you on

    Please if you are not willing and interested in helping me kindly delete this email from your email and pretend you never got it. For security reasons, i am not going to discuss this on my official social media and other platforms. This is email is private and i will schedule a phone call to you when i hear from you.

    Best regards,

    Mr.Luka Chachibaia
    Vice President Operations
    Tethys Petroleum
    London, England

Topics