Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fip%2Fipprefix.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fip%2Fipprefix.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `ipPrefix`

## Description

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

## Syntax

Like many functions in DataPrime, `ipPrefix` supports<!-- --> [two notations](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

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

```
(ip: string).ipPrefix(subnetSize: number): string
```

## Arguments

| Name         | Type     | Required | Description                                                              |
| ------------ | -------- | -------- | ------------------------------------------------------------------------ |
| `ip`         | `string` | **true** | The IP address to process                                                |
| `subnetSize` | `number` | **true** | Number 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

* Function notation
* Method notation

```
create ip_subnet from ipPrefix(ip, 10)
```

```
create ip_subnet from ip.ipPrefix(10)
```

### Example output

```
{

    "ip": "155.123.7.4",

    "ip_subnet": "155.64.0.0/10"

}
```
