ipPrefix - Generate the CIDR range for a given subnet
The ipPrefix
function is very useful for working out the subnet in which an IP address belongs.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
ip | string | true | The IP address to process |
subnetSize | number | true | The number of mask bits in the subnet. For example, 10 will result in a CIDR range ending in /10 |
Example - Generating the CIDR range for a given IP in a subnet of known size
Consider the following document:
To calculate the subnet for this IP, and assuming that we know the number of mask bits, we can use the ipPrefix
function:
This results in the following document:
Theme
Light