So, subnetting is a hard concept to understand. I had to try and grasp it this week for my coursework, and I thought you might be interested hearing about how I came to understand it. Maybe it’ll help you!
Basically, subnets are small networks within a largenetwork. They’re a range of IP addresses that are considered together, within the scheme of a larger range of IPs. (When I say IP or IPs, I mean IP addresses). It’s a quick way of creating separate networks all using the same infrastructure. The subnet mask is a IP address-like number that tells the computer where in the range of IPs one subnet ends and another begins. How it does this exactly isn’t clear until you look at the binary. But first, let me explain a few other things.
What you need to understand to understand subnetting:
- Pretty much everything here only applies to IPv4, as far as I know… IPv6 may be very different, or exactly the same, I don’t know.
- IP addresses can be broken down into two parts: The net ID and the host ID. The net ID is like an IP that identifies the network, while the host ID is the number given to each device on the network.
- IP addresses are represented as 4 decimal numbers because they’re easy for humans to remember. In truth, they are 32-bit (32 places) binary numbers which are broken down into 4 octets (sets of 8 places/numbers)
- The subnet mask is a binary number just like an IP address and is used by the computer to tell what bits in the binary form of the IP address are being used for the net ID and which are the host ID. Any bits that have a 1 in their position in the subnet mask are part of the net ID, while the bits with a 0 are part of the host ID.
- Subnet masks must fall between bit changeovers. That is, all the bits to the left of position X must be 1s and indicate the net ID, and all the bits to the right of position X must be 0s and indicate the host ID. That’s why subnet masks usually start with 255, because 255 = 11111111 in binary.
- The number of hosts you can have in a subnet is dictated by the number of bits in your host ID. The number of bit in your host ID = n.
- Subnets can only have a set number of hosts, all of which are 2^n (2 to the power of n), i.e. 1, 2, 4, 8, 16, 32, 64, 128 etc.
- Actually, that’s not totally true. They can only have (2^n) – 2, because the very first and last IP address in any network are reserved. The first IP refers to the network itself, and the last IP refers to every device on the network (broadcast/multicast address).
- How you choose your subnet mask depends on three things: what IP range you have to work with, how many subnets you need, and how many devices you want on each subnet.
- The number of subnets you can use is determined by the number of bits in your subnet mask that are hanging over the edge of an octet, e.g. 11111111 11111111 111 has three hanging over while 11111111 11111111 11111111 111111 has 6. This too uses 2^n, where n = the number of bits hanging over.
- To work out what this number is in decimals, you can work with this sequence: 128, 64, 32, 16, 8, 4, 2, 1. For each 1 hanging over, add the next number in the sequence to your total. E.g. 111 would be 128 + 64 + 32 = 224 and 111111 would be 128 + 64 + 32 + 16 + 8 + 4 = 252. This number is the last number in your subnet mask, with the ones before it being 255 ( = 11111111). These numbers follow a sequence also, but it’s usually easier to work it out again than memorise the sequence.
- The available IP range determines which octet your subnet mask can hang over into. If you have a range that only varies in the fourth octet, then you’ll have to hang over into the fourth octet. However, if your range is too small, you may not be able to subnet it as you need. E.g. If you have from 192.168.5.0 to 192.168.5.10, you would only be able to fit 2 usable subnets with 2 hosts in each.
- Once you’ve worked out your subnet, you can express your network and subnet together as what’s called an extended network prefix, which is the net ID of the first subnet followed by a slash and the number of 1s in your subnet mask (the number of bits it uses). E.g. 192.168.3.0/29
I’ve only explained the basics here, and for some parts, I haven’t given you much of the background explanation of why what I’ve said is so. This is partly done on purpose so that you can grasp what’s going on and how to put it into practice before worrying with why and how it happens that way .
The two sources I owe most of my understanding to are, in fact, not from my course but from other places on the internet. They are : IP subnetting made easy by George Ou and Subnetting in 6 easy steps. The guy who made the video (the second link) also had a (seemingly deserted) website which I also got a bit of help from. Both take a much more visual approach, but explain things quite differently form each other, and I suggest that you go and have a look, and a read of both if you want or need a bit more detail or understanding in this area.
Now, don’t get disheartened if you don’t understand all this. Subnetting is a hard concept. I came to understand it a lot better by explaining it here, so maybe you could try explaining it to a friend, or summarising it in comments or on Facebook!
Until Next Time,