Tag-Archive for » netstat «

Wednesday, October 08th, 2008 | Author: Angelo

Hello,

Below is command to find out number of connections from each ip to server using netstat , sort, uniq, awk.

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

Here is description of Grep used in this command :: Grep is used for sorting lines which are matching for defined pattern but if you want to sort such lines which are matching two or more different pattern then simply define all patterns in single quote and separate them using \| .

Thursday, October 02nd, 2008 | Author: Angelo

Below is command to find out ports which are in use using netstat & cut.

netstat -na | grep 'tcp\|udp' | awk '{print $4}' | cut -d: -f2 | sort | uniq -c | awk '{print $2}'

Below is description of each commands :: Netstat command is used to check all incoming and outgoing connections on linux server. Using Grep command you can sort lines which are matching pattern you defined. AWk is very important command generally used for scanning pattern and process it. It is powerful tool for shell scripting. Sort is used to sort output and sort -n is for sorting output in numeric order. Uniq -c this help to get uniq output by deleting duplicate lines from it.

Category: Linux Commands  | Tags: , , ,  | 16 Comments
Thursday, October 02nd, 2008 | Author: Angelo

Hello,

Below is command to find out number of connections to each port using netstat, cut, awk ,uniq.

netstat -na | grep 'tcp\|udp' | awk '{print $4}' | cut -d: -f2 | sort | uniq -c | awk '{print $2}'

Here, is description for this command so many times you may face trouble because of dos attack in such case you need to find port number (service) on which dos attack is going on above command will help you to search number of connections to each port which is in use.