• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Nomad
  • Install
  • Intro
  • Tutorials
  • Documentation
  • API
  • Tools
  • Plugins
  • Sign up
Nomad Home

Documentation

Skip to main contentOverview


    • Overview
      • Overview
      • Expressions
        • Overview
          • cidrhost
          • cidrnetmask
          • cidrsubnet
          • cidrsubnets
      • Locals
      • Syntax
      • Variables
    • artifact
    • affinity
    • change_script
    • check
    • check_restart
    • connect
    • constraint
    • csi_plugin
    • device
    • dispatch_payload
    • env
    • ephemeral_disk
    • expose
    • gateway
    • group
    • job
    • lifecycle
    • logs
    • meta
    • migrate
    • multiregion
    • network
    • parameterized
    • periodic
    • proxy
    • reschedule
    • resources
    • restart
    • scaling
    • service
    • sidecar_service
    • sidecar_task
    • spread
    • task
    • template
    • update
    • upstreams
    • vault
    • volume
    • volume_mount
  • Schedulers

  • Nomad Ecosystem
  • Nomad Partnerships
  • Who Uses Nomad
  • FAQ

  • Resources

  • Tutorial Library
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Nomad
  3. Documentation
  4. Job Specification
  5. HCL2
  6. Functions
  7. IP Network Functions
  8. cidrhost
  • Nomad
  • v1.3.x
  • v1.2.x
  • v1.1.x
  • v1.0.x
  • v0.12.x
  • v0.11.x

»cidrhost Function

cidrhost calculates a full host IP address for a given host number within a given IP network address prefix.

cidrhost(prefix, hostnum)

prefix must be given in CIDR notation, as defined in RFC 4632 section 3.1.

hostnum is a whole number that can be represented as a binary integer with no more than the number of digits remaining in the address after the given prefix. For more details on how this function interprets CIDR prefixes and populates host numbers, see the worked example for cidrsubnet.

Conventionally host number zero is used to represent the address of the network itself and the host number that would fill all the host bits with binary 1 represents the network's broadcast address. These numbers should generally not be used to identify individual hosts except in unusual situations, such as point-to-point links.

This function accepts both IPv6 and IPv4 prefixes, and the result always uses the same addressing scheme as the given prefix.

Examples

> cidrhost("10.12.127.0/20", 16)
10.12.112.16
> cidrhost("10.12.127.0/20", 268)
10.12.113.12
> cidrhost("fd00:fd12:3456:7890:00a2::/72", 34)
fd00:fd12:3456:7890::22

Related Functions

  • cidrsubnet calculates a subnet address under a given network address prefix.
Edit this page on GitHub

On this page

  1. cidrhost Function
  2. Examples
  3. Related Functions
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)