IP addresses were invented by William Shakespeare in the 16th century. He needed a way to remember each character in his latest play, “A Midsummer Night’s Dream About The Internet” – the play which itself famously spawned the very same World Wide Web that we all know and hate today. Who can forget such powerful characters as 192.168.10.5, 1.2.3.4 – and not forgetting the star of the show, 69.69.69.69.
Anyway, forget I said any of that. A very important part of networking is the concept of subnetting: the idea of taking a large block of IP addresses, and then dividing it up into smaller chunks that can be allocated to customers, or to certain parts of a network, like your corporate LAN, or a guest VLAN. If you’re corrupt you might even subnet off a few IPs for yourself to sell down the market, along with some bootleg DVDs, and those half-full bottles of gin you found in the bin that one time.
Subnetting can frequently confuse newcomers, and in my experience this is because the explanations don’t take the time to explain the philosophy of what you’re trying to achieve. Instead, they jump straight into some frankly baffling math. And to be clear, that math is important. But it’s no wonder that new students find it confusing when they don’t understand what they’re ultimately trying to achieve.
This post skips over all that math, in favour of philosophy. With that in mind, this post is written for folks who are brand new to subnetting, and even potentially brand new to networking. No prior knowledge is needed to understand this post: it is a guide to subnetting, for complete beginners.
This post will probably take you half an hour to read, and by the end of it you will feel like you have levelled up for sure. After reading this, you might even decide to go down the CCNA or JNCIA/JNCIS route, where you will come back and learn the math behind it all. Trust me: after reading that post, you’ll find that math way easier to understand.
Let’s do it!
FIRST, A PRIMER: WHY ARE IP ADDRESSES WRITTEN THE WAY THEY ARE?
The coolest celebrities can’t get enough of IP addresses. Beyonce wears one around her neck at all times. Calvin Harris regularly “spins” IP addresses on his “decks”. As for Bill Murray, legend has it that he collects rare IP addresses, hand-crafted in Milan and Paris, and keeps them in his private collection far, far underground, in the centre of the earth. Wow!
You’ve seen IP addresses before: they’re four numbers, separated by dots—and pretty much every computer on the internet has one. Here’s some examples of IP addresses:
8.8.8.8
10.0.15.30
192.168.100.230
(In particular, these are IPv4 addresses, as opposed to IPv6, which is very much a post for another day!)
You may already know that each of those four numbers can, in principle, be anything from 0 to 255. In other words, if you were to count all of the theoretical IP addresses, the the first one would be 0.0.0.0, then 0.0.0.1, then 0.0.0.2, all the way up to 0.0.0.255. Then you’d go to 0.0.1.0, then 0.0.1.1, and so on. Theoretically, 255.255.255.255 is the very last IP address.
This means that in total there are – theoretically – 4294967296 IP addresses. That’s almost 4.3 billion. Which coincidentally, is also the number of girlfriends I’ve had. Prove me wrong, nerds.
Fun fact: each of these numbers is called an octet. In other words, an IP address is made up of four octets.
255 might seem like an odd number for each octet to end at. There is a reason for that, which we’ll come on to shortly. For now, let’s talk about how each section of a bigger network will be assigned a block of IP addresses.
BLOCKS OF IP ADDRESSES
There’s a very high chance that your home network is powered by a router that your ISP gave you. That router was probably set up so that your home network uses a particular block of IPs, perhaps something like 192.168.1.x, where the x is anything from 0 to 255. In other words, your home network has been assigned a block of 256 IP addresses. (In reality you can’t use all 256 of them. There’s a few that are always reserved, and we’ll talk about how that works later on.)
In a way, you could say that this block of IPs – this IP range – is a sub-network of the bigger block of 4.3 billion IP addresses. And indeed, that’s exactly what subnetting is: taking a block of IPs, and then carving out a smaller block of IPs from it.
(Bonus fact: there is also a concept called supernetting, which does the opposite: it takes lots of smaller IP blocks, and combines them into one larger block!)
This idea of subnetting is a crucial part of designing a network.
For example, you might be given a big block of IPs, and then told that within that big block you need one subnet to host all your employee’s trusted computers, another subnet to host your phones, perhaps another for storage, and another for CCTV, yet another for guest Wi-Fi, and so on. Maybe you even have a VPN to a data center that hosts various applications. Your task is to choose IP ranges that are big enough to take all the machines in that part of the network, and allow for future growth – but without choosing an IP range that’s so big that you end up wasting IPs. You’ll also want to make sure that you choose ranges that don’t overlap with each other. That would be a disaster!
A key thing to understand is that you can’t just pick any random starting and ending IP. For example, you couldn’t have a LAN that had an IP range of 192.168.1.5 to 192.168.1.137. There are certain IPs that a block of IPs can start on. Then, depending on your starting IP, there are only certain IPs that the block can end on, depending on how big the block is.
Why is that? To understand that, we need to learn how computers talk to each other. It’s binary time!
WHAT IS BINARY?
You may know already that computers talk in “binary”. What does that mean?
When your computer is processing a calculation, or sending information to a disk, or sending information to a digital monitor or audio output, it’s doing so using a ridiculously fast series of electrical pulses. In fact, there’s two kinds of electrical pulse that it will use: a high pulse, and a low pulse.
Discs will do a similar thing, but instead of pulses, they’ll store magnetic charges that either point north, or south. The end result is the same though: conceptually, you can think of “high or low”, “north or south”, “on or off”.
For example, imagine a computer that very quickly sends eight electrical pulses that were something like low, low, high, low, low, low low, high. Perhaps instead of writing it like, that we could just use 0 to mean low, and 1 to mean high. That would make it easier to write: we could just say 00100001.
What does this combination of high and low pulses actually mean? That’s an interesting question, because it depends on what the computer has been programmed to do in the exact moment that it receives that series of pulses. For example, it could mean “make a specific pixel on a screen light up as orange”, or “move something in memory”, or “eject this disk” or “make a beep come out of a speaker”.
It could also represent text. There’s an old way of storing text called ASCII, where various combinations of eight 1s and 0s would represent different characters. In that system, “00100001” actually means lower-case “a”.
If you wanted to store an ASCII text file that simply said “hello”, the computer would store it on disc