Created
April 3, 2013 18:33
-
-
Save openrijal/5303869 to your computer and use it in GitHub Desktop.
Bash Script to find Geolocation from IP Addresses in apache's access log. You need to have "geoiplookup" package from GeoLite package. The excerpts are taken from http://danielmiessler.com/blog/a-simple-script-for-harvesting-dns-country-state-and-city-information-from-a-list-of-ip-addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cat /var/log/apache2/access_log | awk '{print $1}' > ips.txt | |
uniq ips.txt > uniqips.txt | |
IPS=`cat uniqips.txt` | |
for i in $IPS | |
do | |
echo "$i,`geoiplookup $i | cut -d "," -f2 | sed -e 's/^[\t]//'`" >> ipinfo.csv | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get this output:
xxx.xxx.xxx.xxx, xx.xxx yy.yyy
change the echo line with the following