Display all connections grouped by IP and port

These commands generate a table with 3 columns:
1 – local IP and port
2 – remote IP
3 – number of connections

netstat -nptcp 2>/dev/null | egrep -v 'Active|Address|sockets' \ | awk '{print ($4, $5)}' | cut -d. -f 1-8 | sort | uniq -ci \ | sort | awk '{printf "%-18s\t\t%-18s\t\t%s\n",$2,$3,$1}' | sort

The above netstat parameters are valid for FreeBSD and can differ in other OSes.

Leave comment

 

Notify of new comments using RSS