DevOps Interview Questions: How many usable IPs are there in /24 CIDR?

In our previous interview-related question we talked about VPC design, logging system design, monitoring system design, page fault, etc. In this article, we are going to talk about how to calculate how many usage IPs are there in a /24 CIDR.

What is a CIDR?

CIDR stands for classless inter-domain routing. This is a set of rules to assign IP addresses. As you must be aware there can be a total of 4,294,967,296 [2^32] different IPs addresses but there are lot more devices than that. With help of CIDR you can easily reuse the IP addresses.

Every IP has two parts network address and host address.

The network address tells about the network and the host address tells about the devices to which that IP is assigned.

So for any device in a network, the network address is fixed, just the host address part of the IP changes.

So if the question is how many usable IPs are there in /24 CIDR, it means that first 24 bit of the IP is fixed for network and only 32-24 =8 bits of IPs are there to be assigned to different machines.

32 - 24 = 8
2^8 = 256
2 ips are reserved for network address and broadcast Address
256-2 = 254

This answer can vary from cloud to cloud as they can have different use cases of these IPs.

So the answer to the question in 2 ^ x -2 is the CIDR given is /x

If you are preparing for Linux and Operating systems. You can watch this video series by Let Us DevOps. Subscribe to this youtube channel for good content around DevOps and SRE space.

If you like the article please share and subscribe.

Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.