# High Performance Subnetting

Copied from High-performance Subnetting and re-formatted for MediaWiki with permission from the original author.

Check out the Richard Lohman's application for practicing subnetting skills.

## Overview

This page describes a process for subnetting. With minimal preparation (the creation of a table), an understanding of the process, and a few hours practice, you should be able to subnet any IP address/mask (or prefix) in under 60 seconds. The end result of this will be the network address, broadcast address, and valid IP address range for hosts.

## Prerequisites

There are a few things you must have a good grasp of in order to get through this process. These are listed below:

• Address classes (A, B, and C): Knowing the address class will help you pick the appropriate row in the table from which you will be working.
• Interesting Octet: The "interesting octet" is octet of the address that we are working with. For an IP address such as abc.def.ghi.jkl, def is the second octet, ghi the third, and jkl the fourth. This is essentially where we are replacing values to differentiate between a network number and a host address. For example, given the IP address and prefix 163.45.18.29/21, the interesting octet will be the third octet (with the 18) as that is where most of the work in subnetting takes place. We determine this by looking at the prefix, and identifying the row in the table in which the prefix is found. If this seems unclear, we'll be working with exercises below that will help. A few other notes about the interesting octet: 1) the first octet (with the 163) is never the interesting octet, 2) the interesting octet is usually determined by the address class (the second octet is the interesting octet for class A addresses, the 3rd octet is the interesting octet for class B addresses, and the 4th octet is the interesting octet for class C addresses).

## The Table

The following table is used to do the subnetting:

 MaskBlock Size 128128 19264 22432 24016 2488 2524 2542 2551 A       B    C 9   17       25 10    18        26 11    19        27 12     20         28 13     21         29 14     22         30 15     23         31 16     24         X

The Xs: In the last row, you will notice two Xs. This is because you cannot subnet an address down to this level. With a /30 prefix, the block size is 4, leaving a network address (1) a brodcast address (2) and two valid host IP addresses (3 and 4). If you attempt to subnet further with a /31 prefix, this would result in a block size of 2, with one for the network address, one for the broadcast address, and nothing left for host IP addresses [sic]. There is a /32 mask that is valid, however that is unrelated to subnetting.

## The Process

OK. Enough of the talk. Let's do a few exercises to see how this works.

We begin with the IP address provided above and a prefix, 163.45.18.29/21.

1. Write down the ip address and prefix on a sheet of paper:
```163.45.18.29/21
```
2. Look up the prefix number (21) in the bottom half of the table. It falls in the 5th column, so we will be using that column of the table for the remainder of the exercise. At this point we can already make some useful notes about the address. First, we see that it falls within the class B range. This means that the first two octets will be unchanged (and as such, I do not write them down on the piece of paper), and the 3rd octet is the interesting octet, because the prefix (21) falls on the middle row in the bottom half of the table. We also know, by looking at the top row, that the value in the interesting octet of the subnet mask will be 248 (hence, a mask of 255.255.248.0). Finally, we know that the block size we're working with is 8. More on this in the next step. At this point, I usually write the block size above the interesting octet, so I can keep track of where I am at:
```        8
163.45.18.29/21
```
3. Now, we figure the network and broadcast addresses. To do this, we go back to the block size. The block size determines where network addresses start, and is an incrementing value in the interesting octet. Our goal is to find the network number that supports the provided IP address. To do this, we count incrementally in the interesting octet until we reach the host address number (without passing it). in this case, we count as follows:
163.45.0.0
163.45.8.0
163.45.16.0
At this point, if we increment again, we will pass the value in the third octet, so we stop, and we are left with the network number: 163.45.16.0. Write this down:
```        8
163.45.18.29/21
```
4. Now, we need to find the broadcast address. This is probably the most difficult part to explain, but after some practice, it will become very intuitive. First, we increment the interesting octet one more time (passing the host address value for that octet) and subtract 1. The next number in that octet (incrementing by the block size) is 24, minus 1 is 23. If this were a class C address (and we were working in the 4th octet), we would be finished. For class A and B addresses, we need to fix octets to the right of the interesting octet. To do this, we throw a 255 in each remaining octet to the right of the interesting octet. In this case, we place 255 in the 4th octet, and we have our broadcast address, again, written down to keep track of where we're at:
```        8
163.45.18.29/21

```
First valid IP = 163.45.16.[0 + 1] = 163.45.16.1
Last valid IP address = 163.45.23.[255 - 1] = 163.45.23.254.
Again, write these down to keep track of where you're at:
```        8
163.45.18.29/21
16.1 - 23.254    valid host addresses
```

And there you have it. You've subnetted an IP address to find the network address, the broadcast address, and the valid host IP range.

## Another Exercise

Let's do another exercise. This time, we will use an address that falls in the Class A range, and we'll assume that we were given an address and mask (instead of a prefix). The address we want to find subnet information for is 89.65.129.68 with a 255.240.0.0 subnet mask.

1. Write it down:
```89.65.129.68/12
```
How did we know to write the prefix of /12? Simple: Remember one of the prerequisites is that you have to have a solid understanding of IP address classes. We know that an address with 89 in the first octet falls in the Class A range. We also know that the last number in the subnet mask before the first 0 octet is 240. We look up the 240 in the top row of the table, follow down that column to the prefixes in the bottom half, and look at the number in the class A row: 12. This is the prefix for the subnet.
2. Next, get the block size. The block size appears in the lower row of the top half of the table, and it is 16. Remember, this means we have blocks of 16 addresses with two reserved for network and broadcast, leaving 14 for valid host addresses. We also need to find the interesting octet. In this case, it's octet 2, as the second octet is the interesting octet for class A addresses. Write this down:
```   16
89.65.129.68/12
```
3. Now, we find the network and broadcast addresses. Increment in the interesting octet by the block size:
89.0.0.0
89.16.0.0
89.32.0.0
89.48.0.0
89.64.0.0
The next number in the interesting octet, 80 exceeds the host address number, so we stop at 64 for the network number. Write it down:
```   16
89.65.129.68/12
```
4. To find the broadcast address, count up one more in the interesting octet (89.80.0.0), place 255s in all octets to the right of the interesting octet (89.80.255.255) and subtract 1 from the interesting octet to get the broadcast address (89.79.255.255). Write it down:
```   16
89.65.129.68/12

```   16