Check all connected IP on certain port - MdNor/rocksoft GitHub Wiki

Check all IP connected to port 80

netstat -tn 2>/dev/null | grep :80 | awk '{print }' | cut -d: -f1 | sort | uniq -c | sort -nr | head

-n = Display numeric only, don’t resolve into name.

-t = Display only TCP connections.

2>/dev/null = Redirect all unwanted output to /dev/null.

grep :80 = Only display the IP address that connected to server on port 80.

awk '{print }' = Uses awk to display the 5th field only.

cut -d: -f1 = Uses cut to extract the content.

-d = Character immediately following the -d option is use as delimiter, default is tab.

-f = Specifies a field list, separated by a delimiter.

sort | uniq -c | sort -nr = Sort the list, group it and sort it again in reverse order.

head = display first 10 only

source