Get Started with IP2Location DB26 Database
IP2Location DB26 Database offers an IP geolocation solution to identify the country, region or state, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type, IAB category and ASN of IP address.
Licensing
There are 3 subscription license types available.
- Standard License - $9,999 per server (Internal Use)
- Site License - $99,980 for unlimited servers (Internal Use)
- SaaS / Redistribution License - Contact us for pricing
Download Database
After checkout the database, you can download it from your IP2Location account or from DB26 product page.
Import Database
You can import your database file to your application based on different use cases.
Create The IPv4 SQL Table
Sample Code
CREATE DATABASE ip2location;
USE ip2location;
CREATE TABLE `ip2location_db26`(
`ip_from` INT(10) UNSIGNED,
`ip_to` INT(10) UNSIGNED,
`country_code` CHAR(2),
`country_name` VARCHAR(64),
`region_name` VARCHAR(128),
`city_name` VARCHAR(128),
`latitude` DOUBLE,
`longitude` DOUBLE,
`zip_code` VARCHAR(30),
`time_zone` VARCHAR(8),
`isp` VARCHAR(256),
`domain` VARCHAR(128),
`net_speed` VARCHAR(8),
`idd_code` VARCHAR(5),
`area_code` VARCHAR(30),
`weather_station_code` VARCHAR(10),
`weather_station_name` VARCHAR(128),
`mcc` VARCHAR(256),
`mnc` VARCHAR(256),
`mobile_brand` VARCHAR(128),
`elevation` INT(10),
`usage_type` VARCHAR(11),
`address_type` CHAR(1),
`category` VARCHAR(10),
`district` VARCHAR(128),
`asn` VARCHAR(10),
`as` VARCHAR(256),
PRIMARY KEY (`ip_to`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE DATABASE ip2location
GO
USE ip2location
GO
CREATE TABLE [ip2location].[dbo].[ip2location_db26](
[ip_from] bigint NOT NULL,
[ip_to] bigint NOT NULL,
[country_code] nvarchar(2) NOT NULL,
[country_name] nvarchar(64) NOT NULL,
[region_name] nvarchar(128) NOT NULL,
[city_name] nvarchar(128) NOT NULL,
[latitude] float NOT NULL,
[longitude] float NOT NULL,
[zip_code] nvarchar(30) NOT NULL,
[time_zone] nvarchar(8) NOT NULL,
[isp] nvarchar(256) NOT NULL,
[domain] nvarchar(128) NOT NULL,
[net_speed] nvarchar(8) NOT NULL,
[idd_code] nvarchar(5) NOT NULL,
[area_code] nvarchar(30) NOT NULL,
[weather_station_code] nvarchar(10) NOT NULL,
[weather_station_name] nvarchar(128) NOT NULL,
[mcc] nvarchar(256) NOT NULL,
[mnc] nvarchar(256) NOT NULL,
[mobile_brand] nvarchar(128) NOT NULL,
[elevation] int NOT NULL,
[usage_type] nvarchar(11) NOT NULL,
[address_type] nvarchar(1) NOT NULL,
[category] nvarchar(10) NOT NULL,
[district] nvarchar(128) NOT NULL,
[asn] nvarchar(10) NOT NULL,
[as] nvarchar(256) NOT NULL
) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [ip_to] ON [ip2location].[dbo].[ip2location_db26]([ip_to]) ON [PRIMARY]
GO
CREATE DATABASE ip2location WITH ENCODING 'UTF8';
\c ip2location
CREATE TABLE ip2location_db26(
ip_from bigint NOT NULL,
ip_to bigint NOT NULL,
country_code character(2) NOT NULL,
country_name character varying(64) NOT NULL,
region_name character varying(128) NOT NULL,
city_name character varying(128) NOT NULL,
latitude real NOT NULL,
longitude real NOT NULL,
zip_code character varying(30) NOT NULL,
time_zone character varying(8) NOT NULL,
isp character varying(256) NOT NULL,
domain character varying(128) NOT NULL,
net_speed character varying(8) NOT NULL,
idd_code character varying(5) NOT NULL,
area_code character varying(30) NOT NULL,
weather_station_code character varying(10) NOT NULL,
weather_station_name character varying(128) NOT NULL,
mcc character varying(256) NOT NULL,
mnc character varying(256) NOT NULL,
mobile_brand character varying(128) NOT NULL,
elevation integer NOT NULL,
usage_type character varying(11) NOT NULL,
address_type character(1) NOT NULL,
category character varying(10) NOT NULL,
district character varying(128) NOT NULL,
asn character varying(10) NOT NULL,
as character varying(256) NOT NULL,
CONSTRAINT ip2location_db26_pkey PRIMARY KEY (ip_to)
);
Create The IPv6 SQL Table
Sample Code
CREATE DATABASE ip2location;
USE ip2location;
CREATE TABLE `ip2location_db26`(
`ip_from` DECIMAL(39,0) UNSIGNED,
`ip_to` DECIMAL(39,0) UNSIGNED,
`country_code` CHAR(2),
`country_name` VARCHAR(64),
`region_name` VARCHAR(128),
`city_name` VARCHAR(128),
`latitude` DOUBLE,
`longitude` DOUBLE,
`zip_code` VARCHAR(30),
`time_zone` VARCHAR(8),
`isp` VARCHAR(256),
`domain` VARCHAR(128),
`net_speed` VARCHAR(8),
`idd_code` VARCHAR(5),
`area_code` VARCHAR(30),
`weather_station_code` VARCHAR(10),
`weather_station_name` VARCHAR(128),
`mcc` VARCHAR(256),
`mnc` VARCHAR(256),
`mobile_brand` VARCHAR(128),
`elevation` INT(10),
`usage_type` VARCHAR(11),
`address_type` CHAR(1),
`category` VARCHAR(10),
`district` VARCHAR(128),
`asn` VARCHAR(10),
`as` VARCHAR(256),
PRIMARY KEY (`ip_to`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE DATABASE ip2location
GO
USE ip2location
GO
CREATE TABLE [ip2location].[dbo].[ip2location_db26](
[ip_from] char(39) NOT NULL,
[ip_to] char(39) NOT NULL,
[country_code] nvarchar(2) NOT NULL,
[country_name] nvarchar(64) NOT NULL,
[region_name] nvarchar(128) NOT NULL,
[city_name] nvarchar(128) NOT NULL,
[latitude] float NOT NULL,
[longitude] float NOT NULL,
[zip_code] nvarchar(30) NOT NULL,
[time_zone] nvarchar(8) NOT NULL,
[isp] nvarchar(256) NOT NULL,
[domain] nvarchar(128) NOT NULL,
[net_speed] nvarchar(8) NOT NULL,
[idd_code] nvarchar(5) NOT NULL,
[area_code] nvarchar(30) NOT NULL,
[weather_station_code] nvarchar(10) NOT NULL,
[weather_station_name] nvarchar(128) NOT NULL,
[mcc] nvarchar(256) NOT NULL,
[mnc] nvarchar(256) NOT NULL,
[mobile_brand] nvarchar(128) NOT NULL,
[elevation] int NOT NULL,
[usage_type] nvarchar(11) NOT NULL,
[address_type] nvarchar(1) NOT NULL,
[category] nvarchar(10) NOT NULL,
[district] nvarchar(128) NOT NULL,
[asn] nvarchar(10) NOT NULL,
[as] nvarchar(256) NOT NULL
) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [ip_to] ON [ip2location].[dbo].[ip2location_db26]([ip_to]) ON [PRIMARY]
GO
CREATE DATABASE ip2location WITH ENCODING 'UTF8';
\c ip2location
CREATE TABLE ip2location_db26(
ip_from decimal(39,0) NOT NULL,
ip_to decimal(39,0) NOT NULL,
country_code character(2) NOT NULL,
country_name character varying(64) NOT NULL,
region_name character varying(128) NOT NULL,
city_name character varying(128) NOT NULL,
latitude real NOT NULL,
longitude real NOT NULL,
zip_code character varying(30) NOT NULL,
time_zone character varying(8) NOT NULL,
isp character varying(256) NOT NULL,
domain character varying(128) NOT NULL,
net_speed character varying(8) NOT NULL,
idd_code character varying(5) NOT NULL,
area_code character varying(30) NOT NULL,
weather_station_code character varying(10) NOT NULL,
weather_station_name character varying(128) NOT NULL,
mcc character varying(256) NOT NULL,
mnc character varying(256) NOT NULL,
mobile_brand character varying(128) NOT NULL,
elevation integer NOT NULL,
usage_type character varying(11) NOT NULL,
address_type character(1) NOT NULL,
category character varying(10) NOT NULL,
district character varying(128) NOT NULL,
asn character varying(10) NOT NULL,
as character varying(256) NOT NULL,
CONSTRAINT ip2location_db26_pkey PRIMARY KEY (ip_to)
);
Import The Database into MS-SQL/MySQL/PostgreSQL/Microsoft Access Database
Sample Code
LOAD DATA LOCAL
INFILE \'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN.CSV\'
INTO TABLE
`ip2location_db26`
FIELDS TERMINATED BY \',\'
ENCLOSED BY \'"\'
LINES TERMINATED BY \'\r\n\';
BULK INSERT [ip2location].[dbo].[ip2location_db26]
FROM \'C:\\[path to your CSV file]\\IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN.CSV\'
WITH
(
FORMATFILE = \'C:\\[path to your db26.FMT file]\\DB26.FMT\'
)
GO
SQL Server 2017 or later (IPv6) can import without FMT.
NOTE: You will need to copy the FMT code below and save it as a file named DB24.FMT on your computer. The first line of the FMT code indicates the version of bcp. Please change the version as according to your MS-SQL installed.
SQL Server 2016 | 12.0 |
SQL Server 2014 | 12.0 |
SQL Server 2012 | 11.0 |
Azure SQL | 10.0 |
SQL Server 2008/2008R2 | 10.0 |
SQL Server 2005 | 9.0 |
SQL Server 2000 | 8.0 |
SQL Server 7.0 | 7.0 |
SQL Server 6.5 | 6.5 |
IPv4 Database
10.0
28
1 SQLCHAR 0 1 "\"" 0 first_double_quote Latin1_General_CI_AI
2 SQLCHAR 0 20 "\",\"" 1 ip_from ""
3 SQLCHAR 0 20 "\",\"" 2 ip_to ""
4 SQLCHAR 0 2 "\",\"" 3 country_code Latin1_General_CI_AI
5 SQLCHAR 0 64 "\",\"" 4 country_name Latin1_General_CI_AI
6 SQLCHAR 0 128 "\",\"" 5 region_name Latin1_General_CI_AI
7 SQLCHAR 0 128 "\",\"" 6 city_name Latin1_General_CI_AI
8 SQLCHAR 0 20 "\",\"" 7 latitude ""
9 SQLCHAR 0 20 "\",\"" 8 longitude ""
10 SQLCHAR 0 30 "\",\"" 9 zip_code Latin1_General_CI_AI
11 SQLCHAR 0 8 "\",\"" 10 time_zone Latin1_General_CI_AI
12 SQLCHAR 0 256 "\",\"" 11 isp Latin1_General_CI_AI
13 SQLCHAR 0 128 "\",\"" 12 domain Latin1_General_CI_AI
14 SQLCHAR 0 8 "\",\"" 13 net_speed Latin1_General_CI_AI
15 SQLCHAR 0 5 "\",\"" 14 idd_code Latin1_General_CI_AI
16 SQLCHAR 0 30 "\",\"" 15 area_code Latin1_General_CI_AI
17 SQLCHAR 0 10 "\",\"" 16 weather_station_code Latin1_General_CI_AI
18 SQLCHAR 0 128 "\",\"" 17 weather_station_name Latin1_General_CI_AI
19 SQLCHAR 0 256 "\",\"" 18 mcc Latin1_General_CI_AI
20 SQLCHAR 0 256 "\",\"" 19 mnc Latin1_General_CI_AI
21 SQLCHAR 0 128 "\",\"" 20 mobile_brand Latin1_General_CI_AI
22 SQLCHAR 0 20 "\",\"" 21 elevation Latin1_General_CI_AI
23 SQLCHAR 0 11 "\",\"" 22 usage_type Latin1_General_CI_AI
24 SQLCHAR 0 1 "\",\"" 23 address_type Latin1_General_CI_AI
25 SQLCHAR 0 10 "\",\"" 24 category Latin1_General_CI_AI
26 SQLCHAR 0 128 "\",\"" 25 district Latin1_General_CI_AI
27 SQLCHAR 0 10 "\",\"" 26 asn Latin1_General_CI_AI
28 SQLCHAR 0 256 "\"\r\n" 27 as Latin1_General_CI_AI
IPv6 Database
10.0
28
1 SQLCHAR 0 1 "\"" 0 first_double_quote Latin1_General_CI_AI
2 SQLCHAR 0 39 "\",\"" 1 ip_from ""
3 SQLCHAR 0 39 "\",\"" 2 ip_to ""
4 SQLCHAR 0 2 "\",\"" 3 country_code Latin1_General_CI_AI
5 SQLCHAR 0 64 "\",\"" 4 country_name Latin1_General_CI_AI
6 SQLCHAR 0 128 "\",\"" 5 region_name Latin1_General_CI_AI
7 SQLCHAR 0 128 "\",\"" 6 city_name Latin1_General_CI_AI
8 SQLCHAR 0 20 "\",\"" 7 latitude ""
9 SQLCHAR 0 20 "\",\"" 8 longitude ""
10 SQLCHAR 0 30 "\",\"" 9 zip_code Latin1_General_CI_AI
11 SQLCHAR 0 8 "\",\"" 10 time_zone Latin1_General_CI_AI
12 SQLCHAR 0 256 "\",\"" 11 isp Latin1_General_CI_AI
13 SQLCHAR 0 128 "\",\"" 12 domain Latin1_General_CI_AI
14 SQLCHAR 0 8 "\",\"" 13 net_speed Latin1_General_CI_AI
15 SQLCHAR 0 5 "\",\"" 14 idd_code Latin1_General_CI_AI
16 SQLCHAR 0 30 "\",\"" 15 area_code Latin1_General_CI_AI
17 SQLCHAR 0 10 "\",\"" 16 weather_station_code Latin1_General_CI_AI
18 SQLCHAR 0 128 "\",\"" 17 weather_station_name Latin1_General_CI_AI
19 SQLCHAR 0 256 "\",\"" 18 mcc Latin1_General_CI_AI
20 SQLCHAR 0 256 "\",\"" 19 mnc Latin1_General_CI_AI
21 SQLCHAR 0 128 "\",\"" 20 mobile_brand Latin1_General_CI_AI
22 SQLCHAR 0 20 "\",\"" 21 elevation Latin1_General_CI_AI
23 SQLCHAR 0 11 "\",\"" 22 usage_type Latin1_General_CI_AI
24 SQLCHAR 0 1 "\",\"" 23 address_type Latin1_General_CI_AI
25 SQLCHAR 0 10 "\",\"" 24 category Latin1_General_CI_AI
26 SQLCHAR 0 128 "\",\"" 25 district Latin1_General_CI_AI
27 SQLCHAR 0 10 "\",\"" 26 asn Latin1_General_CI_AI
28 SQLCHAR 0 256 "\"\r\n" 27 as Latin1_General_CI_AI
NOTE: Due to the fact that SQL Server does not support a number with more than 38 digits, we have to store the IP From and IP To fields as zero padded strings to enable sorting. Please visit this tutorial on how to add the padding, enable cluster index and make the query.
COPY ip2location_db26 FROM \'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN.CSV\' WITH CSV QUOTE AS \'"\';
Click here to view the step-by-step tutorials.
Import The Database into NoSQL Database
Sample Code
mongoimport -u USERNAME -p PASSWORD --authenticationDatabase admin --drop --db ip2location --collection db26 --type csv --file "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN.CSV" --fields ip_from,ip_to,country_code,country_name,region_name,city_name,latitude,longitude,zip_code,time_zone,isp,domain,net_speed,idd_code,area_code,weather_station_code,weather_station_name,mcc,mnc,mobile_brand,elevation,usage_type,address_type,category,district,asn,as
docker pull ip2location/mongodb
docker run --name ip2location -d -e TOKEN={DOWNLOAD_TOKEN} -e CODE=DB26 -e MONGODB_PASSWORD={MONGODB_PASSWORD} ip2location/mongodb
We also provide tutorials on how to import the database into MongoDB, Redis, Amazon SimpleDB and CouchDB at https://blog.ip2location.com.
Sample Codes
You can follow sample codes below to get started.
Query IP Address Using IP2Location IPv4 and IPv6 Database
First, import IP2Location database into MySQLm MS-SQL, MS-ACCESS, PL/SQL or other RDMS. Use an SQL query to get the matching recordset.
Sample Code
SELECT `ip_from`, `ip_to`, `country_code`, `country_name`, `region_name`, `city_name`, `latitude`, `longitude`, `zip_code`, `time_zone`, `isp`, `domain`, `net_speed`, `idd_code`, `area_code`, `weather_station_code`, `weather_station_name`, `mcc`, `mnc`, `mobile_brand`, `elevation`, `usage_type`, `address_type`, `category`, `district`, `asn`, `as`FROM `ip2location_db26`
WHERE INET_ATON([IP ADDRESS]) <= ip_to LIMIT 1
SELECT TOP 1 [ip_from], [ip_to], [country_code], [country_name], [region_name], [city_name], [latitude], [longitude], [zip_code], [time_zone], [isp], [domain], [net_speed], [idd_code], [area_code], [weather_station_code], [weather_station_name], [mcc], [mnc], [mobile_brand], [elevation], [usage_type], [address_type], [category], [district], [asn], [as]FROM [ip2location_ip-country-region-city-latitude-longitude-zipcode-timezone-isp-domain-netspeed-areacode-weather-mobile-elevation-usagetype-addresstype-category-district-asn]
WHERE [SEARCH IP NO] <= ip_to
Query IPv4 address Using IP2Location IPv6 Database
First, import IP2Location database into MySQL, MS-SQL, MS-ACCESS, PL/SQL or other RDMS. Use an SQL query to get the matching recordset. The IPv4 address is in IPv4-mapped IPv6 address form in IPv6 database. Learn more at https://blog.ip2location.com/knowledge-base/ipv4-mapped-ipv6-address/.
Sample Code
SELECT `ip_from`, `ip_to`, `country_code`, `country_name`, `region_name`, `city_name`, `latitude`, `longitude`, `zip_code`, `time_zone`, `isp`, `domain`, `net_speed`, `idd_code`, `area_code`, `weather_station_code`, `weather_station_name`, `mcc`, `mnc`, `mobile_brand`, `elevation`, `usage_type`, `address_type`, `category`, `district`, `asn`, `as`FROM `ip2location_db26`
WHERE [SEARCH IP NO] <= ip_to LIMIT 1
SELECT TOP 1 [ip_from], [ip_to], [country_code], [country_name], [region_name], [city_name], [latitude], [longitude], [zip_code], [time_zone], [isp], [domain], [net_speed], [idd_code], [area_code], [weather_station_code], [weather_station_name], [mcc], [mnc], [mobile_brand], [elevation], [usage_type], [address_type], [category], [district], [asn], [as]FROM [ip2location_db26]
WHERE [SEARCH IP NO] <= ip_to