Skip to content
Legacy docs for Tenzir v5.x. For the latest Tenzir v6 series, visit docs.tenzir.com. Migrating from v5? Read the Tenzir v6 migration guide.

Checks whether an IP address is a private address.

is_private(x:ip) -> bool

The is_private function checks whether a given IP address x is a private address according to RFC 1918 (IPv4) and RFC 4193 (IPv6).

For IPv4, private addresses are:

  • 10.0.0.0/8 (10.0.0.0 - 10.255.255.255)
  • 172.16.0.0/12 (172.16.0.0 - 172.31.255.255)
  • 192.168.0.0/16 (192.168.0.0 - 192.168.255.255)

For IPv6, private addresses are:

  • fc00::/7 (Unique Local Addresses)

Note: Link-local addresses (169.254.0.0/16 for IPv4 and fe80::/10 for IPv6) are not considered private addresses by this function.

from {
private_10: 10.0.0.1.is_private(),
private_172: 172.16.0.1.is_private(),
private_192: 192.168.1.1.is_private(),
private_ipv6: fc00::1.is_private(),
link_local: 169.254.1.1.is_private(),
public: 8.8.8.8.is_private(),
}
{
private_10: true,
private_172: true,
private_192: true,
private_ipv6: true,
link_local: false,
public: false,
}

Last updated: