What’s CIDR?

Posted on January 8, 2009 by Daniel Petri in Networking with

The Classless Inter Domain Routing (CIDR) standard is already in effect and most newer routers supports it. In a few years it is likely to be the way IP addressing is handled. It is already becoming common for ISP and major providers to use this scheme.

The old Classfull IP Addressing scheme provided for Class A, B and C networks:

Class type Starting bits for the first octet How many networks per Class? How many hosts per network? Range of the first octet
Class A 0 126 (2^24)-2=~16 Million 1-126 127=Loopback
Class B 10 2^14=16384 (2^16)-2=~65000 128-191
Class C 110 2^21=~2 Million (2^8)-2=254 192-223
Class D 1110 224-239
Class E 1111 240-255

The default Subnet Masks for these networks are:

Class type Number of bits used for the Network ID Number of bits used for the Host ID Default Subnet Mask
Class A 8 24
Class B 16 16
Class C 24 8

The problem with such a scheme is that we are bound to blocks of IP addresses and if we don’t need all of them (for example if a small company would need 100 computers they would still have to use a class C network) or if we need more than we can get (for example if a medium sized company needed 1000 computers per network they couldn’t use a class C network – they’d need a class B network) we can do nothing about it. The inefficiencies are mainly in the block assignments. You get a class C network and use only a hundred of those. That means there are suddenly 154 unused and unavailable addresses. On the bigger scale some investigations have indicated that while we are running out of address blocks to assign only a very small percentage of the total addresses are being used. (less than 10%).

Of course these networks could be subnetted on a local level, but that would only be good for our local networks, not for the Internet traffic.

With the expansion of smaller networks the route table additions are increasing rapidly. The capacity is being overtaxed. What good is an Internet address is you can’t get where you want or some can’t find you. Thus, a need is developing for modifying the way it is handled.

One method of solving the problem is to use subnetting. Another is to have all the smaller networks use the privately assigned address space and use proxies. That way only one external address is being employed. Not exactly true since the NAT (Network Address Translation) needs to provide a public address for each IP address in the internal system when in use. However, this would most certainly solve some the problems.

The new scheme that has been developed for this purpose is called CIDR.

How does CIDR work? How does it differ from Classfull IP Addressing? How will it solve it’s problems?

The class system is being replaced with a prefix anywhere from 13 to 27 bits which serves as a generalized network prefix. Thus a new IP address might look like this The first 25 bit in the address are used to identify the network, while the remaining  7 bits are used to identify the host.

Instead of using the old Classfull IP Addressing scheme where the previous IP address was identified as a class C IP address (the first octet is in the range of 192 to 223) and thus we would be forced to use the remaining last octet (the last 8 bits) as the Host ID, we will now use only the last 7 bits as the Host ID and thus have 25 bits for the Network ID instead of the old 24 bits.

CIDR blocks and number of Host IDs per segment:

CIDR Block Number of Equivalent Class C networks Number of Network ID bits Number of Host ID bits Total number of Host addresses per segment= (2 ^# of Host ID bits) Number of usable Host addresses per segment= (2 ^# of Host ID bits)-2
/27 1/8 Class C 27 5 32 30
/26 1/4 Class C 26 6 64 62
/25 1/2 Class C 25 7 128 126
/24 1 Class C 24 8 256 254
/23 2 Class C 23 9 512 510
/22 4 Class C 22 10 1,024 1,022
/21 8 Class C 21 11 2,048 2,046
/20 16 Class C 20 12 4,096 4,094
/19 32 Class C 19 13 8,192 8,190
/18 64 Class C 18 14 16,384 16,382
/17 128 Class C 17 15 32,768 32,766
/16 256 Class C = 1 Class B 16 16 65,536 65,534
/15 512 Class C = 2 Class B 15 17 131,072 131,070
/14 1024 Class C=4 Class B 14 18 262,144 262,142
/13 2048 Class C=8 Class B 13 19 524,288 524,286

This would then allow the big blocks to be provided to the ISPs who would then rent them out on an as needed basis to the users. The allocation might be bigger or smaller blocks depending on needs. It would allow for a much more efficient assignment off the IP address space.


The routing tables and architecture could now be changed to solve that problem too.  In this set up a major provider like UUENET or Alternet or whoever would have their set address space. Thus the major routing tables (global) would only need to include these major providers. It would then be necessary for the major providers as they give out address space to include those in their routing tables. The subset providers or maybe your local ISP would then provide the routing for their set.

This would be a hierarchical set up similar in many ways to how the phone system is set up. It would mean that if you change providers you would be required to change IP addresses on your network. Otherwise the routing would not be there.

How can I calculate the Subnet Mask from a CIDR-type address?

It’s simpler than you think. You need to write down the number of bits that are in the CIDR notation (in Binary notation), divide them into 4 octets, and convert them to decimal notation. For example:

CIDR address:

  1. Write down 27 bits as 1 (one), and the rest (5) as 0 (zero):


  1. Divide them into 4 octets:


  1. Convert to decimal:


Remember that class A networks are followed by a /8, class B networks are followed by a /16, and class C networks are followed by a /24. This will make life easier for you.

BTW, if you need to calculate Subnet Masks and Network IDs and you can’t do it yourself  by using my Subnetting Table (Duh, “Paper MCSE” or not?). Otherwise, for a more automatic solution, try one of these downloadable subnet calculators. They are great:

Wild Packets Free IP Subnet Calculator

Boson Subnet Calculator

Register for this upcoming webinar on Petri.com
Webinar: Accelerate Smart Factory ROI with Deloitte and HPE’s Digital IoT

Join HPE and Deloitte for a discussion on how to take advantage of IT and OT convergence to deliver the Factory of the Future

Tuesday, October 24, 2017
at 2 p.m. EST

Register for this upcoming webinar on Petri.com
Webinar: Accelerate Smart Factory ROI with Deloitte and HPE’s Digital IoT

Join HPE and Deloitte for a discussion on how to take advantage of IT and OT convergence to deliver the Factory of the Future

Tuesday, October 24, 2017
at 2 p.m. EST