GeoIP can be used in your server to locate and track visitors visiting your webpage. GeoIP provide valuable knowledge about your Internet visitors seamlessly and in real-time.GeoIP is a package used to determine the geographical location and other information
like client’s region, city, longitude/latitude, connection speed, ISP,
as well as company name.
Given below are the steps to install GeoIP:
[hari]$ sudo apt-get install geoip-bin
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
geoip-bin
0 upgraded, 1 newly installed, 0 to remove and 131 not upgraded.
Need to get 15.3 kB of archives.
After this operation, 119 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
geoip-bin
Install these packages without verification [y/N]? y
Get:1 http://archive.ubuntu.com/ubuntu/ natty/universe geoip-bin i386 1.4.7~beta6+dfsg-1 [15.3 kB]
Fetched 15.3 kB in 1s (11.3 kB/s)
Selecting previously deselected package geoip-bin.
(Reading database ... 538222 files and directories currently installed.)
Unpacking geoip-bin (from .../geoip-bin_1.4.7~beta6+dfsg-1_i386.deb) ...
Processing triggers for man-db ...
Setting up geoip-bin (1.4.7~beta6+dfsg-1) ...
When we install wordpress we get a sample wp-config file. Similarly we get a geoip sample configuration file at the following location.
/etc/GeoIP.conf.default
Rename it to make it your configuration file.
[hari]$ mv /etc/GeoIP.conf.default /etc/GeoIP.conf
Now open the file /etc/GeoIP.conf using your favorite editor to enter the user_id and license information.
[hari]$ vim /etc/GeoIP.conf
# If you purchase a subscription to the GeoIP database,
# then you will obtain a license key which you can
# use to automatically obtain updates.
# for more details, please go to
# http://www.maxmind.com/app/products
# see https://www.maxmind.com/app/license_key_login to obtain License Key,
# UserId, and available ProductIds
# Enter your license key here
LicenseKey
# Enter your User ID here
UserId
# Enter the Product ID(s) of the database(s) you would like to update
# By default 106 (MaxMind GeoIP Country) is listed below
You can also use GeoIP without purchasing license from the maxmind but it provides only limited support.
Sample Output
[hari]$ geoiplookup 8.8.4.4
GeoIP Country Edition: US, United States