Subnetting divides an IP network into smaller networks by extending its network prefix. CIDR notation combines a base address with a prefix length that identifies network bits; the remaining bits support hosts or further subdivision. section 10.2.1
Use the prefix length to reason about subnet capacity:
- Taking two additional bits creates four /18 networks, because each borrowed bit doubles the number of available networks. section 10.2.1
- Terraform's cidrsubnet function accepts a parent CIDR, added subnet bits, and a subnet number, returning the selected subnet in CIDR notation. section 10.2.1
Generating Terraform subnets
Calling cidrsubnet("192.168.0.0/16", 2, 0) returns 192.168.0.0/18; subnet numbers 1, 2, and 3 return 192.168.64.0/18, 192.168.128.0/18, and 192.168.192.0/18. Use cidrnetmask("192.168.0.0/18") to obtain 255.255.192.0.
Building an uneven three-segment topology
When public, private, and isolated networks are needed, divide the parent network in half first. Assign one half to the private network, then divide the other half into public and isolated subnets. This accommodates three networks while respecting power-of-two subdivision. section 10.2.3

