Using netstat to find largest number of established connections
To find out the largest number of established connections you can simply use something like
netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn | head -n 1
3 192.168.1.2
To see the list of the top 10
netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn | head -n 10
2 192.168.1.2
How to view all
netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn
3 192.168.1.2
You can also view all but have pages so you can view each in detail
netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn | more
8 192.168.1.2
You can show the port with:
netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | uniq -c | sort -rn
1 192.168.1.2:58632
1 192.168.1.2:58631
1 192.168.1.2:58629
1 192.168.1.2:58628
1 192.168.1.2:58627
1 192.168.1.2:58613
1 192.168.1.2:55154
1 192.168.1.2:48673
To find out the largest number of established connections you can simply use something like
netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn | head -n 1
To see the list of the top 10
netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn | head -n 10
To view all
netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn
Count the number of connections each IP makes
Use netstat command to calculate and count the number of connections each IP address makes to the server.
netstat -anp |grep ‘tcp\|udp’ | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships