Rasmus Emilsson

IT Security and Infrastructure

Understanding CIDR: Network Mask Demystified

During my years in University and later my professional life, concepts have arisen that have stumped me, flabbergasted me and made me want to rip my hair out. This site aims to lessen the pains of the most fundamental parts of IT and Cybersecurity.

Understanding CIDR: Network Mask Demystified

The first encounter with an IP address followed by a slash and a number as a new student, such as 192.168.1.0/24, was a bit perplexing. CIDR notation is however a cornerstone of modern network design, known as Classless Inter-Domain Routing, or CIDR.

Historically, networks were constrained by rigid class-based systems (A, B, or C). This approach proved incredibly inefficient, leading to significant wastage of precious IP addresses. CIDR revolutionized this by enabling network administrators to define network segments (subnets) with far greater precision, optimizing address allocation and enhancing network flexibility.

Deconstructing the Network Mask

The number following the slash, often referred to as the CIDR value or "prefix length," is essentially a shorthand. It explicitly states how many bits of the 32-bit IP address are designated for the network identifier. The remaining bits are then allocated to identify individual hosts within that network.

Let's illustrate with some clear examples, using the network 192.168.1.0 to show how a single octet can be divided.

The /24: This is a classic example where the first three octets are for the network. The network mask is 255.255.255.0, which leaves 8 bits for host addresses. This allows for 254 usable hosts.

The /25: Here, we've taken one more bit for the network. The network mask becomes 255.255.255.128. This change halves the available hosts, leaving 126 usable addresses per subnet.

The /26: Taking another bit for the network results in a mask of 255.255.255.192. This further divides the network, providing 62 usable addresses per subnet.

As you can see, the relationship between the CIDR value and network size is quite direct: a larger CIDR number implies more bits are dedicated to the network, consequently reducing the number of available host addresses.

While CIDR might initially appear complex, understanding this straightforward bit-counting mechanism can significantly simplify network configuration and troubleshooting.