At the heart of network routing lies the IP address. For senior engineers, moving beyond simple IP assignment to understanding subnetting efficiency is crucial, especially in cloud infrastructure (AWS VPC, Kubernetes networking).
IPv4 and Classful vs. CIDR
Originally, IPv4 addresses were divided into Classes (A, B, C, D, E). This was inefficient. CIDR (Classless Inter-Domain Routing) replaced this, allowing flexible subnet masking.
CIDR notation uses a suffix (e.g., /24) to indicate the number of bits used for the network portion of the address. The remaining bits are for hosts.
- /24: 255.255.255.0 (256 IPs, 254 usable)
- /20: 255.255.240.0 (4,096 IPs)
- /32: Single host IP
Subnet Calculation Logic
To find the Network ID, perform a bitwise AND between the IP address and the Subnet Mask.