- Unsupervised Learning
- Posts
- A Subnetting Primer

# A Subnetting Primer

I would rather *understand* subnetting than memorize charts.

References that show you every combination are useful, and I’ll include one below, but the focus of this resource is to help you *understand* subnetting so that such charts will no longer be needed.

I’ll give a hint: **It’s all about the binary**.

Full image available here.

Most subnetting charts, and even tutorials, just give you the answer. The concept for the chart above is to reinforce understanding of *how we arrive* at the answers. And the approach is remarkably simple: **you just use the binary steps at the top as your guide for each lateral movement**. For example:

For a /25 you start in the 128 place (one extra bit to the right), and that’s your subnet. You have 2 networks, each with 126 hosts in them. Fair enough.

If you want to go another bit to the right (/26), you’re going to add the binary number for that column to 128, which is 64. So, 128 + 64 = 192. That’s your subnet. And since you’ve gone to the right one— and you were at 2 networks—you now have double that number of networks (remember, each slide is an exponent of two, i.e halving). So you now have **4** networks, each with *half* the number of hosts in them (64 – 2 = 62).

So that’s the secret. You slide back and forth on the binary scale; as you go to the left you go up one exponent of 2 in networks, while simultaneously going down one exponent of 2 in hosts. Another way to say that is that for each bit slide to one side you double either the number of networks or hosts while halving the other.

So at one position your networks are 2 and your hosts are 128, and when you go to the right your networks are 4 and your hosts are 64 (-2). If you went to the right instead you’d be at the /24 mark, and guess what? Hosts go UP from 128 to 256 (doubled), while the network goes DOWN from 2 to 1 (halved). One network of 256 (-2) hosts, just like we would expect.

### Full Reference

So the next time you’re having trouble with doing subnets in your head or on paper, try drawing my chart first (binary, bits, subnets, networks, hosts) and remember the binary sliding concept before looking at the full reference chart shown above. I think you’ll find it enjoyable to grok it rather than look it up. And as always, if you have any questions or comments you can contact me here.