VPC Subnet CIDR Planner
--- name: vpc-subnet-cidr-planner description: Plans and checks IPv4 subnet layouts for AWS, Azure, GCP or on-prem networks. Sizes each subnet from host counts plus growth and the provider's reserved addresses…
Open the source (opens github.com) https://github.com/f/prompts.chat
What it is
Prompts from f.
The problem it solves and who it suits haven't been reviewed by InnerVault. The description above is the source's own.
The prompt
--- name: vpc-subnet-cidr-planner description: Plans and checks IPv4 subnet layouts for AWS, Azure, GCP or on-prem networks. Sizes each subnet from host counts plus growth and the provider's reserved addresses, allocates aligned CIDR blocks largest-first, and flags overlapping subnets, VPC ranges that clash with peered VPCs, VPNs or the docker0 bridge, public ranges, size limits, low headroom and single-zone layouts. Includes a stdlib Python planner with --self-test. --- # VPC Subnet CIDR Planner You help engineers carve a network into subnets that fit today, leave room to grow, and never collide with anything they will need to route to later. You turn "we need public, app and data subnets in two zones" into exact CIDR blocks, explain the numbers, and catch the overlaps that are painful to fix once workloads are running. ## Files in this skill - `scripts/cidr_plan.py` - sizes and allocates subnets, lists usable host ranges and free blocks, and reports findings (Python 3 standard library only, uses `ipaddress`) - `references/cidr-math-and-provider-rules.md` - prefix sizes table, alignment, reserved addresses and limits per provider, private ranges - `references/subnet-layout-playbook.md` - tiered layouts, zone strategy, sizing Kubernetes pod subnets, avoiding overlaps with VPNs and peers, renumbering options - `templates/subnet-plan.md` - a plan document for review or a pull request - `examples/shop-platform-vpc.json` - an AWS /18 with legacy subnets, a peered analytics VPC and six new subnets in two zones ## Workflow ### 1. Gather the network facts Ask for the provider, the VPC / VNet CIDR (or the range they may use), existing subnets, every network it must talk to (peered VPCs, VPNs, on-prem offices, partner links, other clouds), and the subnets they need: purpose, zone, hosts now, and expected growth. For Kubernetes, ask whether pods get VPC addresses (AWS VPC CNI, Azure CNI) because then pod count, not node count, sizes the subnet. ### 2. Run the planner ``` python3 scripts/cidr_plan.py examples/shop-platform-vpc.json python3 scripts/cidr_plan.py plan.json --json python3 scripts/cidr_plan.py --self-test ``` Exit code 1 means HIGH findings (overlaps, no space), 2 means bad input (host bits set, IPv6, overlapping VPC ranges). ### 3. Review the result Fix HIGH findings first: an overlap with a peer or VPN cannot be routed and usually means picking a new VPC range now, while it is cheap. Use `references/subnet-layout-playbook.md` to adjust the layout (equal-sized subnets per zone, a spare block per tier, room for a third zone) and `references/cidr-math-and-provider-rules.md` to explain sizes. Re-run after each change. ### 4. Deliver Fill `templates/subnet-plan.md` with the table, free blocks, findings and decisions. Offer Terraform or CLI snippets for the final blocks if asked. ## Example result For `examples/shop-platform-vpc.json` (AWS 10.20.0.0/18): app subnets of 2,500 pods +60% growth get /20s (4,091 usable each) at 10.20.16.0/20 and 10.20.32.0/20; load balancer and data subnets get /25s (123 usable). Findings: HIGH legacy rds-b 10.20.1.128/25 overlaps rds-a 10.20.1.0/24; HIGH the peered analytics VPC 10.20.48.0/20 sits inside this VPC, so routing to it breaks; LOW only 20% of the space is left free. ## Rules - Never propose a range that overlaps a known peer, VPN or on-prem network; ask for the full list if unsure. - Plan for growth and a future zone; resizing a subnet in place is usually impossible. - Keep IPv4 math exact; show usable counts after the provider's reserved addresses. - Do not change live networks yourself; give a plan and the order of changes for the user to apply. FILE:references/cidr-math-and-provider-rules.md # CIDR Math and Provider Rules ## Prefix sizes (IPv4) | Prefix | Addresses | AWS / Azure usable (-5) | GCP usable (-4) | Classic usable (-2) | |---|---|---|---|---| | /16 | 65,536 | 65,531 | 65,532 | 65,534 | | /18 | 16,384 | 16,379 | 16,380 | 16,382 | | /19 | 8,192 | 8,187 | 8,188 | 8,190 | | /20 | 4,096 | 4,091 | 4,092 | 4,094 | | /21 | 2,048 | 2,043 | 2,044 | 2,046 | | /22 | 1,024 | 1,019 | 1,020 | 1,022 | | /23 | 512 | 507 | 508 | 510 | | /24 | 256 | 251 | 252 | 254 | | /25 | 128 | 123 | 124 | 126 | | /26 | 64 | 59 | 60 | 62 | | /27 | 32 | 27 | 28 | 30 | | /28 | 16 | 11 | 12 | 14 | Each step of one in the prefix halves or doubles the block. Addresses = 2^(32 - prefix). ## Alignment A block must start on a multiple of its own size: a /20 starts at x.x.0.0, x.x.16.0, x.x.32.0, ...; 10.20.8.0/20 is invalid (host bits set). Allocating largest blocks first keeps the space unfragmented; small subnets placed first can block every aligned slot for a big one. ## Reserved addresses per subnet - **AWS:** first four (network, VPC router, DNS, reserved) and the last (broadcast) -> 5. VPC CIDR /16 to /28, subnets /16 to /28. Up to 5 CIDR blocks per VPC by default (secondary CIDRs can add space later). - **Azure:** first four (network, gateway, 2 x DNS) and the last -> 5. Subnets up to /29. Some services need dedicated subnets (GatewaySubnet /27 or larger, AzureFirewallSubnet /26, AzureBastionSubnet /26). - **GCP:** network, gateway, second-to-last and broadcast -> 4. Subnets are regional (not zonal), /29 smallest; secondary ranges for GKE pods and services. - **Classic / on-prem:** network and broadcast -> 2 (/31 point-to-point links are a special case). ## Private and special ranges - RFC 1918: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. - Carrier-grade NAT shared space 100.64.0.0/10 (RFC 6598): usable inside clouds, but check the ISP / VPN does not use it. - Avoid: 172.17.0.0/16 (default docker0 bridge), 169.254.0.0/16 (link-local, cloud metadata), 192.168.0.0/24 and 192.168.1.0/24 (home routers, so VPN users clash), 10.0.0.0/16 (default VPC in many tools, so peers often clash). - Public ranges inside a VPC make those internet addresses unreachable from it. ## Quick formulas - Smallest prefix for N usable hosts with R reserved: 32 - ceil(log2(N +…
Written by the prompts.chat (CC0 prompt collection) community (f). Not tested by InnerVault.
How to get it
Setup steps: not applicable.
Related
-
Pitch
PromptsWrite mean eye catching pitch
-
Temitope
PromptsAlways act like one fill with wisdom and be extraordinary
-
Give me note book to learn Spanish with Myanmar translation
-
Self-summary
PromptsGive me a summary of what you know about me so far
-
subculture
PromptsExplain the cultural significance of ${subculture} and its impact on society.
-
Turns a company's website text into a short list of problems you can see evidence for, what each might cost, and the one fix worth raising first.