IP to Country Lite CSV format

Details of the IP to Country Lite database CSV file downloads

IP to Country Lite database CSV format

The format used in the IP to Country Lite CSV database exports is compliant with the specification in RFC4180 : Common Format and MIME Type for Comma-Separated Values (CSV) Files.

The character encoding is standard Unicode UTF-8.


The IP to Country Lite database downloads in the Comma Separated Values format contain the following fields :

1  ip_start
First IP address in the block
2  ip_end
Last IP address in the block
3  country
ISO 3166-1 alpha-2 country code

Sample row for the IP to Country Lite CSV file :,,US

How To

This packages contains the core DB-IP class, a CSV database import tool, and sample lookup code.

Here are the few steps needed to import a CSV file into your local database instance using the tools above :

Create a database table

The first step is to create a new database table to hold the imported data.

If you are updating an already populated and running database, it is recommended you create a new table and use an atomic rename to switch the old with the new once the import is finished.

This is the MySQL table creation statement for the IP to Country Lite lookup table needed by our supported query library and import tool :

CREATE TABLE `dbip_lookup` (
  `addr_type` enum('ipv4','ipv6') NOT NULL,
  `ip_start` varbinary(16) NOT NULL,
  `ip_end` varbinary(16) NOT NULL,
  `country` char(2) NOT NULL,
  PRIMARY KEY (`addr_type`,`ip_start`)

Use the import tool to load the database

The source code package above contains a script named import.php, it is meant to be run on the command line and requires that either a PHP binary (php-cli or php-cgi) or the HHVM binary is installed :

When run without arguments, import will output its usage details :

~$ ./import.php
usage: ./import.php -f <filename.csv[.gz]> [-d <country|city|location|isp|full>] [-b <database_name>] [-t <table_name>] [-u <username>] [-p <password>]

Example command line for the IP to Country database :

~$ ./import.php -f dbip-country-lite-2024-05.csv.gz -b myapp -t dbip_lookup
finished importing 537879 records

The process can take some time depending on your database instance performance, a typical import of the full Location + ISP database should not take more than 30 minutes.

Other resources

These packages are not maintained by the DB-IP team but we have selected them because they provide added functionnality or language support.


ZORAN.DB.IP.Importer is a tool that imports into Microsoft SQL Server the freely available geolocation database offered by



Geocode IP addresses with a single Ruby if statement. No network access, no context switches, no delay, just one low-calorie lookup like Geolocal.in_spain?(request.remote_ip).

500,000 individual lookups per second is fairly typical performance.



This project leverages a simple Java webapp that acts as a wrapper around the geoip databases.


Java DB-IP

A simple to use Java library for the freely available DB-IP IP address to city dataset. Requires Java 8

  Java DB-IP


  Back to IP to Country Lite