What this document is about:
This document will cover two quick ways for figuring out the numbers behind subnetting. The first way involves making a simple chart, the second way uses simple math that most people can do in their head, at least for smaller numbers. The first way is recommended for any exams, or times when you need to do a lot of subnetting quickly. The second way works best if you just need to know one or two examples, or to check your work from the chart.
Pre-requirements:
This document does not tell you what subnetting is, nor does it tell you why you subnet. It also does not cover any types of binary math or the like. So to use this document, you must understand the following:
1) How to convert decimal to binary
2) How subnets and subnet masks work
3) The basic subnetting rules, such as broadcast addresses and network addresses
Subnetting process:
Part 1) Introduction to the processes covered in this document.
I will be covering two different subnetting processes. The first one takes a bit of time, as it’s a fairly large chart you have to write out. The second way needs no setup, it’s simple subtraction and division. However, for large subnets (510+ hosts) or large numbers of subnets (again, 510+) you may need scrap paper.
Part 2) Chart-Based Subnetting
If you ask any game programmer what’s the fastest way to compute something, he’ll say to pre-compute it. The idea of lookup tables, or figuring out the hard math one time, before you need too, can be applied to many things in life. Timed Cisco and CompTIA exams are one of them.
When you take exams you are not allowed to bring in any of your own paper or the like, but they hand you paper to use while in the exams (Or, dry-erase markers like at my exam place). many people do a “brain dump” where they write down all the things they can think off of the top of their head. This process gave me the idea, if I could memorize a subnetting chart, I could really reduce the time needed for subnetting questions. So, I started writing down all the math I could think of that would help me, the powers of 2, the different valid subnet masks (there’s nine different values per octets that you can have) and the binary values of these masks. Then I sorted it, and came up with a chart like this:
+-------------------------+---------------------+----------+
| Network Section | Host Section | Net Mask |
+---+---------+-----------+---------+-----------+----------+
|128|1 | 0/510 | 000 0000| 126/32,766|1/9/17/25 |
|192|11 | 2/1,022 | 00 0000| 62/16,382|2/10/18/26|
|224|111 | 6/2,046 | 0 0000| 30/8,190 |3/11/19/27|
|240|1111 | 14/4,094 | 0000| 14/4,094 |4/12/20/28|
|248|1111 1 | 30/8,190 | 000| 6/2,046 |5/13/21/29|
|252|1111 11 | 62/16,382| 00| 2/1,022 |6/14/22/30|
|254|1111 111 | 126/32,766| 0| 0/510 |7/15/23/31|
|255|1111 1111| 254/65,534| | X/254 |8/16/24/32|
+---+---------+-----------+---------+-----------+----------+
While this chart may seem complex, and it may seem like you can’t make it while in the exam, it’s actually just built from some simple math. There’s seven steps to making the chart, so let’s start now...
Part 2a) Available masks.
There are nine valid numbers that can be in a subnet mask, 0, 128, 192, 224, 240, 248, 252, 254, 255.How do we get these numbers? Well, remember the numbers used in binary math:
128 64 32 16 8 4 2 1
Well, if you have 0 bits set aside for the subnet inside that octet, then the mask would be 0. If you have 1 bit, then you would have 128 for the mask. (Remember the basics of subnetting, networks start on the LEFT and move right. By adding a bit to the network side, it moves down the line) So if you have two bits for the subnet mask, it would look like this:
128 64 32 16 8 4 2 1
1 1 0 0 0 0 0 0
Or, in other words, 128+64. 128 + 64 = 192. Three bits? 128+64+32, or 192+32, or 224. This is how we get the first column on the chart, by figuring out all the valid subnet masks. After a while you’ll just remember them, but when you start out, you may need to do a little figuring off to the side.
Before you begin, you should also note that, while there are nine values for the subnet masks, only eight are in the chart. I skipped the 0 mask, since it’s overlapped by the 255. If you have a subnet mask of 255.255.0.0 then you have both 0 and 255, I just decided to use the 255 in the B class, rather then the 0 of the C class.
So, the chart will have 8 rows of data. First column is a list of all subnet masks. Keep the binary number chart in mind when you do this. First number is 128. Then, below the, add the next number, 64, for 192. Then add 32, for 224. Then 16, for 240. Then 8 for 248, until you have all 8 subnet masks. Too much thinking? Well, let’s take a break from thinking and do an easy step, step 2.
Part 2b) Network bits
The second section on the chart shows you how many bits are user per mask.. For example, 128 uses 1 bit, so it’s written in binary as 10000000. 192 uses two, 11000000. To make it simpler to read, I just included the 1’s, or the bits used for the network. And since each number down the line uses one more bit, this is very easy to make. Just put down one 1 for 128, then two for 192, three for 224, on down to eight for 255 (255 mask uses all 8 bits for the network part of the mask). When I write it, I put a space every 4 bits, to make it quicker to read. So six bits active in the network mask would show up as 1111 11. So after this set, your chart looks like this:
+-------------------------+
| Network Section |
+---+---------+-----------+
|128|1 |
|192|11 |
|224|111 |
|240|1111 |
|248|1111 1 |
|252|1111 11 |
|254|1111 111 |
|255|1111 1111|
+---+---------+
Part 2c) Powers of two
This part here forms a second sub-chart. I like to write out the powers of 2, generally up to 16. This helps with a lot of math, since finding the number of valid hosts is 2^(Number of host bits)-2. And powers of two are simple to do, it you do them in a row. If someone asked you, what’s 2 to the power of 17, how long would it take you? If someone asked you what’s 65536 * 2, think you could do it faster? I know I sure as hell could.
so that’s ALL you have to do, write down a 2, then each line, double it. so you get a chart like this:
2 | 1
4 | 2
8 | 3
16 | 4
32 | 5
64 | 6
128 | 7
256 | 8
512 | 9
1,024 | 10
2,048 | 11
4,096 | 12
8,192 | 13
16,384 | 14
32,768 | 15
65,536 | 16
Simple? If you REALLY want, you can go up to the powers of 32, but not only is that kind of silly, and takes a long, long time, the higher numbers are NOT valid in subnets. How often do you see a network 10.0.0.0/7 ? So, 16 bit is a good place to stop. 24 bit would be the highest you should even think about going. So you got your nice chart, and can not do 2^1 up to 2^16 with a glance, now we need to move on to the next part of the chart, networks.
Part 2d) Networks
Before we go on, there’s something you need to keep in mind. If you have 4 bits set aside for the subnet, how many networks do you have, 2^4, or 2^4-2 ? Or even 2^4-1 ? Well, depending on the network, all three can be valid. Most people go by the -2, where it removes subnet zero and the all ones subnets. But on most new equipment, both subnets are valid. If you do a show run command on the Cisco router, you will see the current status of subnet zero, if enabled or disabled on that router.
So for this part of the chart, we’ll use networks = 2^(bits)-2. So the first mask, 128, has 1 bit set aside for networks. This would be 255.255.255.128 when used with a class C address, such as 192.168.0.0 (If it was a B class network, like 172.16.0.0, then 255.255.255.128 would have 9 bits for the subnet, not 1. 1 bit mask for a class B address is 255.255.128.0. 1 bit for a class A is 255.128.0.0)
Since the 128 mask has 1 bit, we look up on the chart 2^1, and that’s 2. 2-2 = 0, so we write that down. Keep that in mind, 128 is not a valid subnet when your not using subnet zero and all ones subnet, since that’s all that’s generated, a zero subnet and an all ones subnet. If you can use these subnets, then 128 is valid in network masks.
Below 128, the next mask is 192. This has 2 bits, so we look up the power of 2 on the chart, it’s 4. 4-2 is 2. And we move on to 224, with three bits. 2^3 is 8, 8-2 is 6, so 6 networks. We repeat this till we get to 255 mask, with 8 bits, that’s 256 -2, or 254 valid hosts per network. A standard class C network.
While you could stop, I like to at least cover subnets up to 16 bits, meaning one more pass. After the 0 on the 128, put a slash ( / ) and the find the number for 9 bits (8+1). That’s 512-2. Keep in mind, when you write the chart, the first number is when you have 1~8 bits, the second number is 9~16. I’ll cover this more in the usage section of the cart.
So, you follow the chart you wrote for the powers, subtracting two from each one, until you once again hit 255, this time with 66,534. At this point your chart looks like this:
+-------------------------+
| Network Section |
+---+---------+-----------+
|128|1 | 0/510 |
|192|11 | 2/1,022 |
|224|111 | 6/2,046 |
|240|1111 | 14/4,094 |
|248|1111 1 | 30/8,190 |
|252|1111 11 | 62/16,382|
|254|1111 111 | 126/32,766|
|255|1111 1111| 254/65,534|
+---+---------+-----------+
And now it’s on the working on the host side of the chart.
Part 2e) Host bits
Now that it’s time to move onto the host section, we have three easy steps. The first one, writing the host bits, is just putting the 0’s down where the bits used for the hosts are in the net mask. For example, in 128, the mask is 10000000, and since all 0’s are for the hosts, you put on the chart 000 0000. Then each line, you remove one, until on 255 you have nothing to write. Like this:
000 0000
00 0000
0 0000
0000
000
00
0
If you look, this should match up with the 1’s bits in the network portion. For example, the 224 mask has 111, and 0 0000. That’s eight total bits, three for the network, and five for the hosts. The last one, 255, will have no bits, while all the network masks has at least one bit. This is because of the overlap of 0 and 255 masks. If we had done the 0 mask, it would have been above the 128 line, with no bits for the network, and eight 0’s for hosts, or 0000 0000. Meaning all bits for this part is dedicated to the host.
Part 2f) Number of Hosts
Finding the number of hosts is easy, cause you already did the math. The number of hosts is 2^(Host bits)-2. The same thing as the network side, just as the network moves up, hosts move down. So, starting with 255 and moving up, you write the number of hosts per network. The first line is the dual duty 255/0 line, so it’s a bit special. You have 0 bits set aside for hosts, meaning you can not have this as a network. so we just put an X there for now. Nest up, the 254 line. We have 1 bit for the hosts. If you look at the 128 line for networks, you see that it also has 1 bit. 2^1-2 = 0, so this mask has 0 hosts. On to the 252 mask, we have two bits for hosts, and if we look at the network side, three bits is 6 networks, and for us, 6 hosts.
So, to make this side quickly, you just place an X on the last one, 255, then moving up, you copy the network numbers down. As you move up the hosts column, you move down the network column, until you hit 126 hosts. The next line, 254, you wrap around and place it behind the X, like this:
+-------------------------+---------------------+
| Network Section | Host Section |
+---+---------+-----------+---------+-----------+
|128|1 | 0/510 | 000 0000| 126/
|192|11 | 2/1,022 | 00 0000| 62/
|224|111 | 6/2,046 | 0 0000| 30/
|240|1111 | 14/4,094 | 0000| 14/
|248|1111 1 | 30/8,190 | 000| 6/
|252|1111 11 | 62/16,382| 00| 2/
|254|1111 111 | 126/32,766| 0| 0/
|255|1111 1111| 254/65,534| | X/254
+---+---------+-----------+---------+-----------+
So, why do these numbers not line up right? Simple, it’s cause we’re not showing the 0 mask line, remember. Since the data would be the same as 255, we skip it, but if we did show it, the chart would look like this:
+-------------------------+---------------------+
| Network Section | Host Section |
+---+---------+-----------+---------+-----------+
| 0| | X/254 |0000 0000| 254
|128|1 | 0/510 | 000 0000| 126/
|192|11 | 2/1,022 | 00 0000| 62/
|224|111 | 6/2,046 | 0 0000| 30/
|240|1111 | 14/4,094 | 0000| 14/
|248|1111 1 | 30/8,190 | 000| 6/
|252|1111 11 | 62/16,382| 00| 2/
|254|1111 111 | 126/32,766| 0| 0/
|255|1111 1111| 254/65,534| | X/254
+---+---------+-----------+---------+-----------+
See the pattern now? The 0 line wouldn’t have served any point, so we skipped writing it, to make things go a bit quicker. So, to finish the host section of the chart, just finish copying the numbers till you get to 32,766. Your finished chart should look like this:
+-------------------------+---------------------+
| Network Section | Host Section |
+---+---------+-----------+---------+-----------+
|128|1 | 0/510 | 000 0000| 126/32,766|
|192|11 | 2/1,022 | 00 0000| 62/16,382|
|224|111 | 6/2,046 | 0 0000| 30/8,190 |
|240|1111 | 14/4,094 | 0000| 14/4,094 |
|248|1111 1 | 30/8,190 | 000| 6/2,046 |
|252|1111 11 | 62/16,382| 00| 2/1,022 |
|254|1111 111 | 126/32,766| 0| 0/510 |
|255|1111 1111| 254/65,534| | X/254 |
+---+---------+-----------+---------+-----------+
And now we move on to the last part...
***Coutesy of Ozzy_98***