mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
* Move commands from docs to its own root-level directory * temporarily use modified dev-portal branch with nomad ia changes * explicitly clone nomad ia exp branch * retrigger build, fixed dev-portal broken build * architecture, concepts and get started individual pages * fix get started section destinations * reference section * update repo comment in website-build.sh to show branch * docs nav file update capitalization * update capitalization to force deploy * remove nomad-vs-kubernetes dir; move content to what is nomad pg * job section * Nomad operations category, deploy section * operations category, govern section * operations - manage * operations/scale; concepts scheduling fix * networking * monitor * secure section * remote auth-methods folder and move up pages to sso; linkcheck * Fix install2deploy redirects * fix architecture redirects * Job section: Add missing section index pages * Add section index pages so breadcrumbs build correctly * concepts/index fix front matter indentation * move task driver plugin config to new deploy section * Finish adding full URL to tutorials links in nav * change SSO to Authentication in nav and file system * Docs NomadIA: Move tutorials into NomadIA branch (#26132) * Move governance and policy from tutorials to docs * Move tutorials content to job-declare section * run jobs section * stateful workloads * advanced job scheduling * deploy section * manage section * monitor section * secure/acl and secure/authorization * fix example that contains an unseal key in real format * remove images from sso-vault * secure/traffic * secure/workload-identities * vault-acl change unseal key and root token in command output sample * remove lines from sample output * fix front matter * move nomad pack tutorials to tools * search/replace /nomad/tutorials links * update acl overview with content from deleted architecture/acl * fix spelling mistake * linkcheck - fix broken links * fix link to Nomad variables tutorial * fix link to Prometheus tutorial * move who uses Nomad to use cases page; move spec/config shortcuts add dividers * Move Consul out of Integrations; move namespaces to govern * move integrations/vault to secure/vault; delete integrations * move ref arch to docs; rename Deploy Nomad back to Install Nomad * address feedback * linkcheck fixes * Fixed raw_exec redirect * add info from /nomad/tutorials/manage-jobs/jobs * update page content with newer tutorial * link updates for architecture sub-folders * Add redirects for removed section index pages. Fix links. * fix broken links from linkcheck * Revert to use dev-portal main branch instead of nomadIA branch * build workaround: add intro-nav-data.json with single entry * fix content-check error * add intro directory to get around Vercel build error * workound for emtpry directory * remove mdx from /intro/ to fix content-check and git snafu * Add intro index.mdx so Vercel build should work --------- Co-authored-by: Tu Nguyen <im2nguyen@gmail.com>
95 lines
3.0 KiB
Plaintext
95 lines
3.0 KiB
Plaintext
---
|
|
layout: docs
|
|
page_title: cidrsubnets - Functions - Configuration Language
|
|
description: |-
|
|
The cidrsubnets function calculates a sequence of consecutive IP address
|
|
ranges within a particular CIDR prefix.
|
|
---
|
|
|
|
# `cidrsubnets` Function
|
|
|
|
`cidrsubnets` calculates a sequence of consecutive IP address ranges within
|
|
a particular CIDR prefix.
|
|
|
|
```hcl
|
|
cidrsubnets(prefix, newbits...)
|
|
```
|
|
|
|
`prefix` must be given in CIDR notation, as defined in
|
|
[RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).
|
|
|
|
The remaining arguments, indicated as `newbits` above, each specify the number
|
|
of additional network prefix bits for one returned address range. The return
|
|
value is therefore a list with one element per `newbits` argument, each
|
|
a string containing an address range in CIDR notation.
|
|
|
|
For more information on IP addressing concepts, see the documentation for the
|
|
related function [`cidrsubnet`](/nomad/docs/reference/hcl2/functions/ipnet/cidrsubnet). `cidrsubnet` calculates
|
|
a single subnet address within a prefix while allowing you to specify its
|
|
subnet number, while `cidrsubnets` can calculate many at once, potentially of
|
|
different sizes, and assigns subnet numbers automatically.
|
|
|
|
When using this function to partition an address space as part of a network
|
|
address plan, you must not change any of the existing arguments once network
|
|
addresses have been assigned to real infrastructure, or else later address
|
|
assignments will be invalidated. However, you _can_ append new arguments to
|
|
existing calls safely, as long as there is sufficient address space available.
|
|
|
|
This function accepts both IPv6 and IPv4 prefixes, and the result always uses
|
|
the same addressing scheme as the given prefix.
|
|
|
|
## Examples
|
|
|
|
```shell-session
|
|
> cidrsubnets("10.1.0.0/16", 4, 4, 8, 4)
|
|
[
|
|
"10.1.0.0/20",
|
|
"10.1.16.0/20",
|
|
"10.1.32.0/24",
|
|
"10.1.48.0/20",
|
|
]
|
|
|
|
> cidrsubnets("fd00:fd12:3456:7890::/56", 16, 16, 16, 32)
|
|
[
|
|
"fd00:fd12:3456:7800::/72",
|
|
"fd00:fd12:3456:7800:100::/72",
|
|
"fd00:fd12:3456:7800:200::/72",
|
|
"fd00:fd12:3456:7800:300::/88",
|
|
]
|
|
```
|
|
|
|
You can use nested `cidrsubnets` calls with
|
|
[`for` expressions](/nomad/docs/reference/hcl2/expressions#for-expressions)
|
|
to concisely allocate groups of network address blocks:
|
|
|
|
```shell-session
|
|
> [for cidr_block in cidrsubnets("10.0.0.0/8", 8, 8, 8, 8) : cidrsubnets(cidr_block, 4, 4)]
|
|
[
|
|
[
|
|
"10.0.0.0/20",
|
|
"10.0.16.0/20",
|
|
],
|
|
[
|
|
"10.1.0.0/20",
|
|
"10.1.16.0/20",
|
|
],
|
|
[
|
|
"10.2.0.0/20",
|
|
"10.2.16.0/20",
|
|
],
|
|
[
|
|
"10.3.0.0/20",
|
|
"10.3.16.0/20",
|
|
],
|
|
]
|
|
```
|
|
|
|
## Related Functions
|
|
|
|
- [`cidrhost`](/nomad/docs/reference/hcl2/functions/ipnet/cidrhost) calculates the IP address for a single host
|
|
within a given network address prefix.
|
|
- [`cidrnetmask`](/nomad/docs/reference/hcl2/functions/ipnet/cidrnetmask) converts an IPv4 network prefix in CIDR
|
|
notation into netmask notation.
|
|
- [`cidrsubnet`](/nomad/docs/reference/hcl2/functions/ipnet/cidrsubnet) calculates a single subnet address, allowing
|
|
you to specify its network number.
|