Database downloads

Seamlessly integrate the DB-IP database with your application.

With more than 13 million IPv4 and IPv6 blocks, the DB-IP database is one of the most comprehensive and accurate IP geolocation databases available today.

Every month, hundreds of thousands of records are added or updated, and we're always working hard to improve the coverage of our database and its accuracy.

Here you will find everything you need to seamlessly integrate the DB-IP database with your application.



Database downloads


  IP address to countryIP address to cityIP address to locationIP address to ISPIP address to location + ISP
Country
State/Province**
City**
Latitude/Longitude
Timezone
ISP name
Connection type*
Organization
EditionDecember 2016December 2016December 2016December 2016December 2016
Number of records474,0109,231,96912,012,2987,147,05313,708,050
Size (uncompressed)21 MB608 MB1,448 MB529 MB2,279 MB
Price***--$107$107$203
Free updates--12 months12 months12 months
   Free  Free  Buy Now  Buy Now  Buy Now

* when available
** lower precision than the IP-location database
*** approximation based on the latest exchange rates, final price is determined by PayPal



File formats and SQL scripts



The IP to Country database downloads are in the Comma Separated Values format, with the following fields :

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

This is the MySQL table creation statement for the IP to Country lookup table needed by our provided code :

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`)
);

The IP to City database downloads are in the Comma Separated Values format, with the following fields :

ip_start
First IP address in the block
ip_end
Last IP address in the block
country
ISO 3166-1 alpha-2 country code
stateprov
State or province name
city
City name

This is the MySQL table creation statement for the IP to City lookup table needed by our provided code :

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,
  `stateprov` varchar(80) NOT NULL,
  `city` varchar(80) NOT NULL,
  PRIMARY KEY (`addr_type`,`ip_start`)
);

The IP to Location database downloads are in the Comma Separated Values format, with the following fields :

ip_start
First IP address in the block
ip_end
Last IP address in the block
country
ISO 3166-1 alpha-2 country code
stateprov
State or province name
district
District or county name
city
City name
zipcode
Zip (postal) code
latitude
Decimal latitude
longitude
Decimal longitude
geoname_id
Unique identifier of the location in the GeoNames database
timezone_offset
Offset from UTC in hours
timezone_name
Name of timezone

This is the MySQL table creation statement for the IP to Location lookup table needed by our provided code :

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,
  `stateprov` varchar(80) NOT NULL,
  `district` varchar(80) NOT NULL,
  `city` varchar(80) NOT NULL,
  `zipcode` varchar(20) NOT NULL,
  `latitude` float NOT NULL,
  `longitude` float NOT NULL,
  `geoname_id` int(11) DEFAULT NULL,
  `timezone_offset` float NOT NULL,
  `timezone_name` varchar(64) NOT NULL,
  PRIMARY KEY (`addr_type`,`ip_start`)
);

The IP to ISP database downloads are in the Comma Separated Values format, with the following fields :

ip_start
First IP address in the block
ip_end
Last IP address in the block
country
ISO 3166-1 alpha-2 country code
isp_name
Internet Service Provider name
connection_type
Connection type (dialup, isdn, cable, dsl, fttx, wireless)
organization_name
Organization name

This is the MySQL table creation statement for the IP to ISP lookup table needed by our provided code :

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,
  `isp_name` varchar(128) NOT NULL,
  `connection_type` enum('dialup','isdn','cable','dsl','fttx','wireless') DEFAULT NULL,
  `organization_name` varchar(128) NOT NULL,
  PRIMARY KEY (`addr_type`,`ip_start`)
);

The IP to Location + ISP database downloads are in the Comma Separated Values format, with the following fields :

ip_start
First IP address in the block
ip_end
Last IP address in the block
country
ISO 3166-1 alpha-2 country code
stateprov
State or province name
district
District or county name
city
City name
zipcode
Zip (postal) code
latitude
Decimal latitude
longitude
Decimal longitude
geoname_id
Unique identifier of the location in the GeoNames database
timezone_offset
Offset from UTC in hours
timezone_name
Name of timezone
isp_name
Internet Service Provider name
connection_type
Connection type (dialup, isdn, cable, dsl, fttx, wireless)
organization_name
Organization name

This is the MySQL table creation statement for the IP to Location + ISP lookup table needed by our provided code :

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,
  `stateprov` varchar(80) NOT NULL,
  `district` varchar(80) NOT NULL,
  `city` varchar(80) NOT NULL,
  `zipcode` varchar(20) NOT NULL,
  `latitude` float NOT NULL,
  `longitude` float NOT NULL,
  `geoname_id` int(11) DEFAULT NULL,
  `timezone_offset` float NOT NULL,
  `timezone_name` varchar(64) NOT NULL,
  `isp_name` varchar(128) NOT NULL,
  `connection_type` enum('dialup','isdn','cable','dsl','fttx','wireless') DEFAULT NULL,
  `organization_name` varchar(128) NOT NULL,
  PRIMARY KEY (`addr_type`,`ip_start`)
);


Officially supported source code

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

They are available for the following platforms :


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.

The table structure depends on the database edition you have downloaded, it is either IP to Country, City, Location, ISP or Location + ISP and you will find a schema for each one at the paragraph above : File formats and SQL scripts.


Use the import tool to load the database

This package contains a script named import.php or import.hh, 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-2016-10.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.



External links

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

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

ZORAN.DB.IP.Importer at GitHub


Geolocal

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.

Geolocal at GitHub


geoip-dbip-rest-api

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

geoip-dbip-rest-api at GitHub


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 at GitHub

Spring-Boot-DB-IP at GitHub

search