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 \| .

Category: Linux Commands
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response

  1. can be done a bit more efficiently
    netstat -anp | awk ‘/^tcp|^udp/ && $5 !~ “:::*|0.0.0.0″ {sub(”:[0-9]*”,”",$5); print $5| “sort |uniq -c|sort -n”}’

Leave a Reply