## What Subnet Masks Meet the Stated Design Requirements

So far in this chapter, the text has explained how to answer questions that provide the subnet number. However, some questions do not supply the subnet number, but instead ask you to choose the "correct" subnet mask, given a set of requirements. The most common of these questions reads something like this:

You are using Class B network X, and you need to have 200 subnets, with at most 200 hosts per subnet. Which of the following subnet masks can be used? (followed by some subnet masks that you can pick from for the answer)

The find the correct answers to these types of questions, you first need to decide how many subnet bits and host bits you need to meet the requirements. Basically, the number of hosts per subnet is 2x - 2, where x is the number of host bits in the address. Likewise, the number of subnets of a network, assuming that the same subnet mask is used all over the network, is also 2x - 2, but with x being the number of subnet bits. When you know how many subnet bits and host bits are required, you can figure out what mask, or masks, meet the stated design goals in the question.

Examples certainly help; the first example question reads like this:

Your network can use Class B network 130.1.0.0. What subnet masks meet the requirement that you plan to allow at most 200 subnets, with at most 200 hosts per subnet?

First, you need to figure out how many subnet bits allow for 200 subnets. You simply can use the formula 2x - 2 and plug in values for x, until one of the numbers is at least 200. In this case, x turns out to be 8—in other words, you need at least 8 subnet bits to allow for 200 subnets.

If you do not want to keep plugging in values into the 2x - 2 formula, you can instead memorize Table 12-30.

 Number of Bits in the Host or Subnet Field Maximum Number of Hosts or Subnets (2x - 2) 1 0 2 2 3 6 4 14 5 30 6 62 7 126 8 254 9 510 10 1022 11 2046 12 4094 13 8190 14 16,382

As you can see, if you already have the powers of 2 memorized, you really do not need to memorize the table—just remember the formula.

As for the first example question, 7 subnet bits are not enough because that allows for only 126 subnets. You need 8 subnet bits. Similarly, because you need up to 200 hosts per subnet, you need 8 host bits.

Finally, you need to decide somehow what mask(s) to use, knowing that you have a Class B network and that you must have at least 8 subnet bits and 8 host bits. Using the letter N to represent network bits, the letter S to represent subnet bits, and the letter H to represent host bits, the following text shows the sizes of the various fields:

### NNNNNNNN NNNNNNNN SSSSSSSS HHHHHHHH

All that is left is to derive the actual subnet mask. Because you need 8 bits for the subnet field and 8 for the host field, and the network field takes up 16 bits, you already have allocated all 32 bits of the address structure. So, only one possible subnet mask works. To figure out the mask, you need to write down the 32-bit subnet mask, applying the following fact and subnet masks:

The network and subnet bits in a subnet mask are, by definition, all binary 1s. Similarly, the host bits in a subnet mask are, by definition, all binary 0s.

So, the only valid subnet mask, in binary, is this:

11111111 11111111 11111111 00000000 When converted to decimal, this is 255.255.255.0.

A second example shows how the requirements stated in the question might allow for multiple possible subnet masks. For instance:

Your network can use Class B network 130.1.0.0. What subnet masks meet the requirement that you plan to allow at most 50 subnets, with at most 200 hosts per subnet?

For this design, you still need at least 8 host bits, but now you need only at least 6 subnet bits. Six subnet bits would allow for 26 - 2, or 62, subnets. Following the same convention as before, but now using an x for bits that can be either subnet or host bits, the format of the address struture would be as follows:

### NNNNNNNN NNNNNNNN SSSSSSXX HHHHHHHH

In other words, the addresses will have 16 network bits, at least 6 subnet bits, and at least 8 host bits. This example actually allows for three valid subnet masks, whose strcuture are as follows:

NNNNNNNN NNNNNNNN SSSSSSSS HHHHHHHH—8 subnet, 8 host NNNNNNNN NNNNNNNN SSSSSSSH HHHHHHHH—7 subnet, 9 host NNNNNNNN NNNNNNNN SSSSSSHH HHHHHHHH—6 subnet, 10 host

So, based on the requirements in the question, three different valid subnet masks meet the requirements. The three values are as follows:

11111111 11111111 11111111 00000000 255.255.255.0 11111111 11111111 11111110 00000000 255.255.254.0 11111111 11111111 11111100 00000000 255.255.252.0

The 2 bits that could be subnet bits or host bits, based on the requirements, are shown in bold.