Analyze IP addresses accessing your Apache server

The awk command below retrieves the first column of your apache log file which containsscript the IP address of the browser accessing your host (if you have a virtual host setup with the vhost_combined CustomLog you should retrieve column 2 instead).

After retrieving the column it is sorted and all unique values are determined and counted. After that the list of unique values and there count is sorted (reverse) to get the top list of IP’s.

awk '{ print $1}' $LOGFILE | sort | uniq -c | sort -nr > $DEST

Output of this statement:

606 188.203.177.225
502 84.87.80.237
376 86.81.89.200
365 24.132.181.21
295 94.212.84.128
279 86.81.89.250
251 94.212.208.48
235 85.150.175.72
226 94.212.194.142

 

 

Share

Leave a Reply

Your email address will not be published.