Can you identify how many hosts can fit on a subnet given the CIDR notation?
For example, can you answer this question that essentially asks “how many hosts?”
Bart is designing a network segment that only needs 24 IP addresses assigned. He needs to conserve the IP address space. What CIDR notation is the BEST choice for this network?
A. /25
B. /26
C. /27
D. /28
Answer below.
Network+ practice test questions, flashcards, and mini-tutorials now available.
Looking at a Classful Range
Consider a classful IP range of 192.168.1.0/24. It supports 254 usable IP addresses in the range of 192.168.1.1 through 192.168.1.254.
Note that two IP addresses cannot be assigned to any host:
- 192.168.1.0 is the network ID.
- 192.168.1.255 is the broadcast address for the network.
Using the Formula to Determine How Many Hosts
The formula for determining the number of hosts a network supports is 2n-2, where n is the number of bits used for the host.
- 2n-2 is sometimes expressed as (2^n) – 2. Both indicate 2 raised to the power of n.
- You subtract two to reserve one IP for the network ID and one for the broadcast address.
Consider the classful IP range of 192.168.1.0/24. The /24 is Classless Inter-Domain Routing (CIDR) notation indicating that 24 bits are used for the subnet mask. An IPv4 address includes a total of 32 bits. With 24 bits used for the subnet mask, that leaves 8 bits for the hosts (32-24).
If you plug 8 into the formula, it is (2^8) – 2. 2^8 is 256 and 256 – 2 is 254.
Using a Calculator
Most calculators include a power formula, often listed as xy. The following graphic shows the Windows 10 built-in calculator in Scientific mode.
To calculate (2^8) – 2, press the keys in the following sequence.
- 2
- xy
- 8
- –
- 2
Calculating Hosts in Subnets
The preceding sections focused on a classful range of IP addresses. However, you can use the same formula to determine how many hosts a subnet supports. For example, how many hosts can you fit on this network: 192.168.1.0/28?
Remember that the formula for determining the number of hosts a network supports is 2n-2, where n is the number of bits used for the host. The /28 is CIDR notation indicating that 28 bits are used for the subnet mask. An IPv4 address includes a total of 32 bits. With 28 bits used for the subnet mask, that leaves 4 bits for the hosts (32-28).
If you plug 4 into the formula, it is 2^4 – 2. 2^4 is 16 and 16 – 2 is 14.
- 2n-2 is sometimes expressed as 2^n – 2. Both indicate 2 raised to the power of n.
- You subtract two to reserve one IP for the network ID and one for the broadcast address.
You can use this method for any IP address with a CIDR notation of /25 or greater.
Can You Use a Calculator to Determine How Many Hosts?
You cannot take a calculator into the exam room. However, some exams provide access to a simple calculator. Some don’t.
With this in mind, you should be able to recreate the following table from memory. This ensures you can identify the value of 2n-2
CIDR | # of Bits for Hosts | Max Hosts 2n-2 |
---|---|---|
/24 | 8 | 254 |
/25 | 7 | 126 |
/26 | 6 | 62 |
/27 | 5 | 30 |
/28 | 4 | 14 |
/29 | 3 | 6 |
/30 | 2 | 2 |
How Many Hosts Answer
Bart is designing a network segment that only needs 24 IP addresses assigned. He needs to conserve the IP address space. What CIDR notation is the BEST choice for this network?
A. /25
B. /26
C. /27
D. /28
Answer: C is correct. The /27 Classless Inter-Domain Routing (CIDR) notation is the best choice. It indicates a subnet mask of 255.255.255.224, which supports 30 IP addresses and is the best choice to conserve IP address space.
The formula to determine how many hosts can operate on a network is 2n-2, where n is the number of 0 bits in the subnet mask.
A subnet mask has 32 bits. If the CIDR notation is /27 it indicates that there are 5 bits left to create subnets. Using the 2n-2 formula, or 25 – 2, or 32 – 2, you see the answer is 30. This is how many hosts you can have on the network.
A is incorrect. A /25 CIDR notation indicates 7 bits are left for hosts (32 – 25 = 7). Using the 2n-2 formula, or 27 – 2, or 128 – 2, you see the answer is 126. In other words, /25 supports 126 hosts. This is much more than the 24 needed and wastes IP addresses.
B is incorrect. A /26 CIDR notation indicates 6 bits are left for hosts (32 – 26 = 6). Using the 2n-2 formula, or 26 – 2, or 64 – 2, you see the answer is 62. In other words, /26 supports 62 hosts. This is much more than the 24 needed and wastes IP addresses.
D is incorrect. A /28 CIDR notation indicates 4 bits are left for hosts (32 – 28 = 4). Using the 2n-2 formula, or 24 – 2, or 16 – 2, you see the answer is 14. In other words, /28 supports 14 hosts, which isn’t enough to meet the need of 24 addresses in the question.
Thanks a lot. But where did you get
[ Consider a classful IP range of 192.168.1.0/24. It supports 254 usable IP addresses in the range of 192.168.1.1 through 192.168.1.254. ]
from?
Can such a question that takes that long to answer appear on the exam?
Thanks
Those two sentences aren’t a question. Instead, they are part of the explanation of how to determine how many hosts are supported in a subnet when given the subnet mask (or CIDR notation).
Very good explanation.thanks.