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.

Returns the type classification of an IP address.

ip_category(x:ip) -> string

The ip_category function returns the category classification of a given IP address x as a string. The possible return values are:

  • "unspecified" - Unspecified address (0.0.0.0 or ::)
  • "loopback" - Loopback address (127.0.0.0/8 or ::1)
  • "link_local" - Link-local address (169.254.0.0/16 or fe80::/10)
  • "multicast" - Multicast address (224.0.0.0/4 or ff00::/8)
  • "broadcast" - Broadcast address (255.255.255.255, IPv4 only)
  • "private" - Private address (RFC 1918 for IPv4, RFC 4193 for IPv6)
  • "global" - Global (publicly routable) address

The function returns the most specific classification that applies to the address. For example, 127.0.0.1 is classified as "loopback" rather than just non-global.

from {
global_ipv4: ip_category(8.8.8.8),
private_ipv4: ip_category(192.168.1.1),
loopback: ip_category(127.0.0.1),
multicast: ip_category(224.0.0.1),
link_local: ip_category(169.254.1.1),
}
{
global_ipv4: "global",
private_ipv4: "private",
loopback: "loopback",
multicast: "multicast",
link_local: "link_local",
}

Last updated: