github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/hcl2/functions/ipnet/cidrhost.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: cidrhost - Functions - Configuration Language
     4  sidebar_title: 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`](/docs/job-specification/hcl2/functions/ipnet/cidrsubnet).
    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  ## Examples
    38  
    39  ```shell-session
    40  > cidrhost("10.12.127.0/20", 16)
    41  10.12.112.16
    42  > cidrhost("10.12.127.0/20", 268)
    43  10.12.113.12
    44  > cidrhost("fd00:fd12:3456:7890:00a2::/72", 34)
    45  fd00:fd12:3456:7890::22
    46  ```
    47  
    48  ## Related Functions
    49  
    50  - [`cidrsubnet`](/docs/job-specification/hcl2/functions/ipnet/cidrsubnet) calculates a subnet address under a given
    51    network address prefix.