Skip to content

ip to location database by ASN, GeoFeed, Whois, iptoasn.com, db-ip lite, GeoLite2

Notifications You must be signed in to change notification settings

sapics/ip-location-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

15 Commits

Repository files navigation

ip-location-db

This project provides IP to location databases in CSV and MMDB formats.

There are 3 types of IP database in this repository: country, city and asn files. All have their own standard format.

Country

ip_range_start, ip_range_end, country_code 
DatabaseTypeLicenseUpdatedIPv4IPv6IPv4+IPV6IPv4-numIPv6-num
ASN

npm version
npm version
CountryCC0DailyCSV
MMDB
CSV
MMDB
MMDBCSVCSV
GeoFeed + ASN

npm version
npm version
CountryCC0DailyCSV
MMDB
CSV
MMDB
MMDBCSVCSV
GeoFeed + Whois + ASN

npm version
npm version
CountryCC0DailyCSV
MMDB
CSV
MMDB
MMDBCSVCSV
IPtoASN

npm version
npm version
CountryPDDL by IPtoASNDailyCSV
MMDB
CSV
MMDB
CSVCSV
IPLocate

npm version
npm version
CountryCC BY SA 4.0 by IPLocateDailyCSV
MMDB
CSV
MMDB
MMDBCSVCSV
DB-IP Lite

npm version
CountryCC BY 4.0
by DB-IP
MonthlyCSV
MMDB
CSV
MMDB
CSVCSV
DB-IP Lite + GeoFeed + Whois + ASN

npm version
CountryCC BY 4.0
by DB-IP
MonthlyCSV
MMDB
CSV
MMDB
MMDBCSVCSV
GeoLite2

npm version
npm version
CountryGeoLite2 License by MaxMindTwice weeklyCSV
MMDB
CSV
MMDB
CSVCSV
GeoLite2 + GeoFeed + Whois + ASN

npm version
npm version
CountryGeoLite2 License by MaxMindDailyCSV
MMDB
CSV
MMDB
MMDBCSVCSV

City

ip_range_start, ip_range_end, country_code, state1, state2, city, postcode, latitude, longitude, timezone 
DatabaseTypeLicenseUpdatedIPv4IPv6IPv4+IPV6IPv4-numIPv6-num
DB-IP Lite

npm version
npm version
npm version
CityCC BY 4.0
by DB-IP
MonthlyCSV.gz
CSV.7z
MMDB
CSV.gz
CSV.7z
MMDB
CSV.gz
CSV.7z
CSV.gz
CSV.7z
GeoLite2

npm version
npm version
npm version
CityGeoLite2 License by MaxMindTwice weeklyCSV.gz
CSV.7z
MMDB
CSV.gz
CSV.7z
MMDB
CSV.gz
CSV.7z
CSV.gz
CSV.7z

ASN

ip_range_start, ip_range_end, autonomous_system_number, autonomous_system_organization 
DatabaseTypeLicenseUpdatedIPv4IPv6IPv4+IPV6IPv4-numIPv6-num
RouteViews + ASN + DB-IP

npm version
npm version
ASNCC BY 4.0 by RouteViews and DB-IPDailyCSV
MMDB
CSV
MMDB
MMDBCSVCSV
IPtoASN

npm version
npm version
ASNPDDL by IPtoASNDailyCSV
MMDB
CSV
MMDB
CSVCSV
IPLocate

npm version
npm version
ASNCC BY SA 4.0 by IPLocateDailyCSV
MMDB
CSV
MMDB
MMDBCSVCSV
DB-IP Lite

npm version
npm version
ASNCC BY 4.0
by DB-IP
MonthlyCSV
MMDB
CSV
MMDB
CSVCSV
GeoLite2

npm version
npm version
ASNGeoLite2 License by MaxMindTwice weeklyCSV
MMDB
CSV
MMDB
MMDBCSVCSV

File formats

An explanation of each file format is provided in its own directory.

All files of a given type share the same file format; for example, you could swap one asn file for any other asn file.

Databases referenced in this project

ASN database [Update: Daily]

Created by merging 5 RIP (afrinic, apnic, arin, lacnic, ripe ncc) IP-ASN-Country database. ASN (Autonomous System Number) is a unique number assigned to an Autonomous System (AS) by the IANA.

Whois dastabase [Update: Daily]

Created by merging 5 RIP (afrinic, apnic, arin, lacnic, ripe ncc) provided WHOIS database.

GeoFeed database [Update: Daily]

Created by merging GeoFeed database from OpenGeoFeed and Collections of provider geofeed and so on.

RouteViews database [Update: every 2 hours]

We are using this database to get AS number from ipv4 address for asn. This is licensed under a CC BY 4.0, so, you must create attribution to RouteViews for using asn database.

IPtoASN database [Update: Hourly]

You can download hourly updated database in tsv format from original site. This is licensed under a Public Domain Dedication and License v1.0. There are some differences from above ASN database.

IPLocate database [Update: Daily]

You can download the original databases and read license from github repository iplocate/ip-address-databases.

These databases are licensed under a CC BY SA 4.0, so you must give appropriate credit by providing a link to IPLocate.io on your application, product, or website where the data is used.

If you need more detailed information (ex. City Name/Latitude/Longitude/etc.), please use the premium databases.

DB-IP database [Update: Monthly]

You could download and read the license from ip-to-asn-lite or ip-to-country-lite or ip-to-city-lite. Most of the AS Organization name used in asn uses ip-to-asn-lite database. We also use ip-to-asn-lite to get AS Number from ip address as a supplemental.

These database are licensed under a CC BY 4.0, so, you must create attribution to DB-IP.com for using DB-IP database.
In the case of a web application, you must include a link back to DB-IP.com on pages that display or use results from the database. You may do it by pasting the HTML code snippet into your code: <a href='https://db-ip.com/'>IP Geolocation by DB-IP</a>.
If you need better accuracy or no attribution or daily updates, please use the Commercial Version of db-ip.

GeoLite2 database [Update: Twice weekly]

GeoLite2 is created by MaxMind. The license of GeoLite2 is written in GEOLITE2_LICENSE and End User License Agreement (EULA) is written in GEOLITE2_EULA. Please carefully read the GEOLITE2_LICENSE and GEOLITE2_EULA files, if you use these database. This package comes with certain restrictions and obligations, most notably:

  • You cannot prevent the library from updating the databases.
  • You cannot use the GeoLite2 data:
    • for FCRA purposes,
    • to identify specific households or individuals.

You can read the latest version of GeoLite2 EULA. GeoLite2 databse is provided under CC BY-SA 4.0 by MaxMind, so, you must create attribution to MaxMind for using GeoLite2 database. If you need better accuracy, please use the commercial version GeoIp2.

Which database should I use?

It depends upon your use-case! We do have some simple recommendations though:

  • If you need postcodes or timezones: geolite2-city
  • If you need city data with a CC-BY Licence: dbip-city
  • If you need a country database with a Public Domain Licence: geo-whois-asn-country
  • If you need a high accuracy and wide IP range country database: geolite2-geo-whois-asn-country which is equivalent to geolite2-country for geolite2-country covered IP range and geo-whois-asn-country for the other IP range. (0.10% wider for IPv4 and 2.34% wider for IPv6 than geolite2-country at Aug. 2024)
  • If you need an ASN database: asn

Accuracy of database

Since there is no definitive information on IP addresses and country_code, it is difficult to discuss the accuracy of Public Domain data qualitatively, but it is possible to estimate the approximate accuracy by comparing it with the country information in GeoLite2 and DbIp Lite. By comparing the database in GeoLite2, which is well known for its high accuracy, with the differences in other databases, we can see that Public Domain accuracy.

DatabaseSameDiffEmptyExtra
dbip-country96.15%3.85%0.00%0.42%
asn-country95.97%4.00%0.03%0.03%
geo-asn-country97.26%2.71%0.03%0.06%
geo-whois-asn-country96.98%2.99%0.03%0.12%
iptoasn-country76.80%4.99%18.21%1.26%

Measurements were taken in 9 Oct. 2024. Because the ipv6 range is too wide, the measurements here are limited to ipv4 results. "Same" + "Diff" + "Empty" shows the GeoLite2 IP-range, and the GeoLite2 IP-range size is listed as 100%.

  • "Same" indicates the percentage of country_codes in Database that are the same as the country_code in GeoLite2.
  • "Diff" indicates the percentage of country_codes in Database that are different from GeoLite2 country_code.
  • "Empty" shows the percentage of IPs with GeoLite2 country_code but no corresponding country_code in Database.
  • "Extra" indicates the percentage of IPs with no GeoLite2 country_code listed that had a country_code listed in the Database.

We can see that for all data except iptoasn-country, the country_code matches the GeoLite2 results in more than 96% of cases. Although there is some variation in the results due to differences in update timing and the priority of the information, we believe that the Public Domain data shows a certain level of accuracy.

MMDB Libraries

If you would like to integrate MMDB files into an existing project there are several libraries that can help.

Read MMDB files

Libraries exist in many languages when using the MMDB files. There are official, Maxmind developed libraries for many popular languages: .NET, C, Node.js, Perl, PHP, Python and Ruby, and third-party readers for others: Erlang, Go, Rust.

Write MMDB files

If you wish to create your own MMDB files from the CSV files (to customise their format) there are a couple of official libraries: Go and Perl(now archived). There are also some third-party options: Python and Rust.

Useful Libraries

LibraryLanguageDescriptionTypesAuto
Updates
ip-location-apiNode.jsFast ip to country lookup by using in-memory database (7MB RAM)country
city
country
country-extra
Browser jsIp to country lookup in browsercountry
geocode
geocode-extra
Browser jsIp to geocode lookup in browsercountry
latitude
longitude

Useful applications

ApplicationLanguageDescriptionTypesAuto
Updates
ip_location_serverJavaAn in-memory GRPC and HTTP server mapping IP addresses to locations (requires at least 1.5GB RAM)country
asn
city
ip-location-apiGoAPI server creating / supporting MMDB, PostgreSQL, MySQL / MariaDB and SQLitecountry
asn
city
Ip-geo-APIGoIn-memory API servercountry
IPInfoOfflineWindowsDesktop tool showing information about IP addresses (local data)country
asn
city

Useful tools

ToolDescription
ip-location-to-mmdbBasic conversion from CSV files from this database into MMDB files
mmdbmeldCreate and customise MMDB files from CSV files in this database

Licences

The required licence depends upon the database which you use. Please carefully read each database licence before use.

You can use PDDL (ODC Public Domain Dedication and Licence) or CC0 (Creative Commons Zero) licensed databases without attribution for any purpose.

Support

We'd be grateful if you could link back to sapics/ip-location-db, and star this project to help others find it.

About

ip to location database by ASN, GeoFeed, Whois, iptoasn.com, db-ip lite, GeoLite2

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published