Using GeoIPLookup CLI tool's GeoIP database as Smart IP's data source

GeoIPLookup is available in Unix system as command line tool to look up for geolocation using IP address or hostname. It uses the GeoIP database/library usually found in:


When installed and updated, it comes up with Country and City edition databases. It would be nice if Smart IP module is also using same database and this is very useful for Drupal multi sites. We will only maintain one GeoIP database for all Drupal sites and server's GeoIPLookup tool. This article will guide to setup this use case. The following steps are tested running on my Linode server running Centos 7 64-bit. It is assumed that you have already installed Drupal with Smart IP module enabled.

  1. Install the geoip:

    yum install geoip
  2. Initially, only one database is available:

    lrwxrwxrwx.   1 root root      17 Aug 19  2015 GeoIP.dat -> GeoIP-initial.dat
    -rw-r--r--.   1 root root 1362244 Jun 10  2014 GeoIP-initial.dat

    Let's execute the command below to download the Country and City edition databases:


    After the download, output should look something like this:

    /usr/share/GeoIP/GeoLiteCountry.dat can't be opened, proceeding to download database
    Updating /usr/share/GeoIP/GeoLiteCountry.dat
    Updated database
    /usr/share/GeoIP/GeoLiteCity.dat can't be opened, proceeding to download database
    Updating /usr/share/GeoIP/GeoLiteCity.dat
    Updated database
  3. To test the GeoIP Country edition database:

    geoiplookup -f /usr/share/GeoIP/GeoLiteCountry.dat

    Output should be:

    GeoIP Country Edition: PH, Philippines

    To test the GeoIP City edition database:

    geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat

    Output should be:

    GeoIP City Edition, Rev 1: PH, D9, Manila, Manila, 1006, 14.604200, 120.982201, 0, 0
  4. Login to your Drupal site and go to Smart IP admin page ( Under "Select Smart IP Source" select "Use Maxmind binary database", "Lite" for "Maxmind binary database version", "City" for "Maxmind binary database edition", "No" for "Automatic Maxmind binary database update" and enter "/usr/share/GeoIP" for "Maxmind binary database custom path":

    Smart IP admin page GeoIP CLI database setup

  5. Click "Save configuration" button.

  6. To test, enter the IP address "" under "Manual Lookup" and click "Lookup" button:

    Testing GeoIP CLI database as data source

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.