|Editor's Note This article was written by TechNet subscriber Phil
Calderone. It explains how to derive the 8-bit subnet tables found on page
95 of the Microsoft Official Curriculum course "Internetworking with
Microsoft TCP/IP on Windows NT 4.0" without having to use a scientific
calculator. For more in-depth, comprehensive information about subnetting,
we highly recommend Introduction to TCP/IP
If you have ever taken a TCP/IP or IIS class, you know how difficult building your first subnet table was. First you had to have a scientific calculator. Then you had to do the "2 to the power of 2" thing, plus all the binary-to-decimal equations. Then you had to list all possible bit combinations for the subnet mask, and then convert them to decimal format to determine the beginning value of each subnet.
Well, here's an easier way. Throw away your scientific calculator.
If you have any knowledge of the table, or at least have built one, you will immediately understand the benefits of this method. However, if you have never built a table before, you should find this pretty straightforward.
You will have to remember a few numbers; the more you remember, the easier it will be. We must remember that the default subnet mask is 255, and the highest number of subnets we can have in the first valid subnet mask is 2. We need to remember that in the Class C host, the last two subnets are invalid. Last, we need to know that there are 4 octets of 8 bits each, and the decimal equivalent for the 8 bits is 128-64-32-16-8-4-2-1. We will use simple math -- multiplication, addition, and subtraction -- to build our table. First, let's do some review.
Example of a Subnet Mask
4 octets separated by periods, each octet with 8 binary numbers.
An octet breaks down like this: 11111111. To convert it to a decimal, you must work from right to left, so the first number in the octet from the right is equal to 1, the second is 2, the third is 4, the fourth is 8, the fifth is 16, the sixth is 32, the seventh is 64, and the eighth, the one on the far left, is 128. So you will have 128-64-32-16-8-4-2-1 as the decimal equivalent to an octet. If you were to add all these numbers together, they would equal 255.
To begin, get two sheets of paper, including one for practice. (I recommend that you do not use a calculator. It will really help you to do the math on your scratch paper.) After you try this method a couple of times, one piece of paper will suffice.
Set up 6 columns with 8 rows (example below).
We're finished with the hard part; the rest is simple math.
Let's begin with the first two columns. To figure the subnet mask, take the number from the range column (column 1), and subtract it from the number in the subnet mask column (column 2). Place the answer in the next row above, and continue until all rows in the subnet mask column are filled.
You have just figured out your subnet mask.
Now let's work with column 3, the number of subnets per subnet mask. From our chart, we know that we have 2 subnets next to subnet mask (.192), so that's where we start. Take the number of subnets times 2, plus 2, and put that answer in the next row down under subnets. Continue until all rows are filled.
You have just figured out the number of subnets per subnet mask.
Your table should look like this.
Now we know the number of subnets we can have per subnet mask, and the starting range of that subnet.
For example, if I have a Class B address with anywhere from 7 to 14 subnets needed, I know I must use 255.255.240.0 as my subnet mask. I also know my range for subnets will begin at 16, and jump by 16's (see example).
And so on. You would go by 16's until all 14 subnets are set up.
To figure out the number of hosts per subnet for Class C addresses, take the number of subnets in column 3 on your table, and turn them upside down. List them in the valid areas of Class C. Start at the bottom-most valid area and go up.
That's the number of hosts per subnet in Class C.
Now to go to Class B.
We take 62 (the highest number of hosts we can have in Class C) and multiply it by 4, (the total number of octets). Then add 6 (the total number of ranges open above the range we are figuring). This gives us the smallest number of hosts per subnet for a Class B address.
Example: 62 x 4 = 248 + 6 = 254, so 254 is the smallest number we can have in a Class B address.
Put that number at the bottom of your Class B Table. To move up the table from there, we will take that number times 2, and add 2 to get to the next range.
254 x 2 = 508 + 2 = 510
That's Class B hosts per subnet.
Now we move to Class A.
Take 16,382 x 4 + 6 = 65,534. This is the starting host for Class A, and we go back to the times-2-plus-2 formula.
Now your subnet mask table should look like this.
In a nutshell:
Take one octet and list its decimal numbers down in order. Make the top row of each column invalid and make the bottom 2 rows of Class C column invalid. Insert .255 at the bottom of the subnet mask column. Insert 2 at the top of the number of subnets column at the first valid spot.
To figure out the subnet mask column, subtract the number in the range column from the number in the subnet mask column. This will give you the next subnet mask number. Then you subtract the number in the range column on its same line from that number to get the next subnet mask number, and so on.
To figure out the number of subnets, multiply the starting number (2) by 2 and add 2 to get the next subnet number. Then multiply that number by 2 and add 2 to get the next subnet number. And so on.
To get the number of hosts, invert the subnet table onto the Class C column starting at the bottom from low to high in the first valid location.
To jump to Class B, take the highest host number (62) from Class C and multiply it times 4 (the number of octets). Then add 6 (the number of open ranges above the number you're on): 62 x 4 = 248 + 6 = 254. Take that number and put it at the bottom of Class B, the smallest number of hosts. To move up the table in Class B, take the number times 2. Add 2 to get the next higher number, and so on until you reach the top.
To jump to Class A, take the highest number from Class B times 4 and add 6. This will give you the bottom of Class A: 16,382 x 4 = 65,528 + 6 = 65,534. Then multiply that number times 2, add 2 to move up the table, then the next number times 2, and add 2 for the next number, and so on.