Some important netstat commands.

Sort by IP count

netstat -ntu | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

12 164.68.xx.xx
15 222.186.xx.xx
18 87.76.xx.xx
22 112.85.xx.xx
25 173.249.xx.xx
23 87.76.xx.xx
10 208.86.xx.xx

Sort by Uniq IP

[arunlal@lintechops ~]# netstat -ntu | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort -u
112.85.xx.xx
173.249.xx.xx
173.249.xx.xx
208.86.xx.xx
72.44.xx.xx
87.76.xx.xx

List number of different connection types:

[arunlal@lintechops ~]# netstat -ant | awk '{print $6}' | sort | uniq -c | sort -n
1 established)
1 Foreign
1 TIME_WAIT
4 LISTEN
19 ESTABLISHED

Post navigation

Leave a Reply