# net.ip-classify
Say what kind of address an IPv4 or IPv6 address is: loopback, private,
shared (carrier-grade NAT), link-local, multicast, documentation,
benchmarking, reserved, broadcast, protocol assignments, translation,
IPv4-mapped, discard, unspecified, or global.
## How it decides
The rules are data (`data/special-purpose.json`), one row per block of the
IANA special-purpose registries, with the registry's own name, RFC and
"Globally Reachable" column. An address is matched against every block of
its family and **the most specific (longest prefix) wins**, as the registry
intends: `192.0.0.9` is Port Control Protocol Anycast (globally reachable),
not the surrounding `192.0.0.0/24` IETF assignments (not reachable). An
address in no block is `global`, name `Global unicast`, reachable.
`category` is this capability's grouping of the registry's names, so callers
can branch on a closed set; `name`, `block` and `rfc` say exactly which row
matched. `globallyReachable` is the registry's column, null where it says
N/A (Teredo, 6to4, deprecated blocks) and for the multicast ranges, which the
special-purpose registries do not list.
## Edge cases
- IPv6 is returned in RFC 5952 canonical form (`FE80::0001` gives `fe80::1`).
- An IPv4-mapped address (`::ffff:192.168.1.1`) is `ipv4-mapped`; it is not
classified as the IPv4 address inside it. Classify the IPv4 part yourself if
that is what you mean.
- `global` for IPv6 means "in no special-purpose block", which includes space
IANA has not allocated yet.
- Text follows `net.ipv4` / `net.ipv6` strictly: no leading zeros, zone ids or
prefixes.
## Sources (checked 2026-09-26 against the registries' CSV exports)
- IANA IPv4 Special-Purpose Address Registry,
https://www.iana.org/assignments/iana-ipv4-special-registry/ (RFC 6890,
RFC 8190). All 25 rows, including 192.88.99.2/32 (6a44 relay) and the two
NAT64/DNS64 discovery /32s listed as one row there.
- IANA IPv6 Special-Purpose Address Registry,
https://www.iana.org/assignments/iana-ipv6-special-registry/. All 26 rows,
including 100:0:0:1::/64 (RFC 9780), 3fff::/20 (RFC 9637) and 5f00::/16
(RFC 9602).
- IPv4 multicast 224.0.0.0/4: RFC 5771 (IANA Guidelines for IPv4 Multicast
Address Assignments). IPv6 multicast ff00::/8: RFC 4291 section 2.7.
When the registry changes, publish a new version with the new rows.