# IP_PREFIX

Truncates an IP address to a specified prefix length.

## Syntax

`IP_PREFIX(ip, prefixLengthV4, prefixLengthV6)`

### Parameters

#### `ip`

The IP address to truncate. Supports both IPv4 and IPv6 addresses and must be of type `ip`.

#### `prefixLengthV4`

The prefix length to apply for IPv4 addresses.

#### `prefixLengthV6`

The prefix length to apply for IPv6 addresses.

## Examples

Truncating IPv4 and IPv6 addresses

```esql
ROW ip4 = TO_IP("1.2.3.4"), ip6 = TO_IP("fe80::cae2:65ff:fece:feb9")
| EVAL ip4_prefix = IP_PREFIX(ip4, 24, 0), ip6_prefix = IP_PREFIX(ip6, 0, 112)
```

This example truncates the IPv4 address `1.2.3.4` to a `/24` prefix and the IPv6 address `fe80::cae2:65ff:fece:feb9` to a `/112` prefix.
