Subnets & Subnetting Fundamentals
Master network subnetting, dividing VPC address spaces, calculating network and broadcast boundaries, and isolating public vs private subnets.
What is a Subnet?
A Subnet (Subnetwork) is a logical subdivision of an IP network. Subnetting splits a large network block into smaller, isolated segments to improve network performance, reduce broadcast congestion, and enforce security boundaries.
Example: Subnetting a /16 VPC into /24 Subnets
Suppose your organization has allocated a 10.0.0.0/16 Virtual Private Cloud (VPC):
Parent VPC Network: 10.0.0.0/16 (65,536 addresses)
│
├── Subnet 1 (Public Web DMZ): 10.0.1.0/24 (10.0.1.1 - 10.0.1.254)
├── Subnet 2 (Private App Tier): 10.0.2.0/24 (10.0.2.1 - 10.0.2.254)
├── Subnet 3 (Private Database): 10.0.3.0/24 (10.0.3.1 - 10.0.3.254)
└── Subnet 4 (Internal Cache Tier): 10.0.4.0/24 (10.0.4.1 - 10.0.4.254)Public vs Private Subnets
- Public Subnet: Connected directly to an Internet Gateway (IGW). Resources placed here (e.g. Load Balancers, NGINX gateways) receive public IPv4 addresses and can receive incoming traffic from the internet.
- Private Subnet: Has no direct route to the Internet Gateway. Outbound internet access (for package updates) is routed through a NAT Gateway. Inbound direct internet connections are completely blocked.
Step-by-Step Subnet Calculation
For subnet 192.168.10.0/26:
- Prefix Length:
/26bits for network $\rightarrow 32 - 26 = 6$ bits for hosts. - Total Addresses: $2^6 = 64$ addresses.
- Subnet Mask:
255.255.255.192($128 + 64 = 192$). - Network Address:
192.168.10.0(Cannot be assigned to a host). - Broadcast Address:
192.168.10.63(Cannot be assigned to a host). - Usable Host Range:
192.168.10.1through192.168.10.62(62 usable host machines).
CIDR Notation & IP Block Fundamentals
Master Classless Inter-Domain Routing (CIDR), prefix lengths (/24, /16, /8), subnet masks, and address range calculations.
localhost (127.0.0.1) vs 0.0.0.0 Binding
Understand network interface binding, why binding to 127.0.0.1 breaks Docker containers and mobile testing, and when to use 0.0.0.0.