CIDR and IPv4 Subnetting Explained

CIDR (Classless Inter-Domain Routing), defined in RFC 4632, replaced the older classful addressing scheme (Class A, B, C) to provide more efficient IP address allocation. A CIDR notation like 192.168.1.0/24 represents a network where the first 24 bits are the network prefix, and the remaining 8 bits are for host addresses.

The 32-bit IPv4 Address Space

IPv4 addresses are 32-bit numbers, expressed as four octets (8 bits each) in dotted-decimal notation. This gives a total address space of approximately 4.3 billion unique addresses (2^32). The exhaustion of this space is why IPv6 was developed.

How Bitwise Masking Works

A subnet mask determines which portion of an IP address identifies the network and which identifies the host. For /24, the mask is 255.255.255.0 (binary: 11111111.11111111.11111111.00000000). The network address is calculated by applying the AND operation between the IP and the mask.

VLSM (Variable Length Subnet Masking)

VLSM allows subnets of different sizes within the same network, enabling more efficient use of IP address space. A /26 network (255.255.255.192) gives 4 subnets of 62 usable hosts each.

Usable Hosts

In any subnet, two addresses are reserved: the network address (all host bits = 0) and the broadcast address (all host bits = 1). For a /24, this means 254 usable hosts out of 256 total addresses.