IPv4 Subnetting
Exam topics covered
1.6 Configure and verify IPv4 addressing and subnetting
Supporting skill for 3.0 IP Connectivity and 5.6 ACLs: wildcard masks Foundation. Subnetting is the single most practised skill on the CCNA. You will not find a question titled “subnetting” so much as subnetting hidden inside other questions: which host is in the wrong subnet, which static route covers a destination, which ACL wildcard matches a range, why an OSPF neighbor will not come up. This chapter teaches one fast, reliable method, the block size (or “magic number”) method, and drills it across every octet from /8 to /32. Work through each example with pencil and paper; speed comes from repetition, and the exam gives you roughly a minute per question.
7.1 Why Subnet?
Consider an organisation that owns the private network 172.16.0.0/16, with 65,534 usable addresses. Putting every device into that one giant subnet would technically work, but it would be a poor design for several reasons:
Broadcast containment. Every ARP request, DHCP Discover and other broadcast reaches every host in a subnet. A subnet with thousands of hosts drowns them in broadcasts. Each subnet (usually one per VLAN) is its own broadcast domain. Security and policy. Routers and firewalls apply ACLs and policy between subnets. Putting servers, users, voice phones and guests in separate subnets lets you control which can talk to which.
Routing and troubleshooting. Each site or link gets its own subnet, so routing tables describe the physical layout and a problem can be localised by address alone. Address efficiency. Right-sized subnets avoid wasting addresses on a two-router WAN link or a ten-person branch (Chapter 8 takes this further with VLSM).
Users 172.16.0.0/20 Voice 172.16.16.0/20 Servers 172.16.32.0/20 ACLs between
Figure 7-1 One /16 carved into /20 subnets, one per function. Each subnet is a separate broadcast domain, and R1 can filter traffic between them.
7.2 Borrowing Host Bits
Subnetting extends the network portion of an address by borrowing bits from the host portion. Starting from a /16, borrowing 4 bits produces a /20: the first 16 bits still identify the original network, the next 4 bits (the subnet bits) identify one of the new subnets, and the remaining 12 bits are host bits.
- Network bits (16): 172.16 Subnet (4) Host bits (12)
- bit 1 17 21 32
- Original /16 boundary → ← new /20 boundary
2^4 = 16 subnets, each with 2^12 − 2 = 4094 usable host addresses
Figure 7-2 Borrowing 4 host bits from 172.16.0.0/16 creates sixteen /20 subnets.
Two formulas follow directly. If you borrow s subnet bits and leave h host bits: Number of subnets = 2
s
. (Older material subtracted 2 for the “subnet zero” and all-ones subnet; IOS has allowed both by default since 12.0 via ip subnet-zero , and the CCNA uses
- s
- .)
- Usable hosts per subnet = 2
- h − 2, subtracting the network ID and the broadcast
address.
Every bit you move to the subnet side doubles the number of subnets and roughly halves the hosts in each. Table 7-1 shows the trade-off for a /24.
Table 7-1 Subnetting a /24: bits borrowed versus subnets and hosts Bits borrowed
7.3 The Prefix Reference Table
Table 7-2 is the one table to know cold. For each prefix it gives the dotted mask, the
interesting octet (the octet where the mask is neither 255 nor 0, or where the boundary falls), the block size in that octet, the number of usable hosts and the wildcard mask (Section 7.9.3). Notice the pattern: the same eight mask values (128, 192, 224, 240, 248, 252, 254,
- 255) repeat in each octet, and the block size is always 256 minus the mask value.
Table 7-2 Prefix reference: /8 to /32
- Prefix Subnet mask
- Interesting
- octet
- Block
- size
- Usable hosts Wildcard mask
- /8 255.0.0.0 first 1 16,777,214 0.255.255.255
- /9 255.128.0.0 second 128 8,388,606 0.127.255.255
- /10 255.192.0.0 second 64 4,194,302 0.63.255.255
- /11 255.224.0.0 second 32 2,097,150 0.31.255.255
- /12 255.240.0.0 second 16 1,048,574 0.15.255.255
- /13 255.248.0.0 second 8 524,286 0.7.255.255
- /14 255.252.0.0 second 4 262,142 0.3.255.255
- /15 255.254.0.0 second 2 131,070 0.1.255.255
- /16 255.255.0.0 second 1 65,534 0.0.255.255
- /17 255.255.128.0 third 128 32,766 0.0.127.255
- /18 255.255.192.0 third 64 16,382 0.0.63.255
- /19 255.255.224.0 third 32 8,190 0.0.31.255
- /20 255.255.240.0 third 16 4,094 0.0.15.255
- /21 255.255.248.0 third 8 2,046 0.0.7.255
- Prefix Subnet mask
- Interesting
- octet
- Block
- size
- Usable hosts Wildcard mask
- /22 255.255.252.0 third 4 1,022 0.0.3.255
- /23 255.255.254.0 third 2 510 0.0.1.255
- /24 255.255.255.0 third 1 254 0.0.0.255
- /25 255.255.255.128 fourth 128 126 0.0.0.127
- /26 255.255.255.192 fourth 64 62 0.0.0.63
- /27 255.255.255.224 fourth 32 30 0.0.0.31
- /28 255.255.255.240 fourth 16 14 0.0.0.15
- /29 255.255.255.248 fourth 8 6 0.0.0.7
- /30 255.255.255.252 fourth 4 2 0.0.0.3
- /31 255.255.255.254 fourth 2 2 (point-to-point, RFC
- 3021)
- 0.0.0.1
- /32 255.255.255.255 fourth 1 1 (host route) 0.0.0.0
7.4 The Block Size Method
Subnets of the same size start at multiples of the block size. In a /26, the block size is 256 − 192 = 64, so the subnets in the fourth octet start at .0, .64, .128 and .192. To find which subnet an address belongs to, you just find the multiple of the block size that is at or below the address's value in the interesting octet. The whole method is five steps:
Find the
interesting octet
Block size =
256 − mask octet
Largest multiple of
block ≤ address octet
Network: that value,
later octets = 0
Broadcast: next net − 1
later octets = 255
Figure 7-3 The block size (magic number) method. First host = network + 1; last host = broadcast − 1.
7.4.1 A first example: 192.168.1.130/26
- 1. Interesting octet. /26 = 255.255.255.192. The fourth octet (192) is the interesting one.
- 2. Block size. 256 − 192 = 64.
- 3. Multiples. 0, 64, 128, 192. The address's fourth octet is 130, which falls between 128 and 192.
- 4. Network ID. 192.168.1.128.
- 5. Broadcast. The next subnet starts at .192, so the broadcast is one less: 192.168.1.191. The usable range is 192.168.1.129 through 192.168.1.190: 2
6 − 2 = 62 hosts. Figure 7-4
shows the same reasoning on a number line.
Figure 7-4 The fourth octet of 192.168.1.0/24 divided into /26 blocks of 64.
7.4.2 Seeing it in binary
The block size method is a shortcut for the binary AND you met in Chapter 6. It helps to see once why it works. Take 172.16.45.201/20, where the boundary falls inside the third octet. Mask 255.255.240.0 keeps the top four bits of the third octet:
Figure 7-5 45 = 0010 1101. Zeroing the low four bits leaves 0010 0000 = 32 (the network); setting them leaves 0010 1111 = 47 (the broadcast).
Now compare with the shortcut: the interesting octet is the third, block size 256 − 240 = 16, multiples of 16 are 0, 16, 32, 48…, and 45 falls between 32 and 48. Network 172.16.32.0; the next network is 172.16.48.0, so the broadcast is 172.16.47.255. Because the boundary is in the third octet, the fourth octet is 0 in the network ID and 255 in the broadcast. First host 172.16.32.1, last host 172.16.47.254, and 2
12 − 2 = 4094 hosts. Same answer, a fraction of
the work.
Watch out
When the interesting octet is the third (or second), do not forget the octets to its right. The broadcast of 172.16.32.0/20 is 172.16.47.255, and the last usable host is 172.16.47.254, not 172.16.47.254 in some other subnet or 172.16.46.255. Addresses such as 172.16.40.0 and 172.16.40.255 are perfectly valid hosts inside this /20.
7.4.3 Why “256 minus the mask” works
The block size is simply the place value of the lowest network bit in the interesting octet. In a /22, the third octet of the mask is 11111100: the last 1 sits in the 4s column, so subnets advance in steps of 4. Changing any bit to the left of it moves you to a different subnet; changing the bits to its right (and the whole fourth octet) only moves you between hosts of the same subnet.
- Third octet
- Mask /22
- 128
network (subnet) bits host bits (and all of octet 4)
lowest network bit = 4 = block size
Figure 7-6 In a /22 the lowest network bit of the third octet has place value 4, so subnets start at 0, 4, 8, 12… in that octet: 256 − 252 = 4.
7.5 Worked Examples in Every Octet
The following tables apply the five steps to ten more addresses, two per table. Cover the right-hand columns and try each one first.
Table 7-3 Worked examples: interesting fourth octet
Step Example 1 Example 2
Address/prefix 10.1.1.77/29 192.168.50.100/27
- 1. Mask; interesting octet 255.255.255.248; fourth (248) 255.255.255.224; fourth (224)
- 2. Block size 256 − 248 = 8 256 − 224 = 32
- 3. Multiples bracketing the
octet
72 ≤ 77 < 80 96 ≤ 100 < 128
- 4. Network ID 10.1.1.72 192.168.50.96
- 5. Broadcast 10.1.1.79 192.168.50.127
First – last host 10.1.1.73 – 10.1.1.78 192.168.50.97 – 192.168.50.126 Usable hosts 2
3 − 2 = 6 25 − 2 = 30
Table 7-4 Worked examples: interesting fourth octet
Step Example 3 Example 4
Address/prefix 172.16.5.201/30 192.168.99.200/25
- 1. Mask; interesting octet 255.255.255.252; fourth (252) 255.255.255.128; fourth (128)
- 2. Block size 256 − 252 = 4 256 − 128 = 128
- 3. Multiples bracketing the
octet
200 ≤ 201 < 204 128 ≤ 200 < 256
- 4. Network ID 172.16.5.200 192.168.99.128
- 5. Broadcast 172.16.5.203 192.168.99.255
First – last host 172.16.5.201 – 172.16.5.202 192.168.99.129 – 192.168.99.254 Usable hosts 2
2 − 2 = 2 27 − 2 = 126
Table 7-5 Worked examples: interesting third octet
Step Example 5 Example 6
Address/prefix 10.10.100.5/22 192.168.130.17/17
- 1. Mask; interesting octet 255.255.252.0; third (252) 255.255.128.0; third (128)
- 2. Block size 256 − 252 = 4 256 − 128 = 128
- 3. Multiples bracketing the
octet
100 ≤ 100 < 104 128 ≤ 130 < 256
- 4. Network ID 10.10.100.0 192.168.128.0
- 5. Broadcast 10.10.103.255 192.168.255.255
First – last host 10.10.100.1 – 10.10.103.254 192.168.128.1 – 192.168.255.254 Usable hosts 2
10 − 2 = 1,022 215 − 2 = 32,766
Table 7-6 Worked examples: interesting third octet
Step Example 7 Example 8
Address/prefix 172.31.200.9/19 10.0.7.255/21
- 1. Mask; interesting octet 255.255.224.0; third (224) 255.255.248.0; third (248)
- 2. Block size 256 − 224 = 32 256 − 248 = 8
- 3. Multiples bracketing the
octet
192 ≤ 200 < 224 0 ≤ 7 < 8
- 4. Network ID 172.31.192.0 10.0.0.0
- 5. Broadcast 172.31.223.255 10.0.7.255
First – last host 172.31.192.1 – 172.31.223.254 10.0.0.1 – 10.0.7.254 Usable hosts 2
13 − 2 = 8,190 211 − 2 = 2,046
Table 7-7 Worked examples: interesting second octet
Step Example 9 Example 10
Address/prefix 10.77.88.99/12 10.200.15.3/10
- 1. Mask; interesting octet 255.240.0.0; second (240) 255.192.0.0; second (192)
- 2. Block size 256 − 240 = 16 256 − 192 = 64
- 3. Multiples bracketing the
octet
64 ≤ 77 < 80 192 ≤ 200 < 256
- 4. Network ID 10.64.0.0 10.192.0.0
- 5. Broadcast 10.79.255.255 10.255.255.255
First – last host 10.64.0.1 – 10.79.255.254 10.192.0.1 – 10.255.255.254 Usable hosts 2
20 − 2 = 1,048,574 222 − 2 = 4,194,302
Exam alert
A very common question shows a host's address, mask and default gateway and asks why it cannot reach other subnets. Check that the gateway is in the same subnet as the host, and that neither address is a network ID or broadcast. For example, host 10.1.1.77/29 with gateway 10.1.1.70 is broken: the host's subnet is 10.1.1.72–79, and .70 is in a different subnet.
7.6 Listing the Subnets of a Network
Design questions turn the problem around: given a network and a new prefix, list the subnets. Start at the original network ID and keep adding the block size in the interesting octet. Splitting 192.168.1.0/24 into /27s (block size 32) gives eight subnets:
Table 7-8 The eight /27 subnets of 192.168.1.0/24
- Subnet Network ID Usable range Broadcast
- 1 192.168.1.0/27 192.168.1.1 – 192.168.1.30 192.168.1.31
- 2 192.168.1.32/27 192.168.1.33 – 192.168.1.62 192.168.1.63
- 3 192.168.1.64/27 192.168.1.65 – 192.168.1.94 192.168.1.95
- 4 192.168.1.96/27 192.168.1.97 – 192.168.1.126 192.168.1.127
5 192.168.1.128/27 192.168.1.129 – 192.168.1.158 192.168.1.159 6 192.168.1.160/27 192.168.1.161 – 192.168.1.190 192.168.1.191 7 192.168.1.192/27 192.168.1.193 – 192.168.1.222 192.168.1.223 8 192.168.1.224/27 192.168.1.225 – 192.168.1.254 192.168.1.255 .0/27
Figure 7-7 192.168.1.0/24 divided into eight /27 subnets of 32 addresses each.
The same technique works in any octet. Splitting 10.0.0.0/8 into /12s (block 16 in the second octet) gives 10.0.0.0, 10.16.0.0, 10.32.0.0 … 10.240.0.0. Splitting 172.16.0.0/16 into /22s (block 4 in the third octet) gives 64 subnets: 172.16.0.0, 172.16.4.0, 172.16.8.0 … 172.16.252.0. The last subnet always starts at 256 minus the block size in the interesting octet.
7.6.1 Finding the nth subnet
Because subnets are evenly spaced, you never need to list them all. The nth subnet starts at (n − 1) × block size in the interesting octet, counting the first subnet (subnet zero) as number 1. The 10th /22 subnet of 172.16.0.0/16 starts at 9 × 4 = 36, so it is 172.16.36.0/22 (172.16.36.0–172.16.39.255). The last subnet is always the one that starts at 256 − block size: for /22s, 172.16.252.0/22.
When the new prefix crosses an octet boundary, carry into the next octet the way you would with ordinary numbers. Table 7-9 lists the /19 subnets of a class B network; note how each broadcast is the next subnet ID minus one, which in the third octet means “one less, and 255 in the fourth.”
Table 7-9 The eight /19 subnets of 172.16.0.0/16 (block size 32 in the third octet) Subnet Subnet ID Usable range Broadcast
- 1 172.16.0.0/19 172.16.0.1 – 172.16.31.254 172.16.31.255
- 2 172.16.32.0/19 172.16.32.1 – 172.16.63.254 172.16.63.255
- 3 172.16.64.0/19 172.16.64.1 – 172.16.95.254 172.16.95.255
- 4 172.16.96.0/19 172.16.96.1 – 172.16.127.254 172.16.127.255
5 172.16.128.0/19 172.16.128.1 – 172.16.159.254 172.16.159.255 6 172.16.160.0/19 172.16.160.1 – 172.16.191.254 172.16.191.255 7 172.16.192.0/19 172.16.192.1 – 172.16.223.254 172.16.223.255 8 172.16.224.0/19 172.16.224.1 – 172.16.255.254 172.16.255.255 7.6.2 From an address range back to a prefix
Sometimes you are given a range and must find the prefix that describes it exactly, for a route, an ACL or a summary. Count the addresses (or the span in the interesting octet): the span must be a power of two and the range must start on a multiple of that span. The prefix is then 32 minus log2 of the total number of addresses.
Table 7-10 Converting address ranges to prefixes
Range Addresses
Starts on a
multiple?
- yes 10.32.0.0/11 (255.224.0.0)
- 192.168.8.0 –
- 192.168.15.255
- 2,048 = 2
- 11 yes 192.168.8.0/21 (255.255.248.0)
7.7 Validating Host Configurations
Troubleshooting questions often give you several hosts and ask which one is misconfigured. Find the subnet of the gateway (router interface) first, because that is the subnet everyone on the LAN must share. Then check each host: is its address inside that subnet, is it neither the network ID nor the broadcast, and does its mask and gateway match?
Figure 7-8 Four PCs on R1's G0/0/0 LAN, all configured with gateway 192.168.1.1. Which ones will work?
Table 7-11 Checking the hosts in Figure 7-8 (gateway subnet: 192.168.1.0/26, range 192.168.1.1–192.168.1.62) Host Address Host's subnet Broadcast Verdict
PC-A192.168.1.20/26 192.168.1.0/26 192.168.1.63 OK
PC-B192.168.1.70/26 192.168.1.64/26 192.168.1.127 Broken: in 192.168.1.64/26, gateway 192.168.1.1 is not in its subnet
PC-C192.168.1.62/26 192.168.1.0/26 192.168.1.63 OK
PC-D192.168.1.63/26 192.168.1.0/26 192.168.1.63 Broken: broadcast address of 192.168.1.0/26
PC-B shows why the mask matters: 192.168.1.70 looks “close” to the others, but with a /26 it belongs to the subnet behind G0/0/1. Its gateway 192.168.1.1 is not in its own subnet, so the PC cannot even ARP for it. PC-D's address is the broadcast address of 192.168.1.0/26; most operating systems refuse it outright.
7.8 Choosing a Mask from Requirements
When the question gives requirements instead of a mask, convert the requirement to bits: Hosts needed per subnet: find the smallest h where 2
h − 2 ≥ hosts. The prefix is 32 − h.
For 50 hosts, 2
6 − 2 = 62 is enough and 25 − 2 = 30 is not, so h = 6 and the prefix is /26.
Subnets needed: find the smallest s where 2
s ≥ subnets, and add s to the original prefix.
For 100 subnets from a /16, 2
7 = 128 is enough, so the new prefix is /23.
Both: check that the subnet bits and host bits fit in the bits available. From 192.168.1.0/24, six subnets of 25 hosts each needs s = 3 (8 subnets) and h = 5 (30 hosts); 3 + 5 = 8 bits, which is exactly what a /24 has. The answer is /27.
If a question asks for the mask that provides the most subnets while still meeting a host requirement, choose the longest prefix that leaves enough host bits. If it asks for the most hosts while meeting a subnet requirement, choose the shortest prefix that gives enough subnets.
Table 7-12 Powers of two for subnet and host calculations
1 = 2 22 = 4 23 = 8 24 = 16
5 = 32 26 = 64 27 = 128 28 = 256
9 = 512 210 = 1,024 211 = 2,048 212 = 4,096
- 13 = 8,192 214 = 16,384 215 = 32,768 216 = 65,536
- Given network: 24 bits (192.168.1) s = 3 h = 5
- 8 subnets ≥ 6 needed 30 hosts ≥ 25 needed
s + h = 8 = the bits available in a /24, so /27 satisfies both requirements
Figure 7-9 The bit budget: subnet bits and host bits must share the bits left after the given prefix.
Exam alert
Read requirement questions twice. “Maximise the number of subnets” and “maximise hosts per subnet” lead to different answers from the same numbers. When both a subnet count and a host count are given and several prefixes fit, the question will tell you which to favour; if it does not, any prefix that satisfies both is correct.
7.9 Special Cases: /31, /32 and Wildcard Masks
7.9.1 /31 for point-to-point links
A /30 is the traditional choice for a link between two routers: four addresses, two usable. That wastes half of every block. RFC 3021 allows a /31 on point-to-point links: with only two addresses there is no need for a network ID or broadcast, so both addresses are usable. 10.1.1.10/31 contains exactly 10.1.1.10 and 10.1.1.11. IOS accepts a /31 on any interface but warns you if the interface is not a point-to-point type, such as Ethernet.
R1 — console
R1(config)# interface GigabitEthernet0/0/1 R1(config-if)# ip address 10.1.1.10 255.255.255.254
% Warning: use /31 mask on non point-to-point interface cautiously
R1(config-if)# end R1# show ip route connected | include 10.1.1
C 10.1.1.10/31 is directly connected, GigabitEthernet0/0/1
L 10.1.1.10/32 is directly connected, GigabitEthernet0/0/1
R1# ping 10.1.1.11
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.11, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
Figure 7-10 A /31 on a router-to-router Ethernet link. IOS warns but accepts it, and both addresses are usable. Output is illustrative of Cisco IOS 15 and IOS XE.
7.9.2 /32 host routes
A /32 (mask 255.255.255.255) identifies exactly one address. You will see /32s on loopback interfaces used as router IDs and management addresses, in the L (local) routes IOS installs for every interface address, and in host routes that steer traffic for a single destination.
7.9.3 Wildcard masks
ACLs and OSPF network commands use a wildcard mask instead of a subnet mask. In a wildcard mask a 0 bit means “must match” and a 1 bit means “don't care”: the inverse of a subnet mask. To convert a contiguous subnet mask to its wildcard, subtract each octet from 255.
Table 7-13 Converting subnet masks to wildcard masks
- Prefix Subnet mask Calculation Wildcard mask
- /30 255.255.255.252 255.255.255.255 − 255.255.255.252 0.0.0.3
- /29 255.255.255.248 255.255.255.255 − 255.255.255.248 0.0.0.7
/27 255.255.255.224 255.255.255.255 − 255.255.255.224 0.0.0.31 /26 255.255.255.192 255.255.255.255 − 255.255.255.192 0.0.0.63 /24 255.255.255.0 255.255.255.255 − 255.255.255.0 0.0.0.255
- /22 255.255.252.0 255.255.255.255 − 255.255.252.0 0.0.3.255
- /20 255.255.240.0 255.255.255.255 − 255.255.240.0 0.0.15.255
- /16 255.255.0.0 255.255.255.255 − 255.255.0.0 0.0.255.255
So the ACL entry permit 172.16.32.0 0.0.15.255 matches 172.16.32.0 through 172.16.47.255, exactly the /20 from Figure 7-5. Two shortcuts appear constantly: 0.0.0.0 matches one host (IOS lets you write host 10.1.1.1 ), and 255.255.255.255 matches everything ( any ). Wildcard bits do not have to be contiguous, which allows tricks such as matching only odd-numbered subnets, but on the CCNA they almost always are. Chapter 30 covers ACLs in depth.
Tip
The interesting octet of a wildcard mask is always block size − 1: a /26 has block 64 and wildcard 0.0.0.63; a /22 has block 4 in the third octet and wildcard 0.0.3.255. If you know the block size, you know the wildcard.
7.10 Subnetting on Cisco IOS
IOS checks every address you configure against the mask. It rejects a network ID or broadcast address as an interface address, and it refuses a subnet that overlaps one already assigned to another interface. Both checks catch subnetting mistakes before they reach the network. In Figure 7-11, R1 is being configured with two /26 subnets carved from 192.168.1.0/24, and the engineer makes two errors on the way.
R1(config)# interface GigabitEthernet0/0/0 R1(config-if)# ip address 192.168.1.1 255.255.255.192 R1(config-if)# interface GigabitEthernet0/0/1 R1(config-if)# ip address 192.168.1.30 255.255.255.192
% 192.168.1.0 overlaps with GigabitEthernet0/0/0
R1(config-if)# ip address 192.168.1.64 255.255.255.192
Bad mask /26 for address 192.168.1.64
R1(config-if)# ip address 192.168.1.65 255.255.255.192 R1(config-if)# end R1# show ip route connected
- 192.168.1.0/24 is variably subnetted, 4 subnets, 2 masks
- C 192.168.1.0/26 is directly connected, GigabitEthernet0/0/0
- L 192.168.1.1/32 is directly connected, GigabitEthernet0/0/0
- C 192.168.1.64/26 is directly connected, GigabitEthernet0/0/1
- L 192.168.1.65/32 is directly connected, GigabitEthernet0/0/1
Figure 7-11 IOS rejects an overlapping subnet and a network-ID address, then installs a connected (C) route for each subnet and a local (L) /32 for each interface address.
The routing table is the best place to confirm your arithmetic: the C line shows the subnet IOS calculated from the address and mask you typed. If you meant 192.168.1.64/26 but see 192.168.1.0/25, you typed the wrong mask. The heading line “variably subnetted, 4 subnets, 2 masks” counts the /26 and /32 entries under the classful network 192.168.1.0/24.
LAB Subnet a /24 for three LANs
Goal: R1 (an ISR with three Gigabit ports) connects three LANs of up to 50 hosts each. Use 192.168.1.0/24, assign the first usable address of each subnet to R1, and keep one subnet spare. Steps:
- 1. Choose the prefix: 50 hosts need 6 host bits, so /26 (255.255.255.192, 62 hosts). That gives four subnets: .0, .64, .128 and .192.
- 2. Configure G0/0/0 as 192.168.1.1/26, G0/0/1 as 192.168.1.65/26 and G0/0/2 as 192.168.1.129/26, each with no shutdown . Keep 192.168.1.192/26 for growth.
- 3. Configure one PC per LAN with an address in its subnet, the matching mask and R1's address as gateway, for example 192.168.1.130/26 with gateway 192.168.1.129.
R1(config)# interface GigabitEthernet0/0/2 R1(config-if)# ip address 192.168.1.129 255.255.255.192 R1(config-if)# no shutdown
Verify: show ip route connected lists three C routes (192.168.1.0/26, 192.168.1.64/26, 192.168.1.128/26) and three L routes. Each PC can ping its gateway and the PCs in the other two LANs. As an extra test, try to configure 192.168.1.191/26 on a loopback: IOS rejects it because it is the broadcast address of 192.168.1.128/26.
7.11 Subnetting Under Exam Pressure
The CCNA does not give you a calculator, and every minute spent on arithmetic is a minute taken from a simulation question. A few habits make subnetting automatic:
Write the reference rows first. On your note board, write 128 64 32 16 8 4 2 1 and, under it, 128 192 224 240 248 252 254 255. Those two rows give you every mask value and block size.
Find the interesting octet before anything else. /1–/8 is the first octet, /9–/16 the second, /17–/24 the third, /25–/32 the fourth. Octets to the left are copied unchanged; octets to the right are 0 (network) or 255 (broadcast).
Never convert the whole address to binary. Only the interesting octet matters, and the block size method avoids binary even there.
Sanity-check every answer. The network ID must be a multiple of the block size; the broadcast must be one less than the next multiple; the given address must lie between them.
Practise to a time. Aim for 15 seconds per “find the subnet” problem. Appendix B contains 100 more drills with answers.
7.12 Practice Problems
Solve each problem before checking the answer. For problems 1–20, find the network ID, broadcast address, first and last usable host and number of usable hosts. Several given addresses are deliberately not valid host addresses; spot them. Problems 21–25 are design problems, 26–28 are wildcard masks, 29–33 ask whether two hosts share a subnet, and 34–37 ask for a specific subnet, 38–45 ask whether an address is a valid host, and 46–50 convert a range to a prefix. Every answer has been verified by computer.
7.12.1 Problems
Table 7-14 Practice problems 1–20: find network, broadcast, host range and host count
- 1. 192.168.10.37/27 2. 192.168.200.250/28 3. 10.5.6.7/30 4. 172.16.99.130/25
- 5. 192.168.77.94/26 6. 10.1.200.199/29 7. 172.18.33.66/21 8. 10.20.30.40/18
- 9. 192.168.5.5/23 10. 172.29.255.1/19 11. 10.150.3.4/13 12. 172.17.1.1/15
- 13. 10.99.99.99/9 14. 44.30.10.5/11 15. 172.16.200.255/24 16. 10.0.0.255/23
- 17. 10.1.1.10/31 18. 172.16.0.5/32 19. 10.255.17.9/16 20. 203.0.113.142/28
- 21. You must divide 192.168.10.0/24 into subnets that each hold at least 50 hosts. What prefix do you use, and how many subnets do you get?
- 22. A single VLAN must hold 500 hosts. What is the longest prefix (smallest subnet) that works?
- 23. Network 172.16.0.0/16 must be divided into at least 100 equal subnets with as many hosts as possible in each. What mask do you use, and how many hosts per subnet?
- 24. Network 10.0.0.0/8 must provide at least 1000 subnets, maximising hosts per subnet. What prefix do you use, and how many hosts per subnet?
- 25. 192.168.1.0/24 must provide six subnets of 25 hosts each. Which prefix meets both requirements? List the first three subnets.
- 26. What wildcard mask matches all addresses in 172.18.32.0/21?
- 27. What wildcard mask corresponds to subnet mask 255.255.255.248?
- 28. An ACL entry reads permit ip 10.10.100.0 0.0.3.255 any . Which source addresses does it match?
Problems 29–33: are the two hosts in the same subnet?
- 29. 10.1.1.100/27 and 10.1.1.130/27
- 30. 172.16.33.5/20 and 172.16.46.200/20
- 31. 192.168.1.62/26 and 192.168.1.65/26
- 32. 10.10.10.10/14 and 10.11.200.1/14
- 33. 172.20.5.1/23 and 172.20.6.1/23
Problems 34–37: find the requested subnet.
- 34. What is the third /26 subnet of 192.168.5.0/24? Give its range.
- 35. What is the 10th /22 subnet of 172.16.0.0/16? Give its range.
- 36. What is the last /20 subnet of 10.0.0.0/16? Give its range.
- 37. What is the fifth /12 subnet of 10.0.0.0/8? Give its range.
Problems 38–45: is the address a valid host address for the given prefix?
- 38. 10.4.3.0/22
- 39. 172.16.17.255/20
- 40. 192.168.1.95/27
- 41. 10.255.255.255/9
- 42. 172.31.64.0/18
- 43. 192.168.10.128/25
- 44. 10.0.31.255/19
- 45. 200.1.1.0/23
Problems 46–50: give the single prefix that exactly covers each range.
- 46. 172.16.32.0 through 172.16.35.255
- 47. 10.0.0.0 through 10.15.255.255
- 48. 192.168.100.64 through 192.168.100.127
- 49. 172.20.128.0 through 172.20.255.255
- 50. 10.10.10.8 through 10.10.10.15
7.12.2 Answers
Table 7-15 Answers to problems 1–20
- # Given Working Network Broadcast Usable range Hosts
- 1 192.168.10.37/27 octet 4, block 32: 32 ≤
- 37 < 64
- 192.168.10.32 192.168.10.63 192.168.10.33 –
- 192.168.10.62
- 2 192.168.200.250/28 octet 4, block 16: 240
- ≤ 250 < 256
- 192.168.200.240 192.168.200.255 192.168.200.241 –
- 192.168.200.254
- 3 10.5.6.7/30 octet 4, block 4: 4 ≤ 7
- < 8
- 10.5.6.4 10.5.6.7 10.5.6.5 – 10.5.6.6 2
Given address is the broadcast: not a valid host.
- 6 10.1.200.199/29 octet 4, block 8: 192 ≤
- 199 < 200
- 10.1.200.192 10.1.200.199 10.1.200.193 –
- 10.1.200.198
Given address is the broadcast: not a valid host.
Given address is the broadcast: not a valid host.
- 16 10.0.0.255/23 octet 3, block 2: 0 ≤ 0
- < 2
- 10.0.0.0 10.0.1.255 10.0.0.1 – 10.0.1.254 510
Valid host despite ending in .255.
- 17 10.1.1.10/31 octet 4, block 2: 10 ≤
- 10 < 12
- 10.1.1.10 10.1.1.11 10.1.1.10 – 10.1.1.11 2
/31: both addresses usable (RFC 3021).
- 18 172.16.0.5/32 octet boundary
- (255.255.255.255)
- 172.16.0.5 172.16.0.5 172.16.0.5 –
- 172.16.0.5
/32: a single host address.
- 21. /26 (255.255.255.192), four subnets. 50 hosts need 6 host bits (2 6 − 2 = 62; 5 bits give
only 30). 32 − 6 = 26. Borrowing 2 bits from the /24 gives 2
2 = 4 subnets: .0, .64, .128,
.192.
- 22. /23 (255.255.254.0). 500 hosts need 9 host bits (2
9 − 2 = 510; 8 bits give 254).
- 23. 255.255.254.0 (/23), 510 hosts per subnet. 100 subnets need 7 subnet bits (2 7 = 128;
6 bits give 64). 16 + 7 = 23, leaving 9 host bits.
- 24. /18 (255.255.192.0), 16,382 hosts per subnet. 1000 subnets need 10 bits (2 10 =
1024). 8 + 10 = 18, leaving 14 host bits: 2
14 − 2 = 16,382.
- 25. /27. Six subnets need 3 bits (8 subnets) and 25 hosts need 5 host bits (30 hosts); 3 + 5 = 8 fits the /24 exactly. First three: 192.168.1.0/27, 192.168.1.32/27, 192.168.1.64/27.
- 26. 0.0.7.255. /21 = 255.255.248.0; 255 − 248 = 7.
- 27. 0.0.0.7. 255 − 248 = 7 (a /29, block size 8).
- 28. 10.10.100.0 through 10.10.103.255. Wildcard 0.0.3.255 = /22, block size 4 in the third octet, so third octets 100, 101, 102 and 103 match.
Answers 29–33
- 29. No. 10.1.1.100 is in 10.1.1.96/27; 10.1.1.130 is in 10.1.1.128/27.
- 30. Yes. 172.16.33.5 is in 172.16.32.0/20; 172.16.46.200 is in 172.16.32.0/20.
- 31. No. 192.168.1.62 is in 192.168.1.0/26; 192.168.1.65 is in 192.168.1.64/26.
- 32. Yes. 10.10.10.10 is in 10.8.0.0/14; 10.11.200.1 is in 10.8.0.0/14.
- 33. No. 172.20.5.1 is in 172.20.4.0/23; 172.20.6.1 is in 172.20.6.0/23.
Answers 34–37
- 34. 192.168.5.128/26 (192.168.5.128–192.168.5.191). Block 64 in octet 4; 2 × 64 = 128.
- 35. 172.16.36.0/22 (172.16.36.0–172.16.39.255). Block 4 in octet 3; 9 × 4 = 36.
- 36. 10.0.240.0/20 (10.0.240.0–10.0.255.255). Block 16 in octet 3; 15 × 16 = 240.
- 37. 10.64.0.0/12 (10.64.0.0–10.79.255.255). Block 16 in octet 2; 4 × 16 = 64.
Answers 38–45
- 38. Yes: a host in 10.4.0.0/22 (range 10.4.0.1–10.4.3.254).
- 39. Yes: a host in 172.16.16.0/20 (range 172.16.16.1–172.16.31.254).
- 40. No: it is the broadcast address of 192.168.1.64/27.
- 41. No: it is the broadcast address of 10.128.0.0/9.
- 42. No: it is the network ID of 172.31.64.0/18.
- 43. No: it is the network ID of 192.168.10.128/25.
- 44. No: it is the broadcast address of 10.0.0.0/19.
- 45. Yes: a host in 200.1.0.0/23 (range 200.1.0.1–200.1.1.254).
Answers 46–50
- 46. 172.16.32.0/22 (mask 255.255.252.0, wildcard 0.0.3.255); 1,024 addresses.
- 47. 10.0.0.0/12 (mask 255.240.0.0, wildcard 0.15.255.255); 1,048,576 addresses.
- 48. 192.168.100.64/26 (mask 255.255.255.192, wildcard 0.0.0.63); 64 addresses.
- 49. 172.20.128.0/17 (mask 255.255.128.0, wildcard 0.0.127.255); 32,768 addresses.
- 50. 10.10.10.8/29 (mask 255.255.255.248, wildcard 0.0.0.7); 8 addresses.
s subnets
- 1. What is the network ID of host 10.44.130.9/19?
- A. 10.44.0.0
- B. 10.44.96.0
- C. 10.44.128.0
- D. 10.44.130.0
- 2. What is the broadcast address of the subnet that contains 172.16.70.4/22?
- A. 172.16.70.255
- B. 172.16.71.255
- C. 172.16.67.255
- D. 172.16.68.255
- 3. Which is a valid host address in subnet 192.168.15.0/28?
- A. 192.168.15.0
- B. 192.168.15.14
- C. 192.168.15.15
- D. 192.168.15.16
- 4. How many usable host addresses does a /23 subnet provide?
- A. 254
- B. 256
- C. 510
- D. 512
- 5. An engineer must create at least 120 subnets from 172.20.0.0/16 with the largest possible number of hosts in each. Which mask should be used?
- A. 255.255.255.0
- B. 255.255.254.0
- C. 255.255.252.0
- D. 255.255.255.128
- 6. Which prefix supports a subnet of 1000 hosts while wasting the fewest addresses?
- A. /21
- B. /22
- C. /23
- D. /24
- 7. Which two addresses are usable hosts in the same subnet as 10.1.1.77/29? (Choose two.)
- A. 10.1.1.72
- B. 10.1.1.73
- C. 10.1.1.78
- D. 10.1.1.79
- E. 10.1.1.80
- 8. Which wildcard mask matches every address in 192.168.4.0/22?
- A. 0.0.0.255
- B. 0.0.3.255
- C. 255.255.252.0
- D. 0.0.4.255
- 9. A host is configured as 172.16.45.201/20. Which address could be its default gateway?
- A. 172.16.31.254
- B. 172.16.32.1
- C. 172.16.48.1
- D. 172.16.47.255
- 10. Which statement about a /31 prefix is true?
- A. It provides one usable address
- B. It can be used only on loopback interfaces
- C. Both addresses are usable on a point-to-point link
- D. It is rejected by Cisco IOS
- 11. How many /27 subnets fit in one /24?
- A. 4
- B. 6
- C. 8
- D. 16
- 12. Which two prefixes have a block size of 8 in their interesting octet? (Choose two.)
- A. /21
- B. /22
- C. /29
- D. /26
- E. /20
- 13. What is the last usable host address in the subnet containing 10.200.15.3/10?
- A. 10.200.255.254
- B. 10.255.255.254
- C. 10.255.255.255
- D. 10.223.255.254
Answers
- 1. C. /19: third octet, block 32. 128 ≤ 130 < 160, so the network is 10.44.128.0.
- 2. B. Block 4 in the third octet: 68 ≤ 70 < 72, network 172.16.68.0, broadcast 172.16.71.255.
- 3. B. The /28 spans .0–.15; .0 is the network ID, .15 the broadcast, and .16 is in the next subnet.
- 4. C. Nine host bits: 2
9 − 2 = 510.
- 5. B. 120 subnets need 7 bits (128). /16 + 7 = /23 = 255.255.254.0, with 510 hosts each.
- 6. B. /22 gives 1022 hosts; /23 gives only 510.
- 7. B, C. The subnet is 10.1.1.72/29 (.72–.79). .72 is the network ID, .79 the broadcast and .80 is in the next subnet.
- 8. B. /22 = 255.255.252.0; 255 − 252 = 3, giving 0.0.3.255.
- 9. B. The host subnet is 172.16.32.0–172.16.47.255. .31.254 and .48.1 are outside it; 172.16.47.255 is the broadcast.
- 10. C. RFC 3021 allows /31 on point-to-point links with both addresses usable. IOS accepts it (with a warning on Ethernet).
- 11. C. Borrowing 3 bits: 2
3 = 8.
- 12. A, C. /21 (255.255.248.0) and /29 (255.255.255.248) both have mask value 248, so block 256 − 248 = 8.
- 13. B. /10: second octet, block 64. 192 ≤ 200 < 256, so the subnet is 10.192.0.0– 10.255.255.255 and the last host is 10.255.255.254.