What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]

Although the below methods can be used for viewing and apache log, I recommend setting up the excellent GoAccess on your server as outlined here.

Apache logs can show client IP addresses of those machines that access your server.  These logs can aid in debugging and security auditing.

Logs can be quite large though so it isn't usually feasible to go through line by line looking for unique and different IP addresses.

I usually use a reverse-proxy since I might run several applications on a server.  See this guide for an overview of a standard approach to using apache as a reverse proxy.  Assuming such an approach, you can list unique IP addresses in the standard /var/log/apache2/other_vhosts_access.log by:

Debian/Ubuntu
cd /var/log/apache2
cat other_vhosts_access.log | awk '{print $2}' | sort -n | uniq -c | sort -nr
CentOS
cd /var/log/httpd
cat access_log | awk '{print $1}' | sort -n | uniq -c | sort -nr

This will list the number of, and the unique IP addresses from said log.

Viewing lines with a specific IP address

If you want to have a look at log entries with specific IP addresses mentioned therein, you execute:

grep <ipaddress> <log>

Note: replace <ipaddress> and <log> with the ip address you want to see lines for and the log file you want to process.

If there are lots of entries you might want to pipe it to nano (or another text editor) which will make it much easier to read (and search for strings etc).

grep <ipaddress> <log> | nano -

Finding information on specific IP addresses

You can use an IP lookup website to find information about specific IP addresses.  For example:

https://www.infobyip.com/

References