Classless Inter-Domain Routing (CIDR)

Classless inter-domain routing is an addressing scheme for the Internet which allows IP addresses to be allocated more efficiently than the original class-based system of IP addressing, and is now used by most gateway routers. All Internet service providers are expected to use it for routing, and CIDR is supported by many routing protocols, including BGP and OSPF. Using the class-based addressing scheme the Internet could support the following:

Class-based IP Addressing
Class Network bits Host bits Network address range No of networks No of hosts
A 8 24 1-126 126 16,777,214
B 16 16 128-191 65,533 65,534
C 24 8 192-223 2,097,152 254


In theory, a 32-bit IP addressing scheme would yield 2 32 (4,294,967,296) possible IP addresses. The use of the class system reduces the total number of IP addresses possible to just over half that number (2,147,483,774). Even this number is somewhat academic, since the allocation of IP addresses under the class system means that many addresses are not used. A single class C network that uses global IP addresses, for example, accounts for 254 global IP addresses. If the network has only 100 hosts, 154 of these addresses remain unused and are unavailable for use by other networks. The result is that only a small percentage of the addresses assigned are actually used. CIDR was developed as a short term solution to this problem, and provides a more flexible way for routers to specify network addresses. Despite the introduction of CIDR, the continued rapid growth of the Internet means that IP addresses are still treated as a scarce resource, and customers are required to document their projected needs. The long term solution to the shortage of global IP adrresses is the introduction of IPv6 with its 128-bit addressing scheme, but it may be some time before IPv6 is in widespread use.

Another problem relates to the size of Internet routing tables. As the number of networks increases, so do the number of possible routes through the Internet. A routing table can contain a theoretical maximum number of entries of about 60,000. This number would have proved inadequete by now if it had not been for CIDR, which uses hierarchical routing aggregation to minimise the number of entries required. CIDR IP addresses contain a network prefix that can identify either an individual network gateway or an aggregation of gateways. The length of the network prefix can vary from 13 to 27 bits, enabling blocks of addresses to be assigned according to the needs of an organisation, allowing for networks with as few as 32 hosts, or as many as half a million hosts. The length of the CIDR network prefix is specified using a suffix that follows the 32-bit IP address, as illustrated below:

206.13.01.48/25

In the above example, the first 25 bits are used to identify the network, and the remaining bits identify the host. A shorter suffix can be used to describe many possible destinations, and is less specific. A routing table entry can thus represent an aggregation of networks, sometimes referred to as a supernet . Routers that support CIDR are required to use the most specific suffix available to them when forwarding packets. Large blocks of addresses are assigned by Regional Internet Registries (RIRs) to Internet Service Providers (ISPs), who allocate smaller blocks of addresses to their customers, with a network prefix of a length appropriate to their needs. In global routing tables, all of the networks and hosts connected to a single ISP may be represented by just one routing table entry. In this way, the growth in the number of routing table entries required at each level of the network hierarchy has been significantly reduced. The table below shows the effect of the length of network prefix used on the number of hosts a network can support.

Classless Inter Domain Routing (CIDR)
CIDR Suffix Equivalent class No of hosts Subnet mask
/27 Class C * 1/8 32 255.255.255.224
/26 Class C * 1/4 64 255.255.255.192
/25 Class C * 1/2 128 255.255.255.128
/24 Class C 256 255.255.255.000
/23 Class C * 2 512 255.255.254.000
/22 Class C * 4 1,024 255.255.252.000
/21 Class C * 8 2,048 255.255.248.000
/20 Class C * 16 4,096 255.255.240.000
/19 Class C * 32 8,192 255.255.224.000
/18 Class C * 64 16,384 255.255.192.000
/17 Class C * 128 32,768 255.255.128.000
/16 Class B 65,536 255.255.000.000
/15 Class B * 2 131,072 255.254.000.000
/14 Class B * 4 262,144 255.252.000.000
/13 Class B * 8 524,288 255.248.000.000