Netstat to to find number of connections from each IP

来源:互联网 发布:最会写文案的淘宝店 编辑:程序博客网 时间:2024/06/06 09:46

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


if you want to create a hyperlink in command, you have to use only "ln" instead of "in -s" otherwise you will only create a symbol link of the shell.