VPC CIDRs, subnets and routes
A private network for your application
A Virtual Private Cloud (VPC) is a logically separated network in AWS. It spans a Region; each subnet belongs to one Availability Zone (AZ). Imagine a bookstore with separate web and application servers. Assign them addresses in distinct subnets so you can control paths between them. The examples use fictional resources in the commercial partition, illustrative Region us-east-1; nothing is deployed.
Read an IP address and prefix
IPv4 addresses contain 32 bits; IPv6 addresses contain 128 bits. CIDR writes an address range as a network address followed by a slash and the number of fixed leading bits. In 10.42.0.0/16, the first 16 bits identify the network. A /24 IPv4 range contains 2^(32−24) = 256 addresses. In an ordinary AWS IPv4 subnet, five addresses are reserved (the first four and last), leaving 251 assignable addresses before other allocations. Do not apply ordinary LAN rules that subtract only two. BYOIP has special rules outside this lesson.
Plan four non-overlapping subnets
Use one VPC range and four distinct /24 ranges. The public and application subnets in each AZ are separate; an AZ failure need not affect both copies, provided the application is actually redundant. The labels A and B are fictional AZ labels, not account-specific AZ identifiers. Every listed range fits within the VPC. Avoid overlap with networks you may later connect.
VPC 10.42.0.0/16AZ A: public 10.42.1.0/24 | app 10.42.11.0/24AZ B: public 10.42.2.0/24 | app 10.42.12.0/24Network interfaces and route selection
An elastic network interface (ENI) is a virtual network interface attached to a resource, with private addresses and associated security groups. Each subnet uses one route table (explicitly associated or the main table). Routes match destination ranges and choose targets. For the simplified table below, the more specific /16 wins over /0, so 10.42.12.20 follows the local route, while 203.0.113.8 selects NAT. The latter is a documentation address, not a real test destination. Equal-prefix and propagated route priorities are beyond this model.
10.42.0.0/16 -> local0.0.0.0/0 -> nat-aPublic, private and IPv6 subnets
A public subnet has a direct route to an internet gateway; this alone does not give a resource a public IP or permission to receive traffic. A private subnet has no direct route to that gateway; it may still have controlled outbound paths. IPv4 and IPv6 have separate routing entries. 0.0.0.0/0 covers IPv4 and ::/0 covers IPv6. For an IPv6 example, a documentation-only /56 can be split into 256 /64 ranges; /64 is a teaching choice, not the only supported AWS subnet size. Verify actual allocated IPv6 ranges and routability before deployment.
2001:db8:42:100::/562001:db8:42:101::/642001:db8:42:102::/64Practice and common mistakes
Split 10.42.30.0/24 into two /25 networks, then calculate assignable addresses for each. Check the boundary: the second range starts at .128; each contains 128 addresses, 123 assignable under the ordinary AWS rule. Do not assume route selection is proof of connectivity. Next, learn how gateways and endpoints supply the next hop. The offline lab checks containment, overlap and longest-prefix selection.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
VPC CIDRs, subnets and routes — knowledge check
Apply the lesson concepts to the fictional VPC.
A VPC spans two AZs. Which statement about one subnet is true?
How many assignable addresses are in an ordinary AWS IPv4 /25 subnet before allocations?
Which pair divides 10.42.30.0/24 without overlap?
A table has 10.42.0.0/16 local and 0.0.0.0/0 NAT. Where does 10.42.12.20 match?
What does a direct route to an internet gateway establish about a subnet?