Apache Count number of unique ip’s

So you want to know how many different ip’s have been hitting your apache server?

 

It’s simple to do first locate your logs normally in /var/log/httpd/access_log (redhat)

 

Look at the log and identify which field is the ip address in ours it’s the first entry so we will use $1 (if it’s the second replace with $2)

 

cat /var/log/httpd/access_log | awk ‘{print $1}’ | sort | uniq | wc -l

 

This will output a count of unique hits.  You can also get a list with:

cat /var/log/httpd/access_log | awk ‘{print $1}’ | sort | uniq

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.