# Subnetting Shortcuts – Part 2

In Subnetting Shortcuts- Part One, we reviewed the classful addressing scheme, and the purpose of a subnet mask.  Now let’s look at an example.

Let’s say that you’ve been given an address space of 192.168.1.0/24, and you’re asked to subnet the network such that you can have four subnets, each supporting at least 50 hosts.  In the IP world, anything that requires an IP address is commonly referred to as a “host”, since it can host (provide the hardware on which to execute) computer programs. We’ll assume that each host requires one IP address, which is by far the most common case. We want to know if it is possible to solve the problem, and if so …

• What subnet mask is required?
• What subnets result from using the required mask?
• What are the ranges of legal host addresses on the subnets?

The first thing I do in a problem like this is a “sanity check”.  Multiply the number of hosts per subnet (50) by the number of subnets (4) to obtain the total number of host addresses required (200), then verify that the available address space will support at least that many addresses.  If the total number of host addresses required exceeds the available address space, the problem cannot be solved using standard subnet masking.  Since 200 is less than 254 (the number of host addresses available on a class “C” network), we can proceed to attempt to solve the problem.

The key to solving this type of problem is the following “powers of two” chart:

 n = 8 7 6 5 4 3 2 1 2n = 256 128 64 32 16 8 4 2

Per the chart, 2 to the third power (that is, 2 x 2 x 2) is 8.  In other words, with three bits available, there are eight possible combinations of 0’s and 1’s (000, 001, 010, 010, 011, 100, 101, 110, and 111).  Likewise, 2 to the fifth power is 32 (00000, 00001 … 11111).  As you can see from the chart, each additional bit doubles the number of possible combinations.

How do we use the “powers” chart to solve the problem?

First, determine the number of host bits required to support the specified number of hosts per subnet.  In the example above, since there are 50 hosts per subnet, the number of host bits is 6 (this actually allows for 62 hosts per subnet, since two addresses per subnet are reserved).

Next, determine the number of subnet bits required. In the example above, since there are four subnets, the number of subnet bits is two.  Note that in the case of subnets, you do not have to subtract two from the total (unlike with addresses, no subnets are reserved).

Since in our example we need two subnet bits and six host bits in the last octet (with a class C network, you only have the fourth octet to work with), the subnet mask in that octet is 1100000, which in decimal is 192.  Therefore, the mask is 255.255.255.192, or “/26” (since there are twenty-six 1’s in the mask).  If we set the host bits to zero and cycle through the four possible patterns of subnet bits, we obtain the four subnets:

• 00 000000 = 0 (192.168.1.0/26)
• 01 000000 = 64 (192.168.1.64/26)
• 10 000000 = 128 (192.168.1.128/26)
• 11 000000 = 192 (192.168.1.192/26)

Remember that all 1’s in the host portion is reserved for the directed broadcast address for a subnet. Cycling through the possibilities with the host bits set to all 1’s gives:

• 00 111111 = 63 (192.168.1.63, directed broadcast for 192.168.1.0/26)
• 01 111111 = 127 (192.168.1.127, directed broadcast for 192.168.1.64/26)
• 10 111111 = 191 (192.168.1.191, directed broadcast for 192.168.1.128/26)
• 11 111111 = 255 (192.168.1.255, directed broadcast for 192.168.1.192/26)

Finally, the range of legal host addresses is all values in between the subnet and directed broadcast addresses:

• 00 000001 – 00 111110 (192.168.1.1 – 192.168.1.62)
• 01 000001 – 01 111110 (192.168.1.65 – 192.168.1.126)
• 10 000001 – 10 111110 (192.168.1.129 – 192.168.1.190)
• 11 000001 – 11 111110 (192.168.1.193 – 192.168.1.254)

Note that each of the four subnets allows 62 legal host addresses, which is exactly what we would expect when using six host bits. Why? Because two to the sixth is 64, and two addresses per subnet (those with all 0’s and all 1’s in the host portion) are reserved. That leaves 62 legal host addresses per subnet.

Whew! That was doing it the long way. Next time, we’ll examine some shortcuts that can make solving problems like this easier and quicker.

Author: Al Friebe