unique IP active connections on server 1

unique IP active connections on server

netstat -antu | grep :80 | grep -v LISTEN | awk '{print $5}' | cut -d: -f1 | sort | uniq -c

Here is what the above code is Doing:
1. netstat -antu | grep :80 | grep -v LISTEN
– netstat -antu: This will show all the connections to your server.
– grep :80: This will filter out all the connections that are not on port 80.
– grep -v LISTEN: This will filter out all the connections that are not in the LISTEN state.
2. awk ‘{print $5}’
– awk ‘{print $5}’: This will print the 5th column of the output.
3. cut -d: -f1
– cut -d: -f1: This will cut the output on the colon and print the first field.
4. sort | uniq -c
– sort: This will sort the output.
– uniq -c: This will count the number of times each IP address appears in the output.

Similar Posts