ipmapper v2.0

ipmapper / python + rust / open source

Which registry owns this address?

Offline IPv4 and IPv6 geolocation to country, currency, and Regional Internet Registry, built directly from the five RIR delegated files. Ships with a 515 KB bundled snapshot for air-gapped systems and a built-in HTTP microservice for internal routing.

pip install ipmapper
pip install "ipmapper[full]"
cargo install ipmapper-rs
Snapshot
515 KB
Python
2.2M/s
Rust
83M/s

Plate 1 · Regional Internet Registries

Five registries, one address space

Country Information

Click any country polygon to inspect its RIR allocation status and CIDR blocks.

Architecture

Built for offline speed and air-gapped reliability

IPMapper downloads the five public RIR delegated-extended files (APNIC, ARIN, RIPE NCC, LACNIC, AFRINIC), resolves prefix overlaps deterministically, flattens nested CIDRs into disjoint sorted interval arrays, and packs the entire global IPv4 and IPv6 table into a single CRC32-verified 515 KB binary snapshot.

Disjoint sorted intervals

Sweep-line flattening collapses 250k+ CIDRs into contiguous u32 (IPv4) and u64 (IPv6) arrays. Lookups run in C-speed binary search while preserving exact longest-prefix-match semantics.

515 KB bundled snapshot

Every Python wheel and Rust binary embeds an up-to-date prefixes.bin.gz snapshot. Cold load takes 4.2 ms in Python (2.0 MB RAM, 2.2M lookups/s) and 3.3 ms in Rust (1.92 MB RAM, 83M IPv4 / 95M IPv6 lookups/s).

Python and Rust parity

Both ipmapper (Python) and ipmapper-rs (Rust) read and write the exact same IPMP v1 binary snapshot, share the same CLI commands, and expose the same HTTP microservice endpoints.

Zero mandatory external APIs

No API keys, no per-request billing, and no outbound network traffic at lookup time. Refresh from all five RIRs whenever you want with ipmapper update.

Installation

Choose Python or Rust

All three install paths include the 515 KB global RIR snapshot so lookups work offline immediately after installation.

Package Install command Offline snapshot Extras
Python (core) pip install ipmapper Bundled (515 KB) CLI, Python API, HTTP server, ZIP bundles
Python (full) pip install "ipmapper[full]" Bundled (515 KB) Core + MaxMind MMDB binary export (--mmdb)
Rust (ipmapper-rs) cargo install ipmapper-rs Embedded in binary Native CLI, crate library, multi-threaded HTTP service

Integration recipes

Use it in your stack

Embed IPMapper directly inside your application, transfer it into an air-gapped network, run it as an internal routing sidecar, or query the live edge API.

# FastAPI middleware: zero-network lookup (~0.45 us/req, 2 MB RAM)
from fastapi import FastAPI, Request
import ipmapper

app = FastAPI()
ipmapper.lookup("8.8.8.8")  # warm index once at startup (~4 ms)

@app.middleware("http")
async def attach_geo(request: Request, call_next):
    client_ip = (
        request.headers.get("cf-connecting-ip")
        or request.headers.get("x-forwarded-for", "").split(",")[0].strip()
        or request.client.host
    )
    request.state.geo = ipmapper.lookup(client_ip)
    return await call_next(request)

Edge API

Hosted endpoints

The live demo endpoints on labs.anaskhan.me run as Cloudflare Pages Functions on the same origin.

Endpoint Description
GET /ipmapper/api/me Returns caller IP, country, currency, RIR, ISP, ASN, and timezone from Cloudflare edge metadata.
GET /ipmapper/api/lookup?ip=<addr> Returns edge-cached RIR delegated lookup JSON for any IPv4 or IPv6 literal address.
{
  "ip": "8.8.8.8",
  "country_code": "US",
  "country_name": "United States of America",
  "currency": "USD",
  "rir": "ARIN",
  "prefix": "8.8.8.0/24",
  "source": "rir-delegated"
}

Resources

Explore further