lionsoul2014/ip2region logo

lionsoul2014/ip2region

Free

Ip2region (2.0 - xdb) is a offline IP address manager framework and locator, support billions of data segments, ten microsecond searching performance. xdb engine implementation for many programming languages

FreeFree tier
Type
Open Source

About lionsoul2014/ip2region

ip2region is an offline IP address localization library and IP data management framework that provides city-level geolocation for both IPv4 and IPv6 addresses. It achieves 10-microsecond level query efficiency using the xdb data format, which supports billions of IP data segments. The project includes raw data sources and pre-built xdb files, along with query client implementations for 14 programming languages (Golang, PHP, Java, C, Lua, Python, Rust, JavaScript, C#, etc.). It offers two memory acceleration modes: vIndex Index Caching (512KiB) and full file caching. The framework allows fully customizable region data and automatically deduplicates and compresses IP segments during generation.

Key Features

Offline localization library with city-level IP geolocation (IPv4 and IPv6)
10-microsecond level query efficiency via xdb data format
Supports hundreds of millions of IP data segment rows
Data deduplication and compression on generation
Customizable region information (e.g., GPS, zip codes)
Two memory acceleration modes: vIndex caching (512KiB) and full file caching
Unified query API for both IPv4 and IPv6
Query client implementations for 14+ programming languages (Golang, Java, Python, Rust, etc.)
Built-in raw data for IPv4 and IPv6 with pre-generated xdb files

Pros & Cons

Pros
  • Fully offline, no external API calls needed
  • Extremely fast query performance (10 microseconds)
  • Supports both IPv4 and IPv6
  • Multi-language client support for easy integration
  • Open-source and free to use
  • Data deduplication and compression reduce storage needs
  • Scalable to billions of IP segments with xdb format
Cons
  • Precision limited to city level (not street-level)
  • Data updates require manual generation or download of new xdb files
  • IPv6 data coverage may be less comprehensive than IPv4
  • Documentation primarily in English and Chinese

Best For

IP geolocation for analytics, content localization, or fraud detectionCustom IP data management and localization frameworkOffline city-level region lookup in applications with no internet dependencyBuilding network security tools that require fast IP-to-location mapping

FAQ

What is ip2region?
ip2region is an offline IP address localization library and IP data management framework that provides city-level geolocation for IPv4 and IPv6 addresses with 10-microsecond query performance.
Which programming languages are supported?
Query client implementations are available for Golang, PHP, Java, C, Lua, Rust, Python, JavaScript, C#, Erlang, Nginx, C++, Cangjie, and more.
Is ip2region free to use?
Yes, ip2region is open-source and free. The source code and data are available on GitHub under an open-source license.
How accurate is the IP geolocation?
The built-in data provides city-level accuracy. For China, information is in Chinese; for non-China regions, it is in English. The format is Country|Province|City|ISP|iso-alpha2-code.
Can I use custom IP data?
Yes, the xdb generation supports fully customizable region information. You can append data like GPS coordinates or zip codes to the region fields.