sapics / ip-location-db

ip to location database by ASN, GeoFeed, Whois, iptoasn.com, db-ip lite, GeoLite2
Other
1.02k stars 104 forks source link
asn autonomous-system geoip ip-country ip-geolocation ip-location ip2country ip2location

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
Database Type License Updated IPv4 IPv6 IPv4-num IPv6-num
ASN

npm version
npm version
Country CC0 Daily CSV
MMDB
CSV
MMDB
CSV CSV
GeoFeed + ASN

npm version
npm version
Country CC0 Daily CSV
MMDB
CSV
MMDB
CSV CSV
GeoFeed + Whois + ASN

npm version
npm version
Country CC0 Daily CSV
MMDB
CSV
MMDB
CSV CSV
IPtoASN

npm version
npm version
Country PDDL by IPtoASN Daily CSV
MMDB
CSV
MMDB
CSV CSV
DB-IP Lite

npm version
Country CC BY 4.0
by DB-IP
Monthly CSV
MMDB
CSV
MMDB
CSV CSV
DB-IP Lite + GeoFeed + Whois + ASN

npm version
Country CC BY 4.0
by DB-IP
Monthly CSV
MMDB
CSV
MMDB
CSV CSV
GeoLite2

npm version
npm version
Country GeoLite2 License by MaxMind Twice weekly CSV
MMDB
CSV
MMDB
CSV CSV
GeoLite2 + GeoFeed + Whois + ASN

npm version
npm version
Country GeoLite2 License by MaxMind Daily CSV
MMDB
CSV
MMDB
CSV CSV

City

ip_range_start, ip_range_end, country_code, city, state1, state2, latitude, longitude, postcode, timezone
Database Type License Updated IPv4 IPv6 IPv4-num IPv6-num
DB-IP Lite

npm version
npm version
npm version
City CC BY 4.0
by DB-IP
Monthly CSV.gzbr>[CSV.7z](https://cdn.jsdelivr.net/npm/@ip-location-db/dbip-city-7z/dbip-city-ipv4.csv.7z)<brMMDB CSV.gzbr>[CSV.7z](https://cdn.jsdelivr.net/npm/@ip-location-db/dbip-city-7z/dbip-city-ipv6.csv.7z)<brMMDB CSV.gz
CSV.7z
CSV.gz
CSV.7z
GeoLite2

npm version
npm version
npm version
City GeoLite2 License by MaxMind Twice weekly CSV.gzbr>[CSV.7z](https://cdn.jsdelivr.net/npm/@ip-location-db/geolite2-city-7z/geolite2-city-ipv4.csv.7z)<brMMDB CSV.gzbr>[CSV.7z](https://cdn.jsdelivr.net/npm/@ip-location-db/geolite2-city-7z/geolite2-city-ipv6.csv.7z)<brMMDB CSV.gz
CSV.7z
CSV.gz
CSV.7z

ASN

ip_range_start, ip_range_end, autonomous_system_number, autonomous_system_organization
Database Type License Updated IPv4 IPv6 IPv4-num IPv6-num
RouteViews + ASN + DB-IP

npm version
npm version
ASN CC BY 4.0 by RouteViews and DB-IP Daily CSV
MMDB
CSV
MMDB
CSV CSV
IPtoASN

npm version
npm version
ASN PDDL by IPtoASN Daily CSV
MMDB
CSV
MMDB
CSV CSV
DB-IP Lite

npm version
npm version
ASN CC BY 4.0
by DB-IP
Monthly CSV
MMDB
CSV
MMDB
CSV CSV
GeoLite2

npm version
npm version
ASN GeoLite2 License by MaxMind Twice weekly CSV
MMDB
CSV
MMDB
CSV CSV

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.

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.

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 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:

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, Java, 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

Library Language Description Types Auto
Updates
geoip-country Node.js Fast ip to country lookup by using in-memory database. (requires 10MB RAM) country

Useful applications

Application Language Description Types Auto
Updates
ip_location_server Java An in-memory GRPC and HTTP server mapping IP addresses to locations (requires at least 1.5GB RAM) country
asn
city
ip-location-api Go API server creating / supporting MMDB, PostgreSQL, MySQL / MariaDB and SQLite country
asn
city
Ip-geo-API Go In-memory API server country
IPInfoOffline Windows Desktop tool showing information about IP addresses (local data) country
asn
city

Useful tools

Tool Description
ip-location-to-mmdb Basic conversion from CSV files from this database into MMDB files
mmdbmeld Create 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.