github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/cidrhost.html.md (about) 1 --- 2 layout: "functions" 3 page_title: "cidrhost - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-ipnet-cidrhost" 5 description: |- 6 The cidrhost function calculates a full host IP address within a given 7 IP network address prefix. 8 --- 9 10 # `cidrhost` Function 11 12 -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and 13 earlier, see 14 [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html). 15 16 `cidrhost` calculates a full host IP address for a given host number within 17 a given IP network address prefix. 18 19 ```hcl 20 cidrhost(prefix, hostnum) 21 ``` 22 23 `prefix` must be given in CIDR notation, as defined in 24 [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1). 25 26 `hostnum` is a whole number that can be represented as a binary integer with 27 no more than the number of digits remaining in the address after the given 28 prefix. For more details on how this function interprets CIDR prefixes and 29 populates host numbers, see the worked example for 30 [`cidrsubnet`](./cidrsubnet.html). 31 32 Conventionally host number zero is used to represent the address of the 33 network itself and the host number that would fill all the host bits with 34 binary 1 represents the network's broadcast address. These numbers should 35 generally not be used to identify individual hosts except in unusual 36 situations, such as point-to-point links. 37 38 This function accepts both IPv6 and IPv4 prefixes, and the result always uses 39 the same addressing scheme as the given prefix. 40 41 ## Examples 42 43 ``` 44 > cidrhost("10.12.127.0/20", 16) 45 10.12.112.16 46 > cidrhost("10.12.127.0/20", 268) 47 10.12.113.12 48 > cidrhost("fd00:fd12:3456:7890:00a2::/72", 34) 49 fd00:fd12:3456:7890::22 50 ``` 51 52 ## Related Functions 53 54 * [`cidrsubnet`](./cidrsubnet.html) calculates a subnet address under a given 55 network address prefix.