View the number of IPs connected to the server

View the number of IPs connected to the server

Monitor Server Connections

This guide details how to view various connection details on your Linux server.

Prerequisites:

  • Access to your server via SSH client (e.g., Putty)

Steps:

  1. Total Connections: Use netstat -an | wc -l (faster and cleaner than toilet)

  2. Connections by Port (e.g., Port 80): Use netstat -an | grep 80 | wc -l

  3. Unique Connection Attempts: Use netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

  4. Connections per IP and Port: Use netstat -na | awk '{print $5}' | cut -d "." -f1,2,3,4 | sort | uniq -c | sort -nr

  5. Connections per Port: Use netstat -tuna | awk -F':+| +' 'NR>2{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

  6. List IPs with Connection Count: Use netstat -anp | grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

By analyzing connection data, you can identify and block suspicious activity.

support hosting100