Linux Bash Lookup Geo Location From IP
Page 1 of 1
Linux Bash Lookup Geo Location From IP
- Code:
sudo apt-get install -y geoip-bin geoip-database
- Code:
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
gunzip GeoIP.dat.gz
gunzip GeoIPASNum.dat.gz
gunzip GeoLiteCity.dat.gz
sudo cp GeoIP.dat GeoIPASNum.dat GeoLiteCity.dat /usr/share/GeoIP/
geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat 23.66.166.151
Re: Linux Bash Lookup Geo Location From IP
Very Optimized and quick ip lookup
Update Code
https://app.box.com/s/q2h5yjtybtuf5fi2havbbz2po4p8dxdt
You may need to use su
for super user account access before
- Code:
#!/usr/bin/env bash
# sudo apt-get install -y geoip-bin geoip-database
#
# Usage: ./quick_ip_lookup.sh 74.125.225.33
input=$1
#
geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat $input
Update Code
https://app.box.com/s/q2h5yjtybtuf5fi2havbbz2po4p8dxdt
- Code:
#!/usr/bin/env bash
# geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat $input
# ./quick_log.sh
# http://jnet.forumotion.com/post?p=1653&mode=editpost
# http://kbeezie.com/geoiplookup-command-line/
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
You may need to use su
for super user account access before
- Code:
./quick_log.sh
Last edited by jamied_uk on 25th May 2016, 16:12; edited 1 time in total
Re: Linux Bash Lookup Geo Location From IP
PHP Script to do this on a linux server using shell command
- Code:
<center>
<?php
$ip = $_GET['ip'];
$process = shell_exec("geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat $ip");
$rem = array("GeoIP City Edition, Rev 1:", " N/A,");
$rep = "";
echo $process = str_replace($rem,$rep,$process);
echo "<p>";
$new = substr("$process",5,-7);
echo '<p><br><a href="https://www.google.co.uk/maps/search/'.$new.'" target="_blank">Find On Map</a>';
?>
Similar topics
» Loading Bar For Bash In Linux
» Mapping Temp Location for Sort In Linux Command
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Calculating Pi With Bash On Linux
» Mapping Temp Location for Sort In Linux Command
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Calculating Pi With Bash On Linux
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|