Converts an expression to a subnet value.
subnet(x:string|ip|subnet) -> subnetsubnet(x:string|ip|subnet, prefix:int) -> subnetDescription
Section titled “Description”The subnet function converts an expression to a subnet.
x: string
Section titled “x: string”The string expression to convert. The string can be a CIDR subnet such as
"10.0.1.5/24" or a plain IP address such as "10.0.1.5".
Plain IPv4 addresses become /32 host subnets, and plain IPv6 addresses become
/128 host subnets.
The IP address to convert. IPv4 addresses become /32 host subnets, and IPv6
addresses become /128 host subnets.
x: subnet
Section titled “x: subnet”The subnet to return unchanged.
prefix: int
Section titled “prefix: int”The CIDR prefix length for a plain IP address or subnet network address. IPv4
prefixes must be in the range 0 to 32, and IPv6 prefixes must be in the
range 0 to 128.
Use prefix with plain IP values or existing subnet values. Strings that
already contain CIDR notation return null when you also provide prefix.
Examples
Section titled “Examples”Convert a string to a subnet
Section titled “Convert a string to a subnet”from {x: subnet("1.2.3.4/16")}{x: 1.2.0.0/16}Convert an IP address to a subnet
Section titled “Convert an IP address to a subnet”from {x: subnet(10.10.1.124, 24)}{x: 10.10.1.0/24}Convert a plain IP string to a host subnet
Section titled “Convert a plain IP string to a host subnet”from {x: subnet("2001:db8::1")}{x: 2001:db8::1/128}