CIDR Calculator β€” Classless Inter-Domain Routing

Created by Rijk de Wet
Reviewed by Steven Wooding
Last updated: Jun 17, 2023


Welcome to Omni's CIDR calculator! Classless interdomain routing (CIDR) revolutionized the internet and how IP addresses are assigned. However, CIDR notation isn't simple at first β€” so we made this CIDR block calculator to help!

Our CIDR calculator can convert a CIDR block into an IP range β€” and, given an IP range, this CIDR block calculator will find the CIDR notation that captures that range. In this article, we'll cover essential topics such as:

  • What classless interdomain routing is;
  • How to calculate subnet mask from CIDR notation;
  • How to calculate IP range from CIDR; and
  • How to calculate CIDR from IP range.

πŸ’‘ Interested in IP addresses and subnetworks? Check out our IP subnet calculator!

How to use the CIDR range calculator

This CIDR subnet calculator has two modes, which you can select with the "I want to convert..." dropdown menu.

  • If you select CIDR to IPv4 range, the CIDR calculator will determine the range of IP addresses covered by the block you enter in CIDR notation.

    1. Give the calculator the CIDR notation β€” the IP address and associated subnet mask width.

    2. Verify that the CIDR notation is correct.

    3. Find your results at the bottom of the CIDR block calculator β€” we summarize the results, but we also go into depth on the subnet mask, the associated network prefix, the wildcard bits, and the range of IP addresses that this CIDR covers.

  • In IPv4 range to CIDR mode, the CIDR calculator will determine the network block(s) that cover the range between two IP addresses.

    1. Give the calculator two IP addresses β€” the first in the range and the last.

    2. Find the corresponding network block(s) below. One block that fits nicely into CIDR notation might not exist β€” in such cases, the CIDR calculator gives multiple blocks that cover your range.

    3. You can verify the output and learn about each network block with the CIDR to IPv4 range mode.

What is classless inter-domain routing (CIDR)?

CIDR is an ingenious method of allocation and routing of IP addresses. Before CIDR, the internet used a rather wasteful method of allocating IP addresses for specific subnetworks and their constituent hosts. Because of this inefficiency, the internet was quickly running out of IP addresses. CIDR is specifically called "classless" because it does not use "IP classes", which is exactly what made the previous system so inefficient.

What is CIDR notation?

CIDR notation is a compact way of denoting an IP address and its subnet mask. CIDR notation consists of an IP address, a slash (/), and a number between 0 and 32. This is the number of consecutive 1-bits (followed by more 0-bits) that make up the 32-bit subnet mask.

How to calculate IP range from CIDR

There are three steps to calculating the IP range from CIDR:

  1. Find the subnet mask.
  2. Apply the subnet mask.
  3. Use the wildcard bits to determine the IP range.

We'll use 172.161.25.102/25 as an example throughout this process.

Find the subnet mask

The number after the slash is the width of our subnet mask. Our example (172.161.25.102/25) has a subnet mask width of 25, meaning the mask has 25 1-bits and an additional 7 0-bits (to add up to 32 bits).

We can visualize the bits of the IP address and the mask as follows:

A bit diagram of an IP address.
The IP address, broken up into its binary representation.

 

A bit diagram of a subnet mask with length 25.
The subnet mask, consisting of 25 1-bits and 7 0-bits.

 

πŸ’‘ Not sure what these "bit" things are? Head on over to our binary calculator to learn more!

Apply the subnet mask

We've just learned how to calculate the subnet mask from CIDR notation. We can apply this mask to the IP address (rewritten in binary) with the bitwise AND operation. In practice, we take only the first 25 bits (since 25 is the decimal number in our CIDR, 172.161.25.102/25) and discard the rest.

A bit diagram of a subnet prefix.
The network prefix of the CIDR block.

What's left is called the subnet prefix, which acts as an identifier for the block to which the specific IP address 172.161.25.102/25 belongs. Our example's subnet prefix is 172.161.25.0.

πŸ’‘ Check out our bitwise calculator for more information on the bitwise AND operation and others!

Determine the IP range

The bits not covered by the subnet mask are called the wildcard bits, and they are available to be filled with unique bit combinations to form unique IP addresses that all fall within our subnetwork. The zeros in the subnet mask are the wildcard bits, and so they are:

A bit diagram of a subnet's wildcards.
The wildcard bits of our subnet block.

Now that we know which bits can be changed while fitting within our subnet, we can finally determine the IP range! The range starts at the IP address with all 0s in the wildcard bit positions:

A bit diagram of an IP address.
The first IP address in our range β€” the pink is from the subnet prefix.

And the range ends at the IP address with all 1s in these positions:

A bit diagram of an IP address.
The last IP address in our range.

And there we have it β€” the IP range of the block 172.161.25.102/25 is 172.161.25.0 to 172.161.25.127! We can also see that we have 27 = 128 unique IP addresses in our network block.

How to calculate CIDR from IP range

While calculating the IP range from a CIDR is simple, calculating the CIDR from an IP range is more complex. In a nutshell, only some IP ranges are covered exactly by one single CIDR block. Consider the following cases, which you can verify using our CIDR subnet calculator in IPv4 range to CIDR mode:

The range 10.0.0.0 to 10.0.0.31 is covered by the single CIDR 10.0.0.0/27. Great!

But what happens when we change the first IP address by just one bit? The range 10.0.0.1 to 10.0.0.31 needs five blocks to cover it completely:

CIDR

Starts at

Ends at

#

10.0.0.1/32

10.0.0.1

10.0.0.1

1

10.0.0.2/31

10.0.0.2

10.0.0.3

2

10.0.0.4/30

10.0.0.4

10.0.0.7

4

10.0.0.8/29

10.0.0.8

10.0.0.15

8

10.0.0.16/28

10.0.0.16

10.0.0.31

16

Unfortunately, there's no smart solution to finding these CIDRs β€” you have to work it out by hand, consult a CIDR database, or use our CIDR notation calculator.

FAQ

How do I calculate IP range from CIDR?

To extract the IP range from CIDR notation:

  1. Determine the subnet mask from the number after the slash.
  2. Find the network prefix by applying the mask to the IP address in binary form.
  3. Fill all the wildcard bits (the bits not covered by the mask) with 0s β€” this is the start of the IP range.
  4. Fill the wildcard bits with 1s β€” this is the end of the IP range.

What is the IP range of the CIDR 10.0.0.0/8?

The CIDR 10.0.0.0/8 covers the range of IP addresses from 10.0.0.0 to 10.255.255.255, which are 16,777,216 unique IP addresses.

Rijk de Wet
I want to convert...
CIDR to IPv4 range
Enter your IP's octets (the numbers separated by dots) and the subnet mask width (the number after the slash) below:
First octet of IP
.
Second octet of IP
.
Third octet of IP
.
Fourth octet of IP
/
Subnet mask width
Your IP and subnet in CIDR notation is
0.0.0.0/0
Result
IP0.0.0.0
Subnet mask width0
Subnet mask0.0.0.0
Prefix0.0.0.0
Wildcard bits255.255.255.255
First IP (network address)0.0.0.0
Last IP (broadcast address)255.255.255.255
Range4,294,967,296 IP addresses
Number of host addresses4,294,967,294 IP addresses
See the calculations?
No
Check out 31 similar tech and electronics calculators πŸ’»
3D printing costAmdahl's lawBattery capacity… 28 more
People also viewed…

Black Friday

How to get best deals on Black Friday? The struggle is real, let us help you with this Black Friday calculator!

CSS aspect ratio

Our CSS aspect ratio calculator allows you to quickly resize your files to fit in a designated area.

Podcasts

Do you feel like you could be doing something more productive or educational while on a bus? Or while cleaning the house? Well, why don't you dive into the rich world of podcasts! With this podcast calculator, we'll work out just how many great interviews or fascinating stories you can go through by reclaiming your 'dead time'!

RAID

This RAID calculator will help you decide which configuration of disks (RAID level) is right for you, based on usable capacity, fault-tolerance, performance, and cost.
Copyright by Omni Calculator sp. z o.o.
Privacy, Cookies & Terms of Service