---
page_title: cidrnetmask function reference
description: |-
  The `cidrnetmask` function converts an IPv4 address prefix given in CIDR
  notation into a subnet mask address. 
---

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
> [!IMPORTANT]  
> **Documentation Update:** Product documentation previously located in `/website` has moved to the [`hashicorp/web-unified-docs`](https://github.com/hashicorp/web-unified-docs) repository, where all product documentation is now centralized. Please make contributions directly to `web-unified-docs`, since changes to `/website` in this repository will not appear on developer.hashicorp.com.
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

# `cidrnetmask` Function

`cidrnetmask` converts an IPv4 address prefix given in CIDR notation into
a subnet mask address.

```hcl
cidrnetmask(prefix)
```

`prefix` must be given in IPv4 CIDR notation, as defined in
[RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).

The result is a subnet address formatted in the conventional dotted-decimal
IPv4 address syntax, as expected by some software.

CIDR notation is the only valid notation for IPv6 addresses, so `cidrnetmask`
produces an error if given an IPv6 address.

## Examples

```shell-session
> cidrnetmask("172.16.0.0/12")
255.240.0.0
```
