# What is CIDR?

**CIDR** (**Classless Inter-Domain Routing**) - a method of classless addressing in computer networks built on IP-based protocol. This method of addressing allows to manage more effectively IP address space opposed to class-based addressing.

## What Is The Addressing In IP-based Networks?

In general, the address space in IP-based networks is a finite number. For example, in IPv4 networks (this is the main protocol for today for the Internet), the length of each individual IP-address is 32 bits, which gives the address space of 2^{32} = 4,294,967,296 possible addresses at all (just over 4 billion addresses). At the same time the new IPv6 protocol defines IP-address with length of 128 bits, which substantially increases the address space number and is approximately equals to 3.4 × 10^{38} of available addresses. This is 79 228 162 514 264 337 593 543 950 336 times larger address space than IPv4. Approximately 79 septillions times more! For each of the 7 billion inhabitants at Earth it is possible to allocate IPv4 address space length 11 318 308 930 609 191 085 times, that is, approximately 11.3 quadrillion of IPv4 address spaces. But while these numbers are so huge, they are still finite.

As the Internet it represents a number of different networks, combined into a single global network, there is a need to allocate somehow the addresses from the global space and re-allocate them for use to separate networks. Larger networks can divide individual blocks of their owned address space and allocate smaller address blocks between the subnets, and so on.

That is, each individual network is associated with some address block allocated from global address space. It means that such a dedicated block is addressed to the network.

CIDR is such a special method of allocation of some blocks of addresses to networks.

## How does it work?

Let's look by an example to get a clue about principles of CIDR. Let's use IPv4 example, because smaller numbers would look at this page more clearly. Generally, the same basic principles would also be applicable to IPv6 address space.

So, first of all let's recall the look of IPv4 address. For example it could be like this one - 198.51.100.15. So it is of 4 decimal numbers from 0 to 255, separated by a dot.

By the way, it is simply an integer of 32 bits length. Bit - this is the smallest unit of information that the computer operates. Most of our computers operate on binary bits, which could take two stateslike 0 and 1. This means that if you imagine IPv4 address in binary representation of ones and zeros (the way it is seen by a computer), then turn the chain of ones and zeros in a chain of 32 digits. For example, the minimum IPv4 address would look like:

00000000000000000000000000000000

And the maximum - as follows:

11111111111111111111111111111111

Since most modern computers operate also a byte of information equal to 8 bits, you can divide these 32 bits is 4 octets, and write them in the dotted form (let's deal with address from our example):

11000110.00110011.01100100.00001111

If we translate this and rewrite in a decimal representation (which is more familiar to us humans to perceive), then we obtain the IP-address 198.51.100.15

As mentioned, each network - is a certain block (or range) of addresses. And each address block has a network (base) address of the network and a final (broadcast) address. All other addresses, except the initial and final can be used as addresses of the real network hosts.

Usually for packets routing implementation it is required to determine a network (base) address. It could be easily done by a computer with applying a principal of network mask. In CIDR *variable length subnet mask* (VLSM) are used. With this approach, the mask is defined as the number of unique high-order bits in the mask and is written right by a "/" followed by an IP-address. Let's say our subnet mask - is 24 bits, than for the computer, it looks like this:

11111111.11111111.11111111.00000000

In this case CIDR notation mask for our address would look like this (in decimal view):

198.51.100.15/24

With the help of mask PC easily could calculate the network (base) address applying bitwise logical AND to the address and subnet mask:

11000110.00110011.01100100.00001111 & 11111111.11111111.11111111.00000000 = 11000110.00110011.01100100.00000000

Or in decimal form the result is:

198.51.100.0

The number of zeros in the least significant bits of the mask determines the maximum number of possible addresses for the network hosts. They are quite simple to calculate also. Count the number of zeros. If we have 24 bits as mask of the 32 total length, then the number of zeros will be 32 - 24 = 8. That is 8 bits all available for network addresses. Since each bit can take two values (0 or 1) then all we get are 2^{8} possible combinations, which is equal to 256, and is also equivalent to the series of numbers from 0 to 255. Thus the last address in this subnet is 198.51.100.255 (aka - the broadcast address). That's how the knowledge of the address and subnet mask makes it possible to determine the starting and ending addresses of the network, and the actual amount of possible nodes within the network. In our example, CIDR notation 198.51.100.15/24 gives us the following information:

- Node address - 198.51.100.15
- Subnet mask - 255.255.255.0
- The number of possible nodes in the subnet - 256
- Network base address - 198.51.100.0
- Network broadcast address - 198.51.100.255
- Number of possible hosts in the network - 254

In other words, the block of address with mask /24 gives a possibility to create a subnet, for example, of 254 connected to a network computers (hosts).

## Table Of Variable Length Subnet Masks

Based on the above rules of CIDR addressing it is possible to construct the following table of VLSM, which can be of great help in the work of any network administrator.

CIDR | Маска | Num. of addresses | Num. of hosts | Class |
---|---|---|---|---|

A.B.C.D/32 | 255.255.255.255 | 1 | 1 | 1/256 C |

A.B.C.D/31 | 255.255.255.254 | 2 | 2 | 1/128 C |

A.B.C.D/30 | 255.255.255.252 | 4 | 2 | 1/64 C |

A.B.C.D/29 | 255.255.255.248 | 8 | 6 | 1/32 C |

A.B.C.D/28 | 255.255.255.240 | 16 | 14 | 1/16 C |

A.B.C.D/27 | 255.255.255.224 | 32 | 30 | 1/8 C |

A.B.C.D/26 | 255.255.255.192 | 64 | 62 | 1/4 C |

A.B.C.D/25 | 255.255.255.128 | 128 | 126 | 1/2 C |

A.B.C.0/24 | 255.255.255.000 | 256 | 254 | C |

A.B.C.0/23 | 255.255.254.000 | 512 | 510 | 2 C |

A.B.C.0/22 | 255.255.252.000 | 1 024 | 1 022 | 4 C |

A.B.C.0/21 | 255.255.248.000 | 2 048 | 2 046 | 8 C |

A.B.C.0/20 | 255.255.240.000 | 4 096 | 4 094 | 16 C |

A.B.C.0/19 | 255.255.224.000 | 8 192 | 8 190 | 32 C |

A.B.C.0/18 | 255.255.192.000 | 16 384 | 16 382 | 64 C |

A.B.C.0/17 | 255.255.128.000 | 32 768 | 32 766 | 128 C |

A.B.0.0/16 | 255.255.000.000 | 65 536 | 65 534 | B |

A.B.0.0/15 | 255.254.000.000 | 131 072 | 131 070 | 2 B |

A.B.0.0/14 | 255.252.000.000 | 262 144 | 262 142 | 4 B |

A.B.0.0/13 | 255.248.000.000 | 524 288 | 524 286 | 8 B |

A.B.0.0/12 | 255.240.000.000 | 1 048 576 | 1 048 574 | 16 B |

A.B.0.0/11 | 255.224.000.000 | 2 097 152 | 2 097 150 | 32 B |

A.B.0.0/10 | 255.192.000.000 | 4 194 304 | 4 194 302 | 64 B |

A.B.0.0/9 | 255.128.000.000 | 8 388 608 | 8 388 606 | 128 B |

A.0.0.0/8 | 255.000.000.000 | 16 777 216 | 16 777 214 | A |

A.0.0.0/7 | 254.000.000.000 | 33 554 432 | 33 554 430 | 2 A |

A.0.0.0/6 | 252.000.000.000 | 67 108 864 | 67 108 862 | 4 A |

A.0.0.0/5 | 248.000.000.000 | 134 217 728 | 134 217 726 | 8 A |

A.0.0.0/4 | 240.000.000.000 | 268 435 456 | 268 435 454 | 16 A |

A.0.0.0/3 | 224.000.000.000 | 536 870 912 | 536 870 910 | 32 A |

A.0.0.0/2 | 192.000.000.000 | 1 073 741 824 | 1 073 741 822 | 64 A |

A.0.0.0/1 | 128.000.000.000 | 2 147 483 648 | 2 147 483 646 | 128 A |

0.0.0.0/0 | 000.000.000.000 | 4 294 967 296 | 4 294 967 294 | 256 A |

To calculate subnet mask for some certain IP-address, you can use our Subnet Mask Calculator