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.
Subnet Masks
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.
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.
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.
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.
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.
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 →