2.2 Classless Interdomain Routing
2.2.3 How CIDR works
CIDR was a dramatic break from tradition in that it completely abandoned the rigid classes of addresses. The original IPv4 address architecture used an 8-bit network number for Class A addresses, a 16-bit network number for Class B addresses, and a 24-bit number for Class C addresses. CIDR replaced these categories with a more generalized network prefix. This prefix could be of any length rather than just 8, 16, or 24 bits. This allows CIDR to craft network address spaces according to the size of a network instead of force-fitting networks into pre-sized network address spaces.

Each CIDR-compliant network address is advertised with a specific bit mask. This mask identifies the length of the network prefix. For example, a network address and SNM of 192.125.61.8  255.255.240.0, is represented by a 20-bit CIDR network address as: 192.125.61.8/20.

The IP address can be any mathematically valid address regardless of whether that address was originally part of the Class A, B, or C range! CIDR-compliant routers look at the number after the / to determine the network number. Therefore, the former Class C address 192.125.61.8 previously had a network number of 192.125.61 and a host number of 8. As a Class C address, you could provide addresses for a maximum of 254 hosts within the network. Using CIDR, the architectural limitations of the 8-bit boundaries between address components is eliminated. To better understand how this works, it is necessary to translate the decimal number to binary.

In binary, this network portion of this address is 11000000.0111101.00111101. The first 20 bits of this example identify the network number. The main figure demonstrates the split of this address between network and host numbers.

Notice that the split between the network and host portions of the address falls in the middle of the third octet. The bits that aren't allocated to network number are used to identify hosts. Therefore, an IPv4 address with a 20-bit network prefix has 12 bits left for host identification. Mathematically, this translates to 4,094 usable host addresses. Because none of the leftmost bits are preset (which previously established the address class), virtually the entire range of addresses can be used in a CIDR network. Therefore, a 20-bit network prefix can be assigned a value that was previously reserved for Class A, B, or C networks.