/geoip-ip2country

Translates IP address to country using the GeoIP (GeoLite Country) database

geoip-ip2country

EXPLANATION
 ``ip2country'' runs through the GeoIPCountry.csv (very fast) and returns the country full name based on the IP address provided.

 It's useful for open source projects where you want to easily and accurately work out the client's country based on IP Address without having to have a commercial paid license for GeoIP.

 It is arguably better than using a language such as PHP because the CSV file is very large and this allows for quick look up from the database file.

 The other benefit of this approach is that it doesn't make a WHOIS lookup or have to do any DNS calls.

INSTALL
 gcc ip2country.c -o ip2country

USAGE
 ./ip2country <IP ADDRESS>

EXAMPLE
 $ ./ip2country 4.2.2.2
 United States

EXAMPLE - PHP
 <?php
  $country = system("./ip2country 4.2.2.2");
  echo("$country");
 ?>

REQUIREMENTS
 ``ip2country'' must be run in the same folder as GeoIPCountry.csv.

This databse can be downloaded from the GeoIP database (http://dev.maxmind.com/geoip/legacy/geolite/)

You can download this to your current directory using:

$ wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
$ unzip GeoIPCountryCSV.zip