3

I'm trying to understand the factors that go into the decision-making process of designing the size of a subnet. According to this excellent cheat sheet:

  • A /24 subnet mask gives you 65,536 subnets and 254 hosts
  • A /18 subnet mask gives you 1,024 subnets and 16,382 hosts
  • etc.

So it apears that the two main factors for deciding subnet mask size (e.g. /24 vs /18) is: how many subnets do you want, and how many hosts do you want available for that subnet?

The latter factor makes sense to me: if I know I'm carving out a subnet for a medium-sized team that might have a half-dozen apps/services, where each one of these might have 3 - 6 nodes per environment, and might have 2 or 3 different environments (Dev, QA, Prod, etc.), then I know that team roughly needs ~90 hosts available in their subnet, so I might be inclined to give them a /25 (126 possible hosts) subnet mask.

However, I'm not understanding the first factor in this equation: the number of subnets each mask gives you. A /18 subnet mask gives you 1,024 subnets, whereas a /24 subnet mask gives you 65,536 subnets.

What does this even mean?! Just going on intuition, it sounds like it's possible for you to recursively carve subnets out of subnets out of subnets, etc. Yes? And if that's true, then maybe when designing a subnet you will sometimes know how many sub-subnets you're going to need your subnet to contain, and that might be an important factor in making your decision? Am I on track here or way off base?

Ultimately I'm just trying to understand the third column in that table ("Number of Subnets") and understand how/why that plays a role in determining the subnet mask/size you choose when creating a subnet.

2

However, I'm not understanding the first factor in this equation: the number of subnets each mask gives you. A /18 subnet mask gives you 1,024 subnets, whereas a /24 subnet mask gives you 65,536 subnets.

How many subnets you have depends on how large the network itself is. Without knowing that, these cheat-sheets are useless.

Your linked cheatsheet is not "excellent" anymore – it is rather old; notice how it has separate tables for "Class A", "Class B", and so on. Back then, if you had a class-A network (nowadays /8) and divided it into /18-sized subnets, you'd indeed have 1024 subnets (10 bit wide subnet ID).

But these days you directly get a CIDR allocation instead, which might be of any size – so you'd need something similar to a multiplication table instead. This might be a useful cheatsheet which lets you visually divide a network. (Although your tables still have the right numbers, you can see that they're incomplete – only useful for three specific starting sizes.)

The calculation itself is simple, and you use the same method to calculate subnets-per-network and hosts-per-subnet:

  • let's say you got a /16 and need /23's, then you have 23 - 16 = 7 bits for the subnet ID, so 2⁷ = 128 possible subnets;
  • those /23 subnets have 32 - 23 = 9 bits for host ID, so 2⁹ = 512 possible addresses (510 hosts).

Just going on intuition, it sounds like it's possible for you to recursively carve subnets out of subnets out of subnets, etc. Yes? And if that's true, then maybe when designing a subnet you will sometimes know how many sub-subnets you're going to need your subnet to contain, and that might be an important factor in making your decision? Am I on track here or way off base?

Yes, that sounds about right.

Although note that "network" or "subnet" can mean either a route or an on-link subnet (a broadcast domain) – specifically, things like "reserve 2 addresses" only apply to the latter at the very end, but not to routes along the way.

For example,

  • the Internet has a /12 route towards some ISP, covering that ISP's entire network;
  • the ISP then routes a /16 sub-network to a customer organization (65536 addresses),
  • who then routes several /20 sub-networks to every building (4096 addresses),
  • and finally assigns /24's as on-link subnets to each floor, or division, or such (256 addresses minus 2 reserved = 254 possible hosts on each floor).
1

Your IPv4 address is a 32 bit number (which usually is represented a bit nicer). The subnet mask decides how many of those bits are used to identify the network and how many of those bits are used to address a host. If you're using 8 bits (2^8 = 256) for your host you're left with 24 bits (16,777,216) addresses for networks. Your examples states 65,536 because they assume you have a class A network so you shouldn't choose the first 8 bits freely but rather would have them assigned to you. So out of those 24 bits you can only use 16 to identify the network.

Network classes are kind of old and today CIDR is a thing because that static model would mean you'd always at least own 256 addresses.

Some other questions like the following have some good and more in-depth responses and/or more illustrative responses:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.