TechKnowSurge
CompTIA Network+ 1.7 Cisco CCNA 1.6 Cisco CCST Networking 2.2 CompTIA A+ Core 1 2.6
VideoNetworkFree

Subnet Masks

Subnet masks define the boundary between network and host bits in an IP address, using binary values that translate into specific decimal numbers per octet. Understanding the binary math behind those numbers makes reading and calculating subnet masks straightforward.

Complete this video to capture a CTF flag worth 1 point.

About this video

A subnet mask is a 32-bit value that marks the dividing line between the network bits and the host bits in an IP address. When that line falls on a classful boundary — the end of the first octet for Class A, the second for Class B, the third for Class C — the result is called a default subnet mask, such as 255.0.0.0, 255.255.0.0, or 255.255.255.0. Historically, subnet masks were not strictly necessary under classful addressing because the class could be inferred from the first octet alone, but they became essential once subnetting allowed network boundaries to be drawn at arbitrary bit positions. When the boundary is moved away from its classful position, the result is a custom subnet mask, and the network prefix length in CIDR notation reflects the total count of 1-bits in the mask. A mask like 255.255.192.0, for instance, contains 18 consecutive 1-bits and is written as /18. The decimal values within each octet may look irregular at first, but they follow a predictable binary pattern: each additional borrowed bit adds the next power of two — 128, then 64, then 32, and so on — producing the familiar sequence of 128, 192, 224, 240, 248, 252, 254, and 255. Once an octet is fully borrowed and reaches 255, borrowing continues into the next octet from the left. Fluency with these octet values and their binary equivalents is a foundational skill in IP addressing and subnetting. Whether reading a subnet mask in dotted-decimal or CIDR notation, the ability to quickly translate between binary and decimal makes it possible to determine network boundaries, calculate usable host ranges, and design address schemes efficiently. These values appear consistently across networking tasks, from configuring interfaces to analyzing routing tables, and recognizing them on sight accelerates work at every level of network administration.

What you'll learn

What's covered

Subnet Masks

Aligned to

CompTIA Network+
1.7 Given a scenario, use appropriate IPv4 network addressing.
Cisco CCNA
1.6 Configure and verify IPv4 addressing and subnetting
Cisco CCST Networking
2.2 Identify IPv4 addresses and subnet formats
CompTIA A+ Core 1
2.6 Compare and contrast common network configuration concepts.

Key terms

Subnet Mask
A 32-bit number that divides an IP address into network and host portions.
Subnet
A logical subdivision of an IP network, used to organize and segment network traffic.
IP Address
A numerical label assigned to each device connected to a network that uses the Internet Protocol.
Default Subnet Mask
A subnet mask that draws the network/host boundary at the classful boundary of an IP address class, such as 255.0.0.0 for a Class A address.
Custom Subnet Mask
A subnet mask that draws the network/host boundary at a point other than the classful boundary, allowing flexible division of network and host bits.
Classless Inter-Domain Routing
CIDR
A method for allocating IP addresses and expressing routing prefixes that replaces the older classful addressing scheme by using variable-length prefix notation (e.g., /24). CIDR enables more efficient use of IPv4 address space and reduces the size of internet routing tables through route aggregation.
Classful Addressing
An early IPv4 addressing scheme that divided the address space into fixed classes (A, B, and C for hosts; D for multicast; E reserved) based on the leading bits of the address, with each class defining a fixed boundary between the network and host portions. Classful addressing was replaced by CIDR because it wasted large blocks of address space.

Transcript

When you first start taking a look at subnet masks, it can be a little confusing at first. The numbers look really odd, but as long as you know the binary, what's happening behind the scenes, it really makes a lot of sense and it's really simple to understand.

Default Subnet Masks

Let's talk about a default subnet mask. A default subnet mask is just the classful subnet mask, so it's just drawing the line where the classful line would be drawn.

So an example of this is, we can see that this is a 10 in the first octet, so this is a class A. A class A means it's just the first octet that is the network bits and the rest of them are host bits. So in this example right here, these would be the bits that are associated with the network, these are the bits that are associated with the host. So because of that, these bits right here are all one and these bits are all zero for the subnet mask. This is the default subnet mask, and we'd specify that as 255.0.0.0, and the CIDR notation for this would be 10.0.0.0/8.

I will just drive home one point about this: a default subnet mask really didn't exist, it really wasn't a necessary thing when you had classes, because when you had classes it just looked at the first octet and it could determine what the subnet was. It didn't need a mask at all. But when subnets came by, then we had to have a subnet mask that specified where the line was drawn. And if you draw the line where a classful line is at, then it just becomes a default subnet mask.

Custom Subnet Masks

Then we also have this idea of a custom subnet mask. A custom subnet mask just means that we've customized it, we've drawn the line somewhere different than its classful boundaries. So rather than drawing the line on its classful boundaries, we've drifted in the line. In this example right here we've drawn the line right here, and this is the network bits and this is the host bits for this. So because of that we end up getting this kind of strange number here, 192. And masks look a little bit odd because they go zero and then 128, then 192, then 224, then 240. So they look a little strange, but that's real easy and we'll get to that here in a second. But then the CIDR notation, this is just the /18, because if you count all the ones here you would have 18 ones. So that's the CIDR notation for it.

Where the Odd Numbers Come From

So here's the explanation behind those odd numbers with the subnet mask. If I were to have all zeros here, it would be zero zero zero zero zero zero zero zero, we would just come up with it is zero. So we haven't borrowed any bits. But if I borrow one bit, now we have a one in the 128 column here, so our first decimal is 128. If I were to turn two bits and borrow two bits, then I'd have 128 plus 64, which is 192. If I were to turn on another bit and borrow another bit, then I have to add 32 to that, so that would be 224. And then if I add another one into it, then that's plus 16. So you can see how this is going to go: 240, and then the next one is 248, and then 252, 254, and finally 255.

So these are why you see, when it comes to the decimal equivalent of a subnet mask, why it counts up a little strange. And you're going to want to become very familiar with these numbers, because you're going to use these quite a bit and you're going to see these quite a bit when it comes to your subnet mask.

And remember that's going to be a per octet here. So if I'm drawing the line here, these are all going to be 0 here and it's going to be zero. But if I start moving the line right here, then this becomes a 128, and then next would be a 192, so I'll do a 192 in here if I draw the line there. If I draw the line there, then it becomes a 224, and then a 240. And same thing: once I fill this all up and have borrowed all the bits, this becomes a 255, and then I can start borrowing from the next one. So each of these strange numbers will appear consecutively with each one of these octets, depending on where I'm drawing the line.

Putting It All Together

Just to summarize it all up, let's say I'm going to draw a line somewhere. So I'm going to draw the line, let's say right here, and then these are all ones here, specifying these are the network bits. So what I've borrowed here is I borrowed all eight of these in this octet right here, so that's going to be 255. And then I borrowed a 5 right here — one, two, three, four, five — so I'm going to add 128 plus 64 plus 32 plus 16 plus 8. And then the rest of these are going to be zeros here. So if I do that, then let's see, this is 128, 192, 224, 240, 248. So the answer here is going to be 248.0. So that is how we figure out the subnet mask.

About TechKnowSurge

TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.

Explore free tools and programs →