All of these answers are great in different ways, but they’re missing the *why.*
So I’m going to assume you know a little bit of what I’m saying for convenience sake, but if you have any questions please ask so I can clarify.
So, u/ViskerRatio explained masking as a concept wonderfully. That’s why it’s called a *mask.* But they left out a little bit of pre-requisite knowledge required to understand why we might want to mask a subnet.
IP addresses are normally divided into Classes, Class A-E. Class D is for multicast addressing and Class E is for experimental uses, so instead we’ll just focus on A-C as D and E aren’t relevant to understanding how networks are divided. Class A addresses allocate the first 8 bits to the *network* and leaves the remaining 24 bits for *hosts.* Class B gives 16 bits to the network and the remaining 16 to the hosts. Class C gives 24 bits to the net and 8 to the host.
**What does that mean?**
Because we defined IP addresses as a 32 bit binary number, we only have a certain amount of addresses available. Your home router IP address might be 192.168.0.1. But in binary that’s **1100000.10101000.00000000.00000001.** That’s only relevant because the most amount of bits you can turn on, or make 1s, is *all of them.*
So that leaves us in a bit of a pickle. The total number available if we turn on all bits in an 8 bit segment is 256. Basically, 2^8=256. (Remember, we start counting at 0 in binary so you’ll see the highest number as 255. This can trip you up if you’re new.)
**That means that in a Class A network, where the first 8 bits are reserved for the** ***network,*** **the most amount of** ***networks*** **we can have is 256.** (It’s a little more complicated than that, but let’s just ignore that part too for just a little bit.) Conversely, that leaves 2^24, or 16,777,216 available hosts!
The opposite is true for Class C networks. Class C only has 256 available hosts, but allows for almost 17 million unique networks!
So a massive organization like Google or the US Military might buy a Class A address block to allow their organization to have a massive amount of hosts, or users. Conversely, most ISPs hand out Class C networks to general users because a Class C was the smallest division available and no standard home user is going to need more than 256 devices.
**Okay nerd, so what does this have to do with subnet masks?**
Well, if you wanted a fantastic ELI5, u/aoeex has you covered. What’s happening is you are **sub**dividing your **net**work so that you can have a varied number of hosts. You could call a Class C network a 192.168.0.1/24 because 24 bits are reserved for the network. Well I can decide to divide my 256 hosts into two networks of 128, or 8 networks of 32, etc etc. You’d call those 192.168.0.1/25 or /27 respectively.
Additionally, if you need *more* networks you can go the other way.
[I really suggest reading about CIDR notation.](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#:~:text=CIDR%20notation%20is%20a%20compact%20representation%20of%20an,the%20routing%20mask%2C%20traditionally%20called%20the%20network%20mask.)
Latest Answers