Networking Commands

Show number of connections per IP

netstat -ntu | tail -n +3| awk '{ print $5}' | cut -d : -f 1 | sort | uniq -c| sort -n -r
or
netstat -ntu | awk '{ print $5}' | cut -d : -f 1 | sort | uniq -c| sort -n -r

Show all connected IPs

netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq

Show number of connections by state

netstat -nat | tail -n +3 | awk '{print $6}' | sort | uniq -c | sort -n
or
netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n

Show number of connections

netstat -an | grep ESTABLISHED | wc -l
or
sudo ss -s

Show ports and programs associated with the open ports

netstat -A inet -p
or
ss -utp

Previous page: Linux Network Tuning
Next page: PPPoE Setup