# AWS VPC subnet calculator (CIDR)

Free, in your browser · AWS rules: /16 to /28, 5 reserved addresses per subnet

## Subnet calculator

Everything is calculated in your browser; nothing is sent to us or stored.

Screenshot: VPC IP usage: subnets with free addresses, two nearly full, and an overlapping CIDR block

In the CloudConsole app

## Run this on your own account

Once the subnets exist, VPC IP usage in the app shows each one’s free addresses against its usable size, flags subnets 80% full or more, and finds CIDR blocks that overlap between your VPCs, across regions and accounts.

[How VPC IP usage works →](https://cloudconsole.dev/app-tools/aws-subnet-ip-usage)

[Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710) · [Get it on Google Play](https://play.google.com/store/apps/details?id=com.cloudconsole.app)

**Short answer**

An AWS subnet can be any size from /16 to /28, and AWS reserves 5 addresses in every subnet: the network address, the VPC router (base + 1), the DNS server (base + 2), one for future use (base + 3) and the last address. So a /24 has 251 usable addresses on AWS, not 254, and the smallest subnet, a /28, has 11.

## The 5 reserved IP addresses in every AWS subnet

AWS documents the reserved addresses with this example for a subnet with CIDR block `10.0.0.0/24`. None of them can be assigned to an EC2 instance, a load balancer or any other network interface.

| Address | Reserved for |
|---|---|
| `10.0.0.0` | Network address |
| `10.0.0.1` | The VPC router |
| `10.0.0.2` | The Amazon DNS server. The resolver is at the VPC’s primary CIDR base + 2; AWS also reserves base + 2 in every subnet. |
| `10.0.0.3` | Future use |
| `10.0.0.255` | Network broadcast address. VPCs don’t support broadcast, but the address is still reserved. |

The usable range of `10.0.0.0/24` on AWS is therefore `10.0.0.4` to `10.0.0.254`. Addresses you bring to AWS with BYOIP are the exception: in those ranges you can use the first and last address too.

## AWS subnet sizes and usable IP addresses

Every IPv4 prefix AWS accepts for a subnet, with the total number of addresses, the number you can actually assign on AWS, and the usual count on a traditional network (total minus network and broadcast) for comparison.

| Prefix | Subnet mask | Total | Usable on AWS | Usable elsewhere |
|---|---|---|---|---|
| `/16` | `255.255.0.0` | 65,536 | **65,531** | 65,534 |
| `/17` | `255.255.128.0` | 32,768 | **32,763** | 32,766 |
| `/18` | `255.255.192.0` | 16,384 | **16,379** | 16,382 |
| `/19` | `255.255.224.0` | 8,192 | **8,187** | 8,190 |
| `/20` | `255.255.240.0` | 4,096 | **4,091** | 4,094 |
| `/21` | `255.255.248.0` | 2,048 | **2,043** | 2,046 |
| `/22` | `255.255.252.0` | 1,024 | **1,019** | 1,022 |
| `/23` | `255.255.254.0` | 512 | **507** | 510 |
| `/24` | `255.255.255.0` | 256 | **251** | 254 |
| `/25` | `255.255.255.128` | 128 | **123** | 126 |
| `/26` | `255.255.255.192` | 64 | **59** | 62 |
| `/27` | `255.255.255.224` | 32 | **27** | 30 |
| `/28` | `255.255.255.240` | 16 | **11** | 14 |

## How to plan VPC subnets

- **Pick a VPC block that won’t collide.** AWS recommends a private RFC 1918 range. VPC peering, Transit Gateway and Direct Connect gateways need CIDR blocks that don’t overlap, so give each VPC and environment its own range, separate from your office or VPN networks.
- **One subnet per tier per Availability Zone.** A subnet lives in a single Availability Zone, so a highly available layout repeats each tier (public, private, database) in two or three AZs. That’s what the calculator’s “by subnet size and tier” mode builds.
- **Size for growth, not for today.** An existing subnet can’t be resized. Load balancers, NAT gateways, VPC endpoints, Lambda functions attached to the VPC and EKS pods using the VPC CNI all take addresses from your subnets, so private subnets usually need far more room than public ones.
- **Leave space unallocated.** Keeping part of the VPC free lets you add a tier or an AZ later without re-addressing. If you do run out, you can associate a secondary IPv4 CIDR block with the VPC and create new subnets from it.

## Allowed VPC CIDR blocks

A VPC’s IPv4 CIDR block must be between /16 and /28. AWS recommends a block from the RFC 1918 private ranges:

| RFC 1918 range | Example VPC block |
|---|---|
| `10.0.0.0/8` | `10.0.0.0/16` |
| `172.16.0.0/12` | `172.31.0.0/16` |
| `192.168.0.0/16` | `192.168.0.0/20` |

You can’t use `0.0.0.0/8`, `127.0.0.0/8` (loopback), `169.254.0.0/16` (link-local) or `224.0.0.0/4` (multicast). AWS also advises against `172.17.0.0/16`, which Docker and services such as AWS Cloud9 and Amazon SageMaker AI use. A publicly routable block outside RFC 1918 is allowed, but the VPC then treats those addresses as local. If you give the API a block with host bits set, AWS stores the canonical form: `100.68.0.18/18` becomes `100.68.0.0/18`.

## Subnets in Terraform and CloudFormation

The calculator writes out each subnet with a literal CIDR block, which is easiest to review. Both tools can also compute the blocks for you. In Terraform, `cidrsubnet(prefix, newbits, netnum)` adds `newbits` to the prefix length and picks block number `netnum`:

```
cidrsubnet("10.0.0.0/16", 4, 0)   # "10.0.0.0/20"
cidrsubnet("10.0.0.0/16", 4, 1)   # "10.0.16.0/20"
cidrsubnet("10.0.0.0/16", 8, 10)  # "10.0.10.0/24"
```

In CloudFormation, `Fn::Cidr` returns a list of blocks. Its third argument is the number of host bits, not the prefix length, so a /20 is 12 (32 − 20). It can return 1 to 256 blocks:

```
CidrBlock: !Select [0, !Cidr [!GetAtt VPC.CidrBlock, 6, 12]]   # 10.0.0.0/20 in 10.0.0.0/16
```

The generated code spreads subnets over Availability Zones with `data.aws_availability_zones` in Terraform and `!GetAZs ""` in CloudFormation, so it works in any region with enough AZs.

## Questions

### How many usable IP addresses are in a /24 subnet on AWS?

251. A /24 has 256 addresses and AWS reserves 5 in every subnet: the network address, the VPC router (base + 1), the DNS server (base + 2), one held for future use (base + 3) and the last address. Outside AWS a /24 usually gives 254.

### Why does AWS reserve 5 IP addresses in each subnet?

The first address is the network address and the last is the broadcast address, which a VPC doesn’t support but still reserves. The other three are taken by AWS: base + 1 for the VPC router, base + 2 for the Amazon DNS server and base + 3 for future use. None of them can be assigned to an instance or network interface.

### What are the smallest and largest subnets AWS allows?

An IPv4 subnet can be anything from a /28 (16 addresses, 11 usable) to a /16 (65,536 addresses, 65,531 usable). A VPC CIDR block has the same /16 to /28 limits, so a single subnet can be as large as the whole VPC.

### Can I make a subnet bigger after creating it?

No. There is no way to resize an existing subnet’s IPv4 CIDR block. Create a new, larger subnet and move resources to it; if the VPC is full, associate a secondary IPv4 CIDR block with the VPC first and create the new subnet from that.

### Which CIDR block should I use for a new VPC?

AWS recommends a private range from RFC 1918: 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Pick a block that doesn’t overlap your office network or any VPC you may peer or connect through a Transit Gateway later, and avoid 172.17.0.0/16, which Docker and some AWS services use.

### Does the calculator handle IPv6 subnets?

It splits IPv4 blocks only. AWS IPv6 subnets are /44 to /64 in steps of /4, usually /64, and AWS reserves the first four and the last address of each IPv6 subnet in the same way.

**Keep an eye on what runs in those subnets**

CloudConsole puts alarms, logs, costs and resources from every AWS account and region on your iPhone or Android phone, with credentials that never leave the device.

[About the app →](https://cloudconsole.dev/aws-console-app)

## Sources

- [Subnet CIDR blocks (Amazon VPC User Guide)](https://docs.aws.amazon.com/vpc/latest/userguide/subnet-sizing.html)
- [VPC CIDR blocks (Amazon VPC User Guide)](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-cidr-blocks.html)
- [Fn::Cidr (AWS CloudFormation)](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-cidr.html)
- [cidrsubnet function (Terraform)](https://developer.hashicorp.com/terraform/language/functions/cidrsubnet)

## Related

- [aws ec2 describe-subnets](https://cloudconsole.dev/cli/ec2-describe-subnets) – AWS CLI commands
- [aws ec2 describe-vpcs](https://cloudconsole.dev/cli/ec2-describe-vpcs) – AWS CLI commands
- [VPC Flow Logs rejected traffic in Logs Insights](https://cloudconsole.dev/logs-insights/vpc-flow-logs-rejected-traffic) – Logs Insights queries
- [CloudWatch alarm: NAT Gateway ErrorPortAllocation](https://cloudconsole.dev/alarms/nat-gateway-errorportallocation) – CloudWatch alarms
- [AWS IP address lookup](https://cloudconsole.dev/tools/aws-ip-lookup) – Free tools
- [AWS latency test](https://cloudconsole.dev/tools/aws-latency-test) – Free tools

---

Source: https://cloudconsole.dev/tools/aws-subnet-calculator

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
