CompTIA Network+ (N10-009) · chapter 7 of 29
Week 4: Subnetting boot camp
In this chapter Objectives 1.7
Objective 1.7
Subnetting, step by step
CIDR: the slash number
CIDR (Classless Inter-Domain Routing) writes the mask as a slash and the count of network bits: /24 = 24 ones. It replaced fixed classes, so any prefix length is allowed. To turn a slash into a mask, fill octets with 8 ones (255) until fewer than 8 bits remain, then look up the partial octet.
Bits on: 1 2 3 4 5 6 7 8 Value: 128 192 224 240 248 252 254 255 /20 = 8+8+4 -> 255.255.240.0 /26 = 8+8+8+2 -> 255.255.255.192 /29 = 8+8+8+5 -> 255.255.255.248
Exam tip Memorize 128, 192, 224, 240, 248, 252, 254, 255. Each step adds the next bit value (128 + 64 = 192, + 32 = 224 ...).
Hosts = 2^h - 2
Host bits h = 32 minus the prefix. Usable hosts per subnet = 2^h - 2: subtract the network address (host bits all 0) and the broadcast address (host bits all 1). Number of subnets you make by borrowing s bits from a bigger block = 2^s.
Prefix Last octet h Usable hosts /24 .0 8 2^8-2 = 254 /25 .128 7 2^7-2 = 126 /26 .192 6 2^6-2 = 62 /27 .224 5 2^5-2 = 30 /28 .240 4 2^4-2 = 14 /29 .248 3 2^3-2 = 6 /30 .252 2 2^2-2 = 2
Exam tip Do not forget the -2 for hosts. Trap answers love 64 for a /26 (correct: 62). /31 is a special 2-address point-to-point link (RFC 3021).
The magic number (block size)
Find the interesting octet: the one where the mask is not 255 or 0. Block size = 256 - mask value in that octet. Subnets start at multiples of the block size in that octet: 0, block, 2 x block ... The broadcast is one less than the next subnet. First usable = network + 1; last usable = broadcast - 1.
Mask 255.255.255.224 (/27)
interesting octet = 4th, value 224
block size = 256 - 224 = 32
subnets: .0 .32 .64 .96
.128 .160 .192 .224Exam tip Block size and host count are related: block 32 = 32 addresses = 30 usable hosts.
Worked example 1: 192.168.10.77/26
Find the network, broadcast, usable range and host count for 192.168.10.77/26. Follow the same four steps every time.
1. /26 = 255.255.255.192 (4th octet)
2. Block: 256 - 192 = 64
3. Multiples: 0, 64, 128, 192
77 is in 64-127 -> subnet .64
4. Network 192.168.10.64
First host 192.168.10.65
Last host 192.168.10.126
Broadcast 192.168.10.127
(next subnet .128 - 1)
Hosts 2^6 - 2 = 62Exam tip Sanity check: network is always even and a multiple of the block; broadcast is always odd.
Worked example 2: 172.16.37.5/20
When the prefix is between /17 and /23 the interesting octet is the third. The steps do not change; the fourth octet just runs 0 to 255 inside each block.
1. /20 = 255.255.240.0 (3rd octet)
2. Block: 256 - 240 = 16 (3rd octet)
3. Multiples: 0, 16, 32, 48 ...
37 is in 32-47 -> 172.16.32.0
4. Network 172.16.32.0
First host 172.16.32.1
Last host 172.16.47.254
Broadcast 172.16.47.255
Hosts 2^12 - 2 = 4094
(32 - 20 = 12 host bits)Exam tip Trap: 172.16.40.0 looks like a network ID, but in a /20 it is an ordinary host inside 172.16.32.0/20.
Sizing: pick the prefix from the need
For N hosts, find the smallest h where 2^h - 2 is at least N; prefix = 32 - h. For N subnets, find the smallest s where 2^s is at least N and add s to the starting prefix.
50 hosts: 2^6-2 = 62 >= 50 -> h=6 -> /26 200 hosts: 2^8-2 = 254 >= 200 -> h=8 -> /24 500 hosts: 2^9-2 = 510 >= 500 -> h=9 -> /23 30 subnets from 10.20.0.0/16: 2^5 = 32 >= 30 -> borrow 5 -> /21 each /21 has 2^11-2 = 2046 hosts
Exam tip Always round UP to the next power of two. 2^5-2 = 30 hosts fits exactly 30, but 31 hosts needs a /26.
CIDR summarization
CIDR also works the other way: combining contiguous networks into one shorter prefix (a supernet or summary route) so routers carry fewer routes. Four /24s that start on a multiple of 4 in the third octet summarize to one /22.
192.168.0.0/24 ] 192.168.1.0/24 ] -> 192.168.0.0/22 192.168.2.0/24 ] 255.255.252.0 192.168.3.0/24 ] (block 4)
Exam tip Summaries must line up on the block boundary: 192.168.1.0 - 4.0 cannot become one /22.
Objective 1.7
VLSM: right-sizing every subnet
What VLSM means
VLSM (variable length subnet masking) lets you use different prefix lengths inside one address block, so each subnet is only as big as it needs to be. Without VLSM every subnet is the same size, wasting addresses (a /24 for a 2-host router link wastes 252 addresses). Rule: allocate the largest subnet first, then the next largest, each starting on its own block boundary.
Exam tip VLSM needs classless routing protocols that send the mask with each route (OSPF, EIGRP, BGP, RIPv2).
Worked VLSM: the warehouse 10.20.0.0/24
Needs: floor scanners 100 hosts, office 50, cameras 20, printers 10, router link 2. Sort largest first, pick each prefix with 2^h - 2, then place each subnet at the next free boundary.
Need Pfx Hosts Subnet Usable 100 /25 126 10.20.0.0/25 .1-.126 50 /26 62 10.20.0.128/26 .129-.190 20 /27 30 10.20.0.192/27 .193-.222 10 /28 14 10.20.0.224/28 .225-.238 2 /30 2 10.20.0.240/30 .241-.242 Broadcasts: .127 .191 .223 .239 .243 Free later: 10.20.0.244 - .255
Exam tip Placing a small subnet first (say /30 at .0) can block a later /25 from fitting on its boundary. Largest first avoids that.
Check yourself 1A technician must create a subnet for 28 security cameras with the fewest wasted addresses. Which prefix should be used?
- /26
- /28
- /25
- /27
Show the answer
Answer: D. /27
A /27 has 5 host bits: 2^5 - 2 = 30 usable, enough for 28. A /28 gives only 14, and a /26 (62) wastes more addresses.
Check yourself 2What is the broadcast address of the subnet containing 10.1.1.200/29?
- 10.1.1.207
- 10.1.1.199
- 10.1.1.255
- 10.1.1.208
Show the answer
Answer: A. 10.1.1.207
/29 = 255.255.255.248, block size 8. 200 is a multiple of 8, so the network is .200 and the next subnet is .208. Broadcast = 208 - 1 = .207.
Practice questions
Answer in your head, then open the answer. Ranger's Packet Trail has 483 questions like these for Network+, with mock exams.
Question 1A user reports no network access. The technician runs the command in the exhibit. What is the MOST likely cause?
- The PC could not reach a DHCP server
- The PC has a duplicate static IP address
- The default gateway is misconfigured
- The DNS server is not responding
Show the answer
Answer: A. The PC could not reach a DHCP server
A 169.254.x.x address is APIPA, which Windows assigns itself when it can't get a lease from a DHCP server. A DNS failure wouldn't change the PC's own IP address.
Question 2An engineer is choosing an internal address range for a new site and must use RFC1918 space. Which of the following addresses falls within RFC1918?
- 100.64.5.4
- 172.32.5.4
- 172.20.5.4
- 192.169.5.4
Show the answer
Answer: C. 172.20.5.4
RFC1918 private ranges are 10.0.0.0/8, 172.16.0.0/12 (172.16-172.31) and 192.168.0.0/16. 172.20.5.4 is inside 172.16.0.0/12, but 172.32.5.4 is just outside it.
Question 3A technician wants to confirm that the TCP/IP stack on a PC is working, without the traffic ever leaving the network card. Which address should they ping?
- 192.168.0.1
- 169.254.0.1
- 255.255.255.255
- 127.0.0.1
Show the answer
Answer: D. 127.0.0.1
127.0.0.1 is the loopback (localhost) address, which tests the local stack only. 169.254.0.1 is an APIPA address on the local link.
Question 4A network team assigns the subnet 10.40.8.0/26 to a new VLAN. How many usable host addresses does this subnet provide?
- 64
- 62
- 30
- 126
Show the answer
Answer: B. 62
A /26 leaves 6 host bits: 2^6 = 64 addresses, minus the network and broadcast addresses = 62 usable. 64 forgets to subtract those two.
Question 5A router configuration requires a dotted-decimal subnet mask, but the design document lists the subnet as a /27. Which mask should be entered?
- 255.255.255.192
- 255.255.255.248
- 255.255.255.224
- 255.255.255.240
Show the answer
Answer: C. 255.255.255.224
A /27 has 27 network bits, which leaves 224 in the last octet (128+64+32). 255.255.255.240 is a /28.
CompTIA, A+, Network+, Security+ and Linux+ are trademarks of CompTIA, Inc. Ranger Gamez is not affiliated with or endorsed by CompTIA. The practice questions are written to the published exam objectives; they are not real exam questions.