github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/cidrnetmask.mdx (about) 1 --- 2 page_title: cidrnetmask - Functions - Configuration Language 3 description: |- 4 The cidrnetmask function converts an IPv4 address prefix given in CIDR 5 notation into a subnet mask address. 6 --- 7 8 # `cidrnetmask` Function 9 10 `cidrnetmask` converts an IPv4 address prefix given in CIDR notation into 11 a subnet mask address. 12 13 ```hcl 14 cidrnetmask(prefix) 15 ``` 16 17 `prefix` must be given in IPv4 CIDR notation, as defined in 18 [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1). 19 20 The result is a subnet address formatted in the conventional dotted-decimal 21 IPv4 address syntax, as expected by some software. 22 23 CIDR notation is the only valid notation for IPv6 addresses, so `cidrnetmask` 24 produces an error if given an IPv6 address. 25 26 -> **Note:** As a historical accident, this function interprets IPv4 address 27 octets that have leading zeros as decimal numbers, which is contrary to some 28 other systems which interpret them as octal. We have preserved this behavior 29 for backward compatibility, but recommend against relying on this behavior. 30 31 ## Examples 32 33 ``` 34 > cidrnetmask("172.16.0.0/12") 35 255.240.0.0 36 ```