IPv4 Subnetting, CIDR Prefix Allocation & VLSM Design
The 32-bit IPv4 address space (4,294,967,296 total addresses) is finite and mathematically constrained. Classless Inter-Domain Routing (CIDR, RFC 1519) and Variable Length Subnet Masking (VLSM) prevent global routing table explosion and allow engineers to allocate precisely sized subnets with minimal wasted host space.
- Convert fluently between Dotted-Decimal Netmasks and CIDR prefix notation (/n).
- Compute Network Address, Broadcast Address, and First/Last Usable Host IP using bitwise AND algebra.
- Design multi-department VLSM hierarchical address allocations without overlap.
- Calculate wildcard masks and route summarization supernets for router ACLs and OSPF/BGP routing protocols.
- Binary place-value arithmetic (powers of 2: 128, 64, 32, 16, 8, 4, 2, 1).
- Bitwise Boolean operations: AND (&), OR (|), NOT (~).
- Understanding of OSI Layer 3 (IP) vs Layer 2 (MAC) packet routing.
The Problem: Allows organizations to size subnets to their exact host counts, prolonging IPv4 viability and keeping global BGP routing tables compact.
Historical Context: In the early 1990s, classful addressing (Class A = 16 million hosts, Class B = 65,536 hosts, Class C = 254 hosts) caused massive waste. A company needing 500 IP addresses was forced to take an entire Class B block, leaving 65,000 addresses unused. CIDR eliminated classes and permitted arbitrary prefix masks like /23 (510 hosts).
Think of an IPv4 address like a full postal address. The Network ID prefix is the city and street name. The Host ID suffix is the apartment number inside the building. The Subnet Mask is a stencil: holding the stencil over the address reveals which characters tell the delivery truck which building to drive to (routing), and which characters tell the mail carrier which specific mailbox to drop the letter into.
Seedhi bhasha mein: IPv4 address 32 bits ka hota hai, jisko hum 4 octets mein likhte hain (jaise 192.168.1.100). Har address do hisson se banta hai: Network ID (mohalla/colony) aur Host ID (house number). Subnet mask ka kaam ye batana hai ki kahan tak Network ID hai aur kahan se Host ID shuru hota hai. CIDR notation `/24` ka matlab pehle 24 bits 1s hain (network), aur bache hue 8 bits 0s hain (hosts). Subnet mein Total Hosts = 2^h hote hain, lekin Usable Hosts hamesha 2^h - 2 hote hain, kyunki pehla address Network ID hota hai aur aakhri address Broadcast ID hota hai—ye dono kisi computer ko assign nahi ho sakte!
Every IPv4 router inspects arriving IP packets and performs a bitwise AND between the destination IP address and its interface netmasks to perform Longest Prefix Match (LPM) lookups in the forwarding information base (FIB). The boundary between network and host can fall at any bit position, not just octet boundaries.
| Metric | Classful (Legacy) | CIDR (RFC 1519) | VLSM (Subnetting) |
|---|---|---|---|
| Mask Flexibility | Rigid (/8, /16, /24) | Arbitrary prefix (/0 to /32) | Different mask per subnet |
| Address Waste | > 90% in Class B | < 10% waste | Near zero waste |
| Routing Table Impact | Explosive growth | Aggregated Supernets | Hierarchical internal summarization |
| Protocol Support | RIPv1, IGRP (No mask sent) | BGP-4, OSPFv2, EIGRP | OSPF, IS-IS, EIGRP |
CIDR and VLSM trade routing protocol complexity for near-perfect IPv4 utilization and compact BGP forwarding tables.