[det]ip_class(+IP,
-Class)Classify an IP address as represented by ip/4
(IPv4) or ip/8 (IPv6) terms. Class
is one of
- global
- A globally routable (public) address.
- loopback
- 127.0.0.0/8 or ::1
- private
- 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, the shared address space
100.64.0.0/10 and the IPv6 unique local (fc00::/7)
and deprecated site local (fec0::/10)
addresses.
- link_local
- 169.254.0.0/16 or fe80::/10. This includes
the metadata service of many cloud providers (169.254.169.254).
- multicast
- 224.0.0.0/4 or ff00::/8
- unspecified
- 0.0.0.0/8 or ::
- reserved
- Other special purpose addresses: 192.0.0.0/24, the documentation and
benchmark ranges, 240.0.0.0/4 (including the broadcast address),
2001:db8::/32 and IPv6 addresses outside 2000::/3
that are not covered above.
IPv6 addresses that embed an IPv4 address (IPv4-mapped ::ffff:0:0/96
and NAT64 64:ff9b::/96) are classified by the embedded IPv4 address.
This predicate is intended to decide whether connecting to an address on
behalf of an untrusted party is safe; see the address_filter
option of tcp_connect/3.
- Introduced in 11.1.1 (👉1eb5348) tcp_connect/3: option address_filter(:Filter) and ip_class/2