Skip to main content

ipPrefix

Description

Return the CIDR subnet for a given IP address and subnet size.

Syntax

Like many functions in DataPrime, ipPrefix supports two notations, function and method. These interchangeable forms allow flexibility in how you structure expressions.

ipPrefix(ip: string, subnetSize: number): string

Arguments

NameTypeRequiredDescription
ipstringtrueThe IP address to process
subnetSizenumbertrueNumber of mask bits in the subnet, e.g. 10 produces a /10 CIDR range

Example

Use case: Derive the subnet from an IP address

Compute the subnet for a given IP when the number of mask bits is known.

Example data

{
"ip": "155.123.7.4"
}

Example query

create ip_subnet from ipPrefix(ip, 10)

Example output

{
"ip": "155.123.7.4",
"ip_subnet": "155.64.0.0/10"
}
Was this page helpful?