ip-location-db

repository·main·Indexed 24 days ago

https://github.com/sapics/ip-location-db

A repository providing IP-to-location mapping data in CSV and MMDB formats. It offers three main database types: country, city, and ASN (Autonomous System Number). The project includes datasets such as geolite2-city, dbip-city, user-country, server-country, and origin-asn, with varying licenses including PDDL, CC BY 4.0, and CC BY-SA 4.0.

Tokens
2K
Snippets
4
Records
14
Agent score
35%

What's inside ip-location-db

  1. Overview of ip-location-db

    main
    ip-location-db provides IP to location databases in both CSV and MMDB formats. The project offers three main types of IP databases: country, city, and asn. All databases follow a standard format for their respective types.
  2. Licensing for user-country, server-country, and origin-asn

    main
    The datasets user-country, server-country, and origin-asn are published under the PDDL license. This allows for free use without attribution. These datasets are compiled from raw, public network data to ensure they remain free of commercial or redistribution restrictions.
  3. Data sources for origin-asn and other datasets

    main

    The datasets are compiled using the following types of public network data:

    1. Regional Internet Registries (RIRs) & NRO: Public statistical data (e.g., delegated statistics) from AFRINIC, APNIC, ARIN, LACNIC, RIPE NCC, and the NRO. Subject to the NRO License and respective RIR copyright statements.
    2. Global BGP Routing Archives: Aggregated global BGP routing data (RIB dumps and BGP updates) from Route Views (University of Oregon) and RIPE RIS (RIPE NCC) to analyze network visibility and active IP prefixes.
    3. Geofeed Providers: Geolocation data from geofeeds published by network operators (RFC 8805 / RFC 9632).
  4. Compliance and data handling policy

    main
    To maintain PDDL licensing and comply with provider Acceptable Use Policies (AUP), this project DOES NOT use RIR WHOIS or IRR databases (such as inetnum, country, or geoloc) for geographic mapping. This avoids violations of RIR policies (e.g., APNIC's prohibition on using WHOIS to map IP addresses to geographic locations). Instead, the project relies exclusively on open routing records and public geofeeds.
  5. Understand the difference between user-country and server-country

    main

    Both user-country and server-country use the same data sources but prioritize different geographic points:

    • user-country (Recommended): Prioritizes the end-user's country, even when routed through VPNs or proxies. This is best for most general applications.
    • server-country: Prioritizes the physical server or relay point. This is best for specific network analysis, such as determining routing locations.

    In most instances, both databases return almost identical results.

  6. Choose the right IP location database for your use-case

    main

    The project provides several databases depending on your requirements for accuracy, data type, and licensing. Use the following recommendations to select a database:

    • Postcodes or timezones: Use geolite2-city.
    • City data with CC-BY license: Use dbip-city.
    • Country data without attribution (PDDL): Use user-country.
    • ASN (Autonomous System Number) data: Use origin-asn.
  7. Verify database integrity with SHA-256 checksums

    main

    SHA-256 checksum files are available for all release assets in the Checksum Release.

    To construct a checksum URL for a specific file, replace /download/latest/ in the file's download URL with /download/checksum/ and append .sha256 to the filename.

    Example:

    • File: https://github.com/sapics/ip-location-db/releases/download/latest/user-country-ipv4.csv
    • Checksum: https://github.com/sapics/ip-location-db/releases/download/checksum/user-country-ipv4.csv.sha256
  8. Compliance and restrictions for GeoLite2

    main

    GeoLite2 (provided by MaxMind) is licensed under CC BY-SA 4.0. If you use these databases, you must adhere to specific restrictions and obligations, including:

    • No update prevention: You cannot prevent the library from updating the databases.
    • No FCRA usage: You cannot use GeoLite2 data for Fair Credit Reporting Act (FCRA) purposes.
    • No individual identification: You cannot use the data to identify specific households or individuals.

    It is highly recommended to read the GEOLITE2_LICENSE and GEOLITE2_EULA files before use.

  9. Compliance and attribution requirements for DB-IP

    main

    The dbip databases are licensed under CC BY 4.0. If you use these in a web application, you must include a link back to DB-IP.com on pages that display or use the results.

    You can satisfy this requirement by pasting the following HTML snippet into your code:

    <a href='https://db-ip.com/'>IP Geolocation by DB-IP</a>

    <a href='https://db-ip.com/'>IP Geolocation by DB-IP</a>
  10. Read and write MMDB files

    main

    If you are integrating MMDB files into an existing project, you can use various libraries depending on your language:

    Reading MMDB files

    Writing MMDB files

    To create your own MMDB files from CSV files (for custom formats), use:

    • Official: Go and Perl (Note: Perl version is archived).
    • Third-party: Python and Rust.