How do subnets relate to availability zones, and how many addresses do you lose in each subnet?
Show the answer
Say this first
In AWS a subnet lives in exactly one availability zone, so for high availability you build one subnet per tier per AZ. Azure and GCP subnets are regional and span zones. AWS and Azure reserve 5 addresses in every subnet and GCP reserves 4, so a /28 in AWS gives 11 usable addresses, not 14.
Go deeper
AWS
A subnet is tied to one AZ (us-east-1a, for example). A typical layout for two AZs:
| Subnet | AZ | CIDR |
|---|---|---|
| public-a | us-east-1a | 10.10.0.0/24 |
| public-b | us-east-1b | 10.10.1.0/24 |
| private-a | us-east-1a | 10.10.10.0/24 |
| private-b | us-east-1b | 10.10.11.0/24 |
Reserved in 10.10.10.0/24: .0 network, .1 VPC router, .2 Amazon DNS, .3 reserved for future
use, .255 broadcast (broadcast is not supported, but the address is still held back).
Subnet size is /16 to /28.
Azure
A subnet spans all zones in the region; you pick the zone per VM or per zonal resource. Azure reserves
.0 network, .1 default gateway, .2 and .3 for Azure DNS mapping, and the last address.
The smallest subnet is /29. Some services need a dedicated subnet with a fixed name, such as
GatewaySubnet for VPN and ExpressRoute gateways and AzureFirewallSubnet for Azure Firewall.
GCP
Subnets are regional. GCP reserves the network address, the gateway (.1), the second-to-last
address and the broadcast address in the primary range.
They will ask next
Why not use one big subnet per tier in AWS?
You cannot: a subnet cannot cross AZs. And if all instances sat in one AZ, losing that AZ would take the tier down. One subnet per tier per AZ is the normal pattern.
How many usable addresses are in an AWS /27?
32 minus 5 reserved, so 27.
Traps
- Forgetting the 5 reserved addresses when sizing small subnets for load balancers or endpoints.
- Assuming Azure subnets are zonal like AWS subnets.