Subnets (Public vs. Private) & CIDR Blocks
Subnets are logical subdivisions of a VPC's IP address range. They allow you to organize your network and control traffic flow. Public subnets have direct internet access through an Internet Gateway, while private subnets require NAT Gateway or NAT Instance for outbound internet connectivity.
Public Subnets
Public subnets have a route to an Internet Gateway in their route table. This allows resources in public subnets to have direct internet access. Public subnets are typically used for load balancers, NAT Gateways, and bastion hosts.
Private Subnets
Private subnets do not have a route to an Internet Gateway. Resources in private subnets cannot directly access the internet. For outbound internet access, they require a NAT Gateway or NAT Instance. Private subnets are used for application servers, databases, and other resources that should not be directly accessible from the internet.
CIDR Blocks
CIDR (Classless Inter-Domain Routing) blocks define the IP address range for your VPC and subnets. CIDR notation uses IP address and prefix length, like 10.0.0.0/16, where /16 means the first 16 bits are the network portion. Common CIDR blocks include /16 (65,536 IPs), /24 (256 IPs), and /28 (16 IPs). AWS reserves 5 IPs in each subnet, so a /24 subnet has 251 usable IPs.
