Hello! Welcome to the first lesson in our course on designing and managing IP addressing for large networks.
Your goal is to master subnetting for a significant Layer 2 architecture, and this course is designed to get you there, step by step. We'll start with the fundamentals and build up to complex design scenarios involving VLSM, VLANs, and VRFs.
Today, we'll focus on the absolute bedrock of IP addressing: the relationship between subnet masks and CIDR notation. You've mentioned you're comfortable configuring IPs and have a basic grasp of what a /24 means. This lesson will formalize that knowledge and give you the tools to instantly convert any subnet mask to its CIDR equivalent, and vice-versa, without needing a calculator. This skill is non-negotiable for the advanced planning we'll be doing later.
Our learning outcome for this 60-minute lesson is to: Convert between dotted-decimal subnet masks and CIDR notation for all prefix lengths.
Let's get started.
1. The "Why": From Classful Waste to CIDR Efficiency
Before we dive into the mechanics of conversion, it's crucial to understand why we use different subnet mask notations. Historically, IP addresses were grouped into rigid "classes" (A, B, C), which led to massive address waste. Classless Inter-Domain Routing (CIDR) was introduced to fix this.
To get a clear picture of the problem CIDR solves, let's watch a segment from a video by Jeremy's IT Lab, a popular resource for network engineers.
Free CCNA | Subnetting (Part 1) | Day 13 | CCNA 200-301 Complete Course
This video explains the limitations of old-school classful addressing and introduces CIDR as the modern, flexible solution.
Watch the segment from 01:48 to 11:16. Focus on: The fixed prefix lengths of Class A, B, and C networks. The examples of how this system wastes IP addresses, especially for point-to-point links and medium-sized companies. How CIDR removes these fixed requirements, allowing for 'subnetworks' or 'subnets' of flexible sizes.
As you saw, CIDR allows us to break up large address blocks into smaller, more appropriately sized subnets, minimizing waste. This is achieved by using a subnet mask that isn't restricted to the old classful defaults of /8, /16, or /24.
2. The Three Mask Formats
A subnet mask can be represented in three ways. You're already familiar with two of them, but let's formally define them. The following article provides a concise explanation.
Analyzing Subnet Masks - Internold Networks
Let's read the first part of an article from Internold Networks that clearly defines the three ways a subnet mask can be written.
Please read the introductory part of the article and the section titled 'Three Mask Formats'. You can stop reading just before the section 'Converting Between Binary and Prefix Masks'. Pay attention to the rules for a valid binary mask (all 1s on the left, all 0s on the right).
To summarize, the three formats are:
- Binary: A 32-bit number consisting of a string of consecutive 1s followed by a string of 0s. The 1s represent the network portion of an IP address, and the 0s represent the host portion.
- Dotted-Decimal Notation (DDN): The more human-readable format you're used to, like
255.255.255.0. Each number is the decimal conversion of an 8-bit segment (octet) of the binary mask. - Prefix/CIDR Notation: A slash (
/) followed by a number, like/24. This number is simply a count of the leading 1s in the binary mask. It's the most compact and common way to express a subnet mask in modern networking.
3. The "How": Conversion Techniques
Your goal is to be able to move between DDN and CIDR notation effortlessly. The key is understanding that the CIDR prefix is just the total count of '1's in the binary mask.
The Foundational Method: Using Binary as a Bridge
- DDN to CIDR: Convert each decimal octet to binary, place them together to form the 32-bit mask, and count the number of 1s.
255.255.255.0->11111111.11111111.11111111.00000000-> Count the 1s -> 24 ones ->/24
- CIDR to DDN: Take the CIDR prefix, write out that many 1s, pad with 0s to 32 bits, group into octets, and convert each octet to decimal.
/26-> 26 ones ->11111111.11111111.11111111.11000000-> Convert each octet ->255.255.255.192
This always works, but it's slow. As a network professional, you need a faster way.
The Professional's Shortcut: Memorizing the "Magic Numbers"
Because a binary mask octet must be a string of 1s followed by 0s, there are only nine possible decimal values for any octet in a subnet mask. Committing these to memory is the key to high-speed conversion.
The next video gives a quick, animated tutorial on a method that leverages this fact.
How to Convert CIDR Notation value into Subnet Mask | Animation Video
This short video demonstrates a common shortcut for converting CIDR to DDN by breaking the prefix down by octet.
Watch the segments from 01:32 to 02:39 and 03:34 to 05:10. Focus on the 'conversion table' that maps the number of 'ones' in an octet to its decimal value, and see how he applies it to examples like /26 and /20.
Now, let's solidify this with the detailed explanation from the Internold Networks article. It presents the same core idea with a very useful table.
Analyzing Subnet Masks - Internold Networks
This reading provides a deeper look at the conversion process and formally presents the 'nine possible values' table you should memorize.
Read the sections 'Converting Between Binary and DDN Masks' and 'Converting Between Prefix and DDN Masks'. Focus on 'Table 4: Nine Possible Values in One Octet of a Subnet Mask'. This is the most important takeaway. The article's recommendation to memorize this table is standard industry practice.
Here is that crucial table, which maps the number of network bits (1s) in an octet to the resulting decimal value.
| # of 1s in Octet | Binary Value | Decimal Value |
|---|---|---|
| 0 | 00000000 |
0 |
| 1 | 10000000 |
128 |
| 2 | 11000000 |
192 |
| 3 | 11100000 |
224 |
| 4 | 11110000 |
240 |
| 5 | 11111000 |
248 |
| 6 | 11111100 |
252 |
| 7 | 11111110 |
254 |
| 8 | 11111111 |
255 |
Let's walk through two examples using this shortcut.
Example 1: Convert /22 to DDN
- A
/22prefix means 22 ones. - Break it down by octet:
- Octet 1: 8 ones ->
255 - Octet 2: 8 ones ->
255 - Total so far: 16 ones. We need 6 more (22 - 16 = 6).
- Octet 3: 6 ones. From the table, 6 ones is
252. - Octet 4: 0 ones ->
0
- Octet 1: 8 ones ->
- Result:
255.255.252.0
Example 2: Convert 255.255.255.248 to CIDR
- Look at each octet and find its corresponding number of ones from the table.
- Octet 1 (
255): 8 ones - Octet 2 (
255): 8 ones - Octet 3 (
255): 8 ones - Octet 4 (
248): 5 ones
- Octet 1 (
- Add them up: 8 + 8 + 8 + 5 = 29.
- Result:
/29
4. Reference and Practice
To help you, here is a complete reference chart. This is a valuable tool to bookmark or download. It directly maps every CIDR prefix to its DDN mask and also shows the total number of addresses in that subnet—a topic we'll explore in the next lessons.
This table from an article on freeCodeCamp is an excellent cheat sheet for all CIDR prefixes. You don't need to read the whole article, just use the table as a reference.
Review the table, focusing on the 'CIDR' and 'Subnet mask' columns. Notice the patterns as the prefix length changes.
Practice Exercise
Now it's time to put this into practice. The only way to get fast is through repetition.
Below is an image of a worksheet. Please complete the first exercise, "Subnet Mask to CIDR Conversion". For each row, fill in the missing value, whether it's the DDN mask or the CIDR prefix. Ignore the second exercise in the image for now; it covers topics for future lessons.

Take about 15 minutes to complete this. Try to use the "magic numbers" shortcut without looking at the full cheat sheet.
(You can check your answers below when you're ready)
Answers to the Worksheet (Exercise 1)
| Subnet Mask | CIDR |
|---|---|
| 255.255.255.224 | /27 |
| 255.255.240.0 | /20 |
| 255.255.255.192 | /26 |
| 255.255.255.248 | /29 |
| 255.128.0.0 | /9 |
| 255.255.192.0 | /18 |
Conclusion
Excellent work. In this lesson, we established the fundamental relationship between dotted-decimal subnet masks and CIDR notation.
Here are the key takeaways:
- CIDR was developed to replace the inefficient classful addressing system, enabling flexible subnet sizes.
- A subnet mask has three formats: binary, dotted-decimal (DDN), and CIDR prefix.
- The CIDR prefix (
/x) is a direct count of the network bits (the leading1s) in the 32-bit binary mask. - The fastest way to convert between DDN and CIDR is to memorize the nine possible decimal values an octet can have in a subnet mask and how many network bits each represents.
You are now equipped with the basic language of subnetting. In our next lesson, we will build directly on this by learning how to calculate the network address and broadcast address for any given IP address and subnet mask. This is the next logical step in dissecting a subnet.