The details of the algorithm used to answer subnetting questions about the number of hosts and subnets are summarized in the following list:
- Identify the structure of the IP address.
- Identify the size of the network part of the address based on Class A, B and C rules.
- 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.
- The size of the subnet part is what’s “left over”; mathematically, it is 32 – (number of network + host bits).
- Declare the number of subnets, which is 2number-of-subnet-bits – 2.
- Declare the number of hosts per subnet, which is 2number-of-host-bits – 2.
To find the subnet number, follow the next steps:
- You start with the decimal address and mask stated in the question.
- You convert the two numbers to binary, as shown in all five examples.
- Each bit is ANDed with the bit in the same position in the other number (in other words, a bitwise Boolean AND), giving the result of the Boolean AND.
- You convert the Boolean AND result back to decimal.
For example, with 18.104.22.168, mask 255.255.252.0, the first 6 bits of the third octet comprise the subnet field, and the last 2 bits of the third octet, plus the entire fourth octet, comprise the host field. The problem that some people experience is that they try to convert the 6-bit subnet part from binary to decimal and the 10-bit host part to decimal. However, when converting binary to decimal, to find the dotted decimal IP address you always convert the entire octet-even if part of the octet is in the subnet part of the address and part is in the host part of the address. So, in this example, the subnet number (22.214.171.124) in binary is 1000 0010 0000 0100 0110 0100 0000 0000. The entire third octet is shown in bold, which converts to 100 in decimal. When you convert the whole number, each set of 8 bits is converted to decimal, giving you 126.96.36.199.
Subnet Broadcast Address
The subnet broadcast address, sometimes called the directed broadcast address, can be used to send a packet to every device in a single subnet. However, few tools and protocols use the subnet broadcast address anymore. However, by calculating the subnet broadcast address, you can easily calculate the largest valid IP address in the subnet, which is an important part of answering subnetting questions. There is a binary math operation to calculate the subnet broadcast address, but there is a much easier process, especially if you already have the subnet number in binary:
- Change all the host bit values in the subnet number to binary 1s.
For exapmle, if you have an address 192.168.10.7 with mask 255.255.255.0, the host bits are the last 8 bits, so if we replace them with 1s, we will have finaly 192.168.10.255, which is exactly the broadcast address.
Some questions in the exam 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 200 subnets, with at most 200 hosts per subnet. Which of the following subnet masks can you use?”
This is followed by some subnet masks from which you choose the answer. To 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 in 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. As soon as 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 sample question reads like this:
“Your network can use Class B network 188.8.131.52. 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 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. 7 subnet bits is 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 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 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 have already allocated all 32 bits of the address structure. Therefore, 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
11111111 11111111 11111111 00000000
When converted to decimal, this is 255.255.255.0.
Our Recommended Premium CCNA Training Resources
These are the best CCNA training resources online:
Click Here to get the Cisco CCNA Gold Bootcamp, the most comprehensive and highest rated CCNA course online with a 4.8 star rating from over 30,000 public reviews. I recommend this as your primary study source to learn all the topics on the exam.
And click here for a free trial of AlphaPrep premium practice tests when youre ready to test your knowledge. They have the largest question bank, with adaptive tests and advanced reporting which tells you exactly when you are ready to pass the real exam.