CloudConsole

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.

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.

AddressReserved for
10.0.0.0Network address
10.0.0.1The VPC router
10.0.0.2The 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.3Future use
10.0.0.255Network 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.

PrefixSubnet maskTotalUsable on AWSUsable elsewhere
/16255.255.0.065,53665,53165,534
/17255.255.128.032,76832,76332,766
/18255.255.192.016,38416,37916,382
/19255.255.224.08,1928,1878,190
/20255.255.240.04,0964,0914,094
/21255.255.248.02,0482,0432,046
/22255.255.252.01,0241,0191,022
/23255.255.254.0512507510
/24255.255.255.0256251254
/25255.255.255.128128123126
/26255.255.255.192645962
/27255.255.255.224322730
/28255.255.255.240161114

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 rangeExample VPC block
10.0.0.0/810.0.0.0/16
172.16.0.0/12172.31.0.0/16
192.168.0.0/16192.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 →

Sources