What is CIDR and Why Was It Created?
Classless Inter-Domain Routing (CIDR) was introduced in 1993 to replace the older, rigid class-based routing system (Class A, B, and C). The internet was rapidly running out of IP addresses because assigning a full Class B network (65,534 hosts) to an organization that only needed 1,000 addresses resulted in massive waste.
CIDR allows for variable-length subnet masking (VLSM), meaning network administrators can allocate IP address blocks that precisely match their requirements.
Understanding the Suffix Syntax
A CIDR address looks like this: `192.168.1.0/24`. The number after the slash (`/24`) is the prefix length. It dictates how many bits (from left to right) of the 32-bit IPv4 address are locked as the *network portion*. The remaining bits are the *host portion*.
Since an IPv4 address is 32 bits long, a `/24` prefix means:
- **Network Bits**: 24
- **Host Bits**: 32 - 24 = 8
Binary Mask Breakdown for /24:
11111111 . 11111111 . 11111111 . 00000000Translated to decimal, this binary sequence is exactly `255.255.255.0`.
Number of Hosts Calculation
To calculate the total number of usable host addresses for a given CIDR suffix `N`, we use the following standard formula:
\[ \text{Usable Hosts} = 2^{(32 - N)} - 2 \]
Why Subtract Two?
In any IPv4 subnet, the very first and very last addresses cannot be assigned to hosts like computers or servers:
1. **Network Address**: The first address (where all host bits are `0`). It identifies the network itself.
2. **Broadcast Address**: The last address (where all host bits are `1`). It is used to send broadcast packets to all hosts on that subnet.
Real-World Example: /26 Subnet
If you are assigned the network `10.0.0.0/26`:
- [Subnet Mask](/tools/subnet-calculator/subnet-mask-reference-table): `255.255.255.192`
- Host Bits: `32 - 26 = 6`
- Total IPs: `2^6 = 64`
- Usable Hosts: `64 - 2 = 62`
The usable IP range will be from `10.0.0.1` to `10.0.0.62`, with `10.0.0.63` serving as the broadcast address.
