github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/ipnet/cidrhost.mdx (about)

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