Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 4

Subnetting with CIDR Prefixes

Recommended resources

Welcome back! In our last lesson, you learned how to distinguish the network, host, and broadcast addresses within a given IP subnet by analyzing the network and host bits. This was a crucial first step in understanding how networks are structured.

Today, we will build directly on that foundation. This lesson focuses on using the CIDR prefix of a subnet mask to perform two essential calculations: determining the total number of subnets you can create from a larger network block, and finding the number of usable hosts available within each of those subnets. Mastering this is fundamental for your project, as it allows you to design an IP addressing scheme that is both organized and efficient, without wasting valuable addresses.

1. The Power of Two: Subnet and Host Formulas

When you subnet a network, you are "borrowing" bits from the original host portion and reassigning them to the network portion. This creates more network bits, which allows for more subnets. The bits you borrow are called subnet bits, and the bits that are left over are the host bits.

These two values, the number of subnet bits and host bits, are the keys to our calculations. The logic is based on binary powers of two:

  • Number of Subnets: If you borrow bits for the subnet portion, you can create new subnets. Each bit can be a 0 or a 1, so bits give you unique combinations.
  • Number of Usable Hosts: If you have bits remaining for the host portion, you can create total addresses. However, as you learned previously, the first address (all host bits are 0) is the network address, and the last address (all host bits are 1) is the broadcast address. Neither can be assigned to a device. Therefore, the formula is .

This article from GeeksforGeeks provides a concise summary of these core formulas.

How to Calculate Number of Host in a Subnet?

This article clearly defines the formulas for calculating the number of subnets and usable hosts.

Focus on the sections "Practical Application" and "Basic Formulas". Pay attention to the definitions: Usable Hosts = 2^h - 2, where h is the number of host bits. Total Subnets = 2^s, where s is the number of borrowed subnet bits. The table provided also gives a great quick-reference for common Class C subnets.


2. The Calculation Process: Finding s and h

Now, let's see how to apply these formulas. The process involves identifying how many bits are allocated to the network, subnet, and host portions based on the CIDR prefix.

The video below by Professor Messer provides excellent, clear examples for Class C, A, and B networks.

Calculating IPv4 Subnets and Hosts - CompTIA Network+ N10-009 - 1.7

This video demonstrates the full calculation process for different network sizes.

Watch the following segments to see how the number of subnet (s) and host (h) bits are determined and used in the formulas: First, watch the introduction to the powers of two method. Next, see it applied to a Class A address range being subnetted as a /24 in the first example. Notice how he identifies 16 borrowed bits (s) and 8 host bits (h). Then, watch the Class C example with a /26 prefix from 192.168.1.0. Here, s=2 and h=6. Finally, observe the Class B example with a /21 prefix from 172.16.5.0. Here, s=5 and h=11.

Let's summarize the steps from the video:

  1. Identify the network class to determine the default mask (Class A: /8, Class B: /16, Class C: /24).
  2. Find the number of borrowed subnet bits (s): This is the difference between the new CIDR prefix and the default class prefix. For example, for 192.168.1.0/26 (Class C, default /24), bits.
  3. Find the number of host bits (h): This is the number of bits remaining in the 32-bit address. . For /26, bits.
  4. Calculate the number of subnets: . In our /26 example, subnets.
  5. Calculate the number of usable hosts: . In our /26 example, usable hosts per subnet.

3. A Handy Reference: The CIDR Cheat Sheet

Memorizing all the powers of two and subnet masks can be time-consuming. Network engineers often use reference charts to speed up the process. This CIDR cheat sheet is an invaluable tool for both your studies and practical work.

CIDR/IPv4 Cheat Sheet
Caption: A comprehensive CIDR cheat sheet. The key columns for today's lesson are "CIDR," "Subnet Mask," and "# of Addresses." Remember to subtract 2 from the "# of Addresses" to get the number of usable hosts.

Take a moment to look at the /26 row on this chart. You'll see it corresponds to a subnet mask of 255.255.255.192 and allows for 64 addresses, which confirms our calculation of 62 usable hosts.


4. Reinforcement and Practice

Let's watch one more video that reinforces these concepts and sets you up with some practice questions. This video provides a slightly different approach but arrives at the same conclusions.

Free CCNA | Subnetting (Part 2) | Day 14 | CCNA 200-301 Complete Course

This video from Jeremy's IT Lab offers another perspective on subnetting calculations and provides practice problems.

First, watch the review of a /26 subnetting problem. This will reinforce the formulas and introduce a quick trick for finding the next subnet. Next, jump to the section on subnetting a Class B network. This part poses several questions where you must determine the correct prefix length based on the required number of subnets and hosts. The video walks through the logic for each.

The video demonstrates a common real-world scenario: you're given requirements (e.g., "we need 80 subnets") and you must work backward to find the appropriate CIDR prefix. This involves finding the smallest power of 2 that meets the requirement.

For example, to get 80 subnets, you need to find the smallest where .

  • (not enough)
  • (enough)
    So, you need to borrow 7 bits. If starting from a Class B (/16) network, your new prefix would be /16 + 7 = /23.

5. Self-Assessment

Now it's time to test your skills. The video from Jeremy's IT Lab concludes with a quiz. Try to solve these problems on your own. This is the best way to ensure you can perform these calculations quickly and accurately.

Free CCNA | Subnetting (Part 2) | Day 14 | CCNA 200-301 Complete Course

Test your understanding with these quiz questions.

Watch the quiz section of the video. Pause after each question is presented and try to solve it on paper. The answers are provided in the next video of that series, but you should be able to verify your answers using the formulas and the cheat sheet from this lesson. Question 1: Requires you to find a prefix that satisfies both a subnet and a host requirement. Question 2 & 3: Test your ability to work with specific host and broadcast addresses. Question 4 & 5: Similar to the examples, they ask you to calculate outcomes based on a given subnetting scheme.


Conclusion

In this lesson, you moved from identifying parts of an IP address to quantifying them. You now have the essential skill to plan a network's structure based on specific requirements for subnets and hosts.

Here are the key takeaways:

  • The number of subnets you can create is calculated with the formula , where is the number of bits borrowed from the host portion.
  • The number of usable hosts per subnet is calculated with the formula , where is the number of bits remaining in the host portion.
  • To solve a subnetting problem, you must first determine the values of and based on the given CIDR prefix and the original network block.
  • In practical scenarios, you often work backward from requirements (e.g., needing 500 hosts) to find the necessary number of host bits (), which in turn defines the CIDR prefix ().

In our next lesson, we will put all of this together. You will learn how to take a given IP address and CIDR prefix, calculate the number of possible subnets, and then determine the exact network address, usable host range, and broadcast address for each of those subnets.