Most of the software I write is for businesses that have multiple office locations. Even though the software is web based, my clients often want to lock access down so that the software can only be accessed from within one of their offices. We do this by getting the public IP address of each office and allowing only that traffic through. Because I block requests from non-registered IP addresses using PHP, apache will still handle the request. Therefore all user IP addresses will be registered within the /var/log/http/access_log whether they are registered IP addresses or not.
Sometimes you need to see if a specific IP address is trying to access your server. Here’s a handy little bash command that will list all of the IP addresses contained in the current apache log and rank them by the number of times they appear (# of requests they have made).
cat /var/log/http/access_log | awk '{print $1}' | sort | uniq -c | sort -n |
No comments:
Post a Comment