Create your blog and photo album with postbit
Create your blog and photo album

Create new post


Upload a picture:
Tags (keywords separated by comma)

Save Cancel
webtools:   Followers: 10 ; Following: 2

Explore webtools's photo albums:
Photos from posts (2)
Photos from posts (2)

GeoIP - locating IP country and city

GeoIP2 Precision give more city results that were not available in free version.

For example, the GeoIP2 Precision says that IP "" is from the city Ipero, region Sao Paulo, Brazil, ISP and Organization "virtua" (domain, postal code 18560, coordinates (-23.35, -47.6833).
You can test individual IP's using the geoip demo page:

And the free version only finds the country (Brazil).

Free GeoIP database download:
GeoLite2 City (GeoLite2-City.mmdb and .csv)
GeoLite2 Country (GeoLite2-Country.mmdb and .csv)

Sample content of GeoLite2-City-Blocks.csv (first line is header with file format / file structure and following lines are sample data). Size of complete file is 182 Mb:
Sample content of GeoLite2-City-Locations.csv (first line is header / file structure). Size of complete file is 6.4 Mb:
Other GeoIP database (samples):
Available sample files to download:
The full GeoIP Organization (ISP list) costs $25:
The full GeoIP2 City database costs $370:
I downloaded the binary files (free version):
GeoIP.dat (719 kb, contains only country code data) and GeoLiteCity.dat (18 MB, contains country, region and city information)
Note that some IPs can not be found, not even in the Geo IP Precision database.
Example: "The IP address you provided ( cannot be found in our database." (error from maxmind demo site)

How to install Geo::IP (installing and using perl Geo::IP CPAN module):

1) Download Geo IP databases:

 Download page 'GeoLite Country' with updated version of GeoIP.dat.gz:
 gunzip GeoIP.dat.gz; gunzip GeoLiteCity.dat.gz;
 mkdir /usr/local/share/GeoIP
 ln -s GeoIP.dat /usr/local/share/GeoIP/GeoIP.dat
GEOIP TEST SCRIPT (returns country code, 2 letters):
/usr/local/bin/geoip-lookup (IP number)
2) Download and install C API (CAPI):
 make install
3) install Geo::IP perl module from CPAN:
# Not needed: Geo::IP::PurePerl
# If you ge the error "The GeoIP CAPI is not installed you should do that", then install manually. Type in CPAN prompt:
look Geo::IP
cd (path to Geo::IP downloaded source)
perl Makefile.PL LIBS='-L/usr/local/lib' INC='-I/usr/local/include';
make test
make install
If you get the error:  "fatal error: GeoIP.h: No such file or directory", then you need to install the Geo IP C API (CAPI) in step 2 above, because it contains the required libs to compile Geo::IP.

Post by webtools (2014-08-29 12:22)

Post your comment:

Name: Email: Site:

| Explore users | New posts | Create your blog | Create your photo album |
| About Postbit | Our blog | Terms of use | Contact Postbit |

Copyright © 2018 -