How Many Hosts and How Many Subnets

You also should know how to figure out how many network, subnet, and host bits are used with that subnetting scheme. From those facts, you easily can figure out how many hosts exist in the subnet and how many subnets you can create in that network using that subnet mask.

You already have learned that Class A, B, and C networks have either 8, 16, or 24 bits in their network fields, respectively. Those rules do not change. You also already have read that, without subnetting, Class A, B, and C addresses have 24, 16, or 8 bits in their host fields, respectively. With subnetting, the network part of the address does not shrink or change, but the host field shrinks to make room for the subnet field. So, the key to answering these types of questions is to figure out how many host bits remain after applying subnetting, which then can tell you the size of the subnet field. The rest of the answers follow from those two facts.

The following facts tell you how to find the sizes of the network, subnet, and host parts of an IP address:

■ The network part of the address always is defined by class rules.

■ The host part of the address always is defined by the mask; binary 0s in the mask mean that the corresponding address bits are part of the host field.

■ The subnet part of the address is what's left over in the 32-bit address.

Table 12-6 lists these three key facts along with the first example. If you have forgotten the ranges of values in the first octet for addresses in Class A, B, and C networks, refer to Table 12-2 earlier in the chapter.

Table 12-6 First Example, with Rules for Learning Network, Subnet, and Host Part Sizes



Rules to Remember



Number of network bits


Always defined by Class A, B, C

Number of host bits


Always defined as number of binary 0s in mask

Number of subnet bits


32 - (network size + host size)

In this example, there are 8 network bits because the address is in a Class A network, There are 16 host bits because, when you convert to binary, there are 16 binary 0s—the last 16 bits in the mask. (If you do not believe me, look at Appendix B, in the binary-to-decimal conversion chart. 255 decimal is eight binary 1s, and 0 decimal is eight binary 0s.) The size of the subnet part of the address is what's left over, or 8 bits.

Two other examples with easy-to-convert masks might help your understanding. Consider address, with mask First, is in a Class B network, so there are 16 network bits. A subnet mask of has only eight binary 0s, implying 8 host bits, which leaves 8 subnet bits in this case.

For another example, consider, with mask In fact, this example does not even use subnetting. is in a Class C network, which means that there are 24 network bits. The mask has eight binary 0s, yielding 8 host bits, with no bits remaining for the subnet part of the address. In fact, if you remembered that the default mask for Class C networks is, you might have realized already that no subnetting was being used in this example.

Most of us can calculate the number of host bits easily if the mask uses only decimal 255s and 0s because it is easy to remember that decimal 255 represents 8 binary 1s, and decimal 0 represents 8 binary 0s. So, for every decimal 0 in the mask, there are 8 host bits. However, when the mask uses other decimal values besides 0 and 255, deciphering the number of host bits is more difficult. Examining the subnet masks in binary helps overcome the challenge. Consider the following addresses and masks, along with the binary version of the masks, as shown in Table 12-7.

Table 12-7 Two Examples Using More Challenging Masks

Mask in Decimal

Mask in Binary, mask

1111 1111 1111 1111 1111 1100 0000 0000, mask

1111 1111 1111 1111 1111 1111 1110 0000

The number of host bits implied by a mask becomes more apparent after converting the mask to binary. In the first mask,, there are ten binary 0s, implying a 10-bit host field. Because that mask is used with a Class B address (, implying 16 network bits, there are 6 remaining subnet bits. In the second example, the mask has only five binary 0s, for 5 host bits. Because the mask is used with a Class C address, there are 24 network bits, leaving only 3 subnet bits. The process so far is straightforward:

■ The class rules define the network part.

■ The mask binary 0s define the host part.

■ What's left over defines the size of the subnet part.

The only big problem occurs when the mask is tricky, which is true in the last two examples. When the mask is tricky, you have two alternatives for deciding how many host bits are defined:

■ Convert the mask to binary, using any method for conversion at your disposal, and count the number of zeros.

■ Convert the mask to binary after memorizing the nine decimal and binary values in Table 12-8. These are the only nine valid decimal values used in a subnet mask. Converting a mask to binary without having to convert from decimal to binary will be much faster.

Table 12-8 lists the only valid decimal values in a mask and their binary equivalents. Memorizing these values will help you convert masks from between their decimal and binary forms more quickly on the exam.

Table 12-8 Decimal and Binary Values in a Single Octet of a Valid Subnet Mask




0000 0000


1000 0000


1100 0000


1110 0000


1111 0000


1111 1000


1111 1100


1111 1110


1111 1111

Without the use of a calculator, PC, or decimal-to-binary conversion chart, binary conversion of a subnet mask becomes easy after memorizing this chart. The binary equivalents of 255 and decimal 0 are obvious. The other seven values are not. But notice the values in succession: Each value has an additional binary 1 and one less binary 0. Each mask value, in succession, shows a mask value that reduces the number of host bits by 1 and adds 1 to the size of the subnet field. If you simply memorize each decimal value and its binary equivalent, converting masks from decimal to binary will be a breeze. In fact, you could sit down to take the exam, and before starting, go ahead and write down the information in the table so you could easily refer to it during the exam.

So far, the book has not told you how to answer a question like this:

Given an address and mask, how many subnets are there? And how many hosts are there in a single subnet?

Well, two simple formulas provide the answers, and the formulas are based on the information that you just learned how to derive:

Number of subnets = 2number-of-subnet-bits - 2 Number of hosts per subnet = 2number-of-host-bits - 2

The formulas calculate the number of things that can be numbered using a binary number and then subtract 2 for two special cases. IP addressing conventions define that two subnets per network should not be used and that two hosts per subnet should not be used.

One reserved subnet, the subnet that has all binary 0s in the subnet field, is called the zero subnet. The subnet with all binary 1s in the subnet field is called the broadcast subnet—and it also is reserved. (Well, in fact, you can use both these subnets on a Cisco router, but it is recommended that you avoid using them. On the exam, the "right" answer is that you do not use them—hence the "minus 2" part of the 2number-of-subnet-bits - 2 formula.) In fact, the courses upon which CCNA is based now use the term discouraged instead of reserved, meaning that although those two subnets can be used, you should avoid it.

IP addressing conventions also reserve two IP addresses per subnet: the first (all binary 0s in the host field) and last (all binary 1s in the host field) addresses. No tricks exist to make these two addresses usable—they are indeed always reserved.

Table 12-9 summarizes the five examples used so far in this chapter.

Table 12-9 Five Example Addresses/Masks, with Number of Network, Subnet, and Host Bits



Number of network bits






Number of host bits






Number of subnet bits






Number of hosts per subnet

216 - 2, or 65,534

28 - 2, or 254

28 - 2, or 254

210 - 2, or 1022

25 - 2, or 30

Number of subnets

28 - 2, or 254

28 - 2, or 254


26 - 2, or 62

23 - 2, or 6

The details of the algorithm used to answer subnetting questions about the number of hosts and subnets are summarized in the following list:

Step 1 Identify the structure of the IP address.

Step 2 Identify the size of the network part of the address, based on Class A, B, and C rules.

Step 3 Identify the size of the host part of the address, based on the number of binary 0s in the mask. If the mask is tricky, use the chart of typical mask values to convert the mask to binary more quickly.

Step 4 The size of the subnet part is what's "left over"; mathematically, it is 32 - (number of network + host bits).

Step 5 Declare the number of subnets, which is 2number-of-subnet-bits - 2.

Step 6 Declare the number of hosts per subnet, which is 2number-of-host-bits - 2.

Was this article helpful?

0 0


  • Eric
    How many subnets and how many hosts?
    2 months ago

Post a comment