Here’s how you can find out which IPs are connected to your Linux server, and how many times each IP is connected:
Group by IP:
netstat -ntu | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
Group by IP (but Handle IPv6):
netstat -ntu | awk ' $5 ~ /^(::ffff:|[0-9|])/ { gsub("::ffff:","",$5); print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
Group by IP and Port:
netstat -nt | awk -F":" '{print $2}' | sort | uniq -c