Classless Inter Domain Routes (CIDR)


There are networks known as classful and classless. The first plan adopted and used widely by the Internet community were classful networks. So named because three address classes: A, B, and C were defined with assignable IP address space. These classes, however, disproportionately distributed the number of available IP addresses. A new method to identify networks and allocate IP addresses was needed to support the continued growth of the Internet. The new method is named classless because it does away with the idea of classes altogether. It is commonly known as Classless Inter-Domain Routing (CIDR). It is much more flexible than classful networks and is what the Internet uses today. Classful networks are still used by many devices, so it is important to understand both classful and classless networking.

IPv4 Overview

An IPv4 address contains 32-bits. It is usually represented in dotted decimal quad notation so it is easier to read and communicate. Computers, of course, read this information in binary form. And in order to calculate subnet masks, network addresses, and broadcast addresses, the binary value must be known.

Converting a dotted decimal IP address to binary is simple. Given that there are 4 numbers, each decimal number is represented in binary as an octet. The high order bits in binary are always the leftmost ones.

Counting in Binary
Binary11111111
Powers of 22726252423222120
Decimal1286432168421

The largest single value an IP address may have in decimal is 255 since this is the sum when all of the bits are added together, i.e. 27 + 26 + 25 + 24 + 23 + 22 + 21 + 20. When all of the bits are turned off, the number is 0. The range of an IP address is therefore 0 – 255, 256 values.

The following is how the IP address 68.125.16.250 would be converted and represented in binary form.

DecimalBroken DownBinary AdditionBinary
First Octet6864 + 426 + 2201000100
Second Octet12564 + 32 + 16 + 8 + 4 + 126 + 25 + 24 + 23 + 22 + 2001111101
Third Octet16162400010000
Fourth Octet250128 + 64 + 32 + 16 + 8 + 227 + 26 + 25 + 24 + 23 + 2111111010

The end result looks like 01000100011111010001000011111010.

Classful Networks

Once an IP address is represented in binary format, the class of network can be determined rather easily. Beginning from the left of the IP address, the first bit that is not a “1” indicates whether it is a Class A, Class B, Class C, Class D, or Class E network.

For class A networks, the high order (leftmost) bit is always a “0”. For class B networks, the high order bits are always a “1” followed by a “0”. For class C networks, the high order bits are always a “1” followed by a “1” followed by a “0”.

First BitStart AddressEnd Address
Class A00.0.0.0127.255.255.255
Class B10128.0.0.0191.255.255.255
Class C110192.0.0.0223.255.255.255
Class D1110224.0.0.0239.255.255.255
Class E1111240.0.0.0255.255.255.255

Subnet Masks

Subnet masks represent what part of an IP address is used to determine network information versus host information. For a class B network, the subnet mask uses 16 bits, allowing the remaining 16 bits to be used for host information.

Subnet MaskBinary FormatDecimal Format
Class A8-bit11111111.00000000.00000000.00000000255.0.0.0
Class B16-bit11111111.11111111.00000000.00000000255.255.0.0
Class C24-bit11111111.11111111.11111111.00000000255.255.255.0


The total number of available hosts on a network can be determined from it’s subnet mask. Since a class B network uses 16 bits for its subnet mask, it leaves 16 bits available for host information. 216 = 65,536. All hosts need a network address and a broadcast address. The network and broadcast addresses are indicated by either all 1s or all 0s in the host information part of an IP address. With those two addresses always reserved, the total number of assignable hosts for a class B network is 216 – 2 = 65,534.

Host BitsHost FormulaAvailable Hosts
Class A24-bit224 – 216,777,214
Class B16-bit216 – 265,534
Class C8-bit28 – 2254

The total number of networks a class address may have is calculated by subtracting the number of bits in the subnet mask from the number of bits used to determine which class of network it is. For example, a class A network has an 8-bit subnet mask. Only 1 bit is used to determine that it is a class A network. Subtract 8 from 1 and that leaves 7 bits available for networks. 27 is 128. So, there is only room for 128 class A networks.

Subnet MaskNetwork IDNetwork FormulaAvailable Networks
Class A8-bit1-bit28-1128
Class B16-bit2-bit216-216,384
Class C24-bit3-bit224-32,097,152

Classless Networks

Forget class A, B, and C now. Classless networks don’t use it at all, hence the name. Instead, CIDR networks are identified with a trailing “/” slash and a number that indicates how many bits are used to identify the network portion of the address. Like a class C address in classful networking, a /24 would indicate that 24-bits are used to identify the network and the remaining 8-bits are used to identify the host. Unlike classful networking, CIDR provides much more flexibility than 8, 16, and 24-bit network masks. Under CIDR, the number of bits used to indicate the network portion of the address can be from /8 to /30 although more commonly only /13 to /29 are used. This gives network administrators the flexibility to assign addresses from 6 – 524,286 to match the needs of an organization.

CIDR Available Hosts

The formula to calculate the number of assignable IP address to CIDR networks is similar to classful networking. Subtract the number of network bits from 32. Raise 2 to that power and subtract 2 for the network and broadcast addresses. For example, a /24 network has 232-24 – 2 addresses available for host assignment.

CIDR NotationHost FormulaAvailable Hosts
/8232-8 – 216,777,214
/9232-9 – 28,388,606
/10232-10 – 24,194,302
/11232-11 – 22,097,150
/12232-12 – 21,048,574
/13232-13 – 2524,286
/14232-14 – 2262,142
/15232-15 – 2131,070
/16232-16 – 265,534
/17232-17 – 232,766
/18232-18 – 216,382
/19232-19 – 28,190
/20232-20 – 24,094
/21232-21 – 22,046
/22232-22 – 21,022
/23232-23 – 2510
/24232-24 – 2254
/25232-25 – 2126
/26232-26 – 262
/27232-27 – 230
/28232-28 – 214
/29232-29 – 26
/30232-30 – 22

As the table indicates, two /29 networks equals a /28 network. Two /28 networks equals a /27 network. Two /27 networks equals a /26 network. And so on, and so on. The notion of combining two smaller networks into a larger one is another benefit of classless networks named supernetting. In order to create a supernet the smaller networks must be contiguous. For example, 192.0.2.240/29 and 192.0.2.248/29 can form a supernet 192.0.2.240/28, but 192.0.2.240/29 and 192.0.2.8/29 could not.

CIDR Available Networks (subnetting)

How many /29 networks can fit into a /24 network? Or how many /21 networks can fit into a /17 network? The best way to explain the formula is to show it. The following illustrates how many /21 networks can fit into a /17 network.

  1. Subtract the network bits from 32.
    /17 = 32-17 and /21 = 32-21
  2. Raise 2 to that power.
    232-17 and 232-21
  3. Divide the larger network by the smaller one.
    232-17 / 232-21 = 215 / 211 = 215-11 = 24 = 16

As the example shows, a /17 network could be divided into sixteen /21 networks. Spot the shortcut in the steps? How many /29 networks in a /24?

  • 28-3 = 25 = 32

CIDR Subnet Mask

The process to determine the subnet mask for a CIDR address is straight forward. The number of bits in the network portion of the address are converted to 1s and right padded with 0s until there are 32 numbers. The sequence of numbers is then divided into 4 octets. From then, it is a matter of converting the 4 octets from binary to decimal.

CIDR NotationConvert to 1s and Right PadSubnet Mask
/811111111.00000000.00000000.00000000255.0.0.0
/911111111.10000000.00000000.00000000255.128.0.0
/1011111111.11000000.00000000.00000000255.192.0.0
/1111111111.11100000.00000000.00000000255.224.0.0
/1211111111.11110000.00000000.00000000255.240.0.0
/1311111111.11111000.00000000.00000000255.248.0.0
/1411111111.11111100.00000000.00000000255.252.0.0
/1511111111.11111110.00000000.00000000255.254.0.0
/1611111111.11111111.00000000.00000000255.255.0.0
/1711111111.11111111.10000000.00000000255.255.128.0
/1811111111.11111111.11000000.00000000255.255.192.0
/1911111111.11111111.11100000.00000000255.255.224.0
/2011111111.11111111.11110000.00000000255.255.240.0
/2111111111.11111111.11111000.00000000255.255.248.0
/2211111111.11111111.11111100.00000000255.255.252.0
/2311111111.11111111.11111110.00000000255.255.254.0
/2411111111.11111111.11111111.00000000255.255.255.0
/2511111111.11111111.11111111.10000000255.255.255.128
/2611111111.11111111.11111111.11000000255.255.255.192
/2711111111.11111111.11111111.11100000255.255.255.224
/2811111111.11111111.11111111.11110000255.255.255.240
/2911111111.11111111.11111111.11111000255.255.255.248
/3011111111.11111111.11111111.11111100255.255.255.252

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s