github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/functions/cidrhost.html.md (about)

     1  ---
     2  layout: "language"
     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  `cidrhost` calculates a full host IP address for a given host number within
    13  a given IP network address prefix.
    14  
    15  ```hcl
    16  cidrhost(prefix, hostnum)
    17  ```
    18  
    19  `prefix` must be given in CIDR notation, as defined in
    20  [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).
    21  
    22  `hostnum` is a whole number that can be represented as a binary integer with
    23  no more than the number of digits remaining in the address after the given
    24  prefix. For more details on how this function interprets CIDR prefixes and
    25  populates host numbers, see the worked example for
    26  [`cidrsubnet`](./cidrsubnet.html).
    27  
    28  Conventionally host number zero is used to represent the address of the
    29  network itself and the host number that would fill all the host bits with
    30  binary 1 represents the network's broadcast address. These numbers should
    31  generally not be used to identify individual hosts except in unusual
    32  situations, such as point-to-point links.
    33  
    34  This function accepts both IPv6 and IPv4 prefixes, and the result always uses
    35  the same addressing scheme as the given prefix.
    36  
    37  -> **Note:** As a historical accident, this function interprets IPv4 address
    38  octets that have leading zeros as decimal numbers, which is contrary to some
    39  other systems which interpret them as octal. We have preserved this behavior
    40  for backward compatibility, but recommend against relying on this behavior.
    41  
    42  ## Examples
    43  
    44  ```
    45  > cidrhost("10.12.112.0/20", 16)
    46  10.12.112.16
    47  > cidrhost("10.12.112.0/20", 268)
    48  10.12.113.12
    49  > cidrhost("fd00:fd12:3456:7890:00a2::/72", 34)
    50  fd00:fd12:3456:7890::22
    51  ```
    52  
    53  ## Related Functions
    54  
    55  * [`cidrsubnet`](./cidrsubnet.html) calculates a subnet address under a given
    56    network address prefix.