# IP_PREFIX

The IP_PREFIX function truncates an IP address to a specified prefix length, supporting both IPv4 and IPv6 formats.

## Syntax

`IP_PREFIX(ip, prefixLengthV4, prefixLengthV6)`

### Parameters

#### ip

IP address of type `ip`. Both IPv4 and IPv6 addresses are supported.

#### prefixLengthV4

Prefix length to use for truncating IPv4 addresses.

#### prefixLengthV6

Prefix length to use for truncating IPv6 addresses.

## Examples

Truncates an IPv4 address to a /24 prefix and an IPv6 address to a /112 prefix, showing the original and truncated values for each.

```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);
```
