Subnetting Practice
Answer a question, see whether it is right, and read the steps. Every answer is calculated in your browser. The block sizes are on the Subnet cheat sheet, and a single subnet opens in the Subnet calculator.
Question
How to practice subnetting
Subnetting gets faster when you work questions, not when you reread a table. Start on easy prefixes, /24 through /30, and write the network, broadcast and host range before you check. When those are comfortable, move the boundary into the third octet, then the second, and add the /31 and /32 cases. Turn the timer on once you can finish a question without looking up the block size. Missed questions are the useful ones: read the steps, then take another from the same seed.
The magic number method
The magic number is the block size in the octet where the mask stops being 255. Subtract that mask octet from 256. Subnets in that octet start at 0 and then on every multiple of the block size. Take the address octet and find the greatest multiple of the block that is still less than or equal to it. That multiple is the network's value in the interesting octet, and every octet to its right is 0.
The broadcast address is one less than the next multiple, with the octets to the right set to 255. The first usable host is the address after the network, and the last usable host is the address before the broadcast. Two cases skip that minus-two rule. A /31 uses both of its addresses on a point-to-point link, and a /32 is a single host with no broadcast address.
Example. Which subnet contains 192.168.1.77 with mask 255.255.255.192? Give the network in CIDR notation.
Answer: 192.168.1.64/26
- Mask 255.255.255.192. The interesting octet is octet 4, value 192.
- Block size = 256 − 192 = 64. Subnets in that octet start on multiples of 64.
- Address octet 77 falls in the block that starts at 64.
- Network 192.168.1.64, broadcast 192.168.1.127. Usable hosts run from 192.168.1.65 to 192.168.1.126 (62 of 64).
- The subnet is 192.168.1.64/26.
Subnetting practice questions with answers
These ten stay the same so you can check them on paper. Open a row to see the answer and the steps. The quiz above makes new ones.
For 192.168.1.37/26, give the network address, broadcast address, first usable host and last usable host. Write none when there is no broadcast address.
Network address: 192.168.1.0 · Broadcast address: 192.168.1.63 · First usable host: 192.168.1.1 · Last usable host: 192.168.1.62
- Mask 255.255.255.192. The interesting octet is octet 4, value 192.
- Block size = 256 − 192 = 64. Subnets in that octet start on multiples of 64.
- Address octet 37 falls in the block that starts at 0.
- Network 192.168.1.0, broadcast 192.168.1.63. Usable hosts run from 192.168.1.1 to 192.168.1.62 (62 of 64).
What is the subnet mask for /27, and how many usable hosts does it have?
Subnet mask: 255.255.255.224 · Usable hosts: 30
- /27 is 255.255.255.224.
- Total addresses 32, minus the network and broadcast addresses, leaves 30 usable hosts.
The subnet mask is 255.255.255.128. What prefix length is that?
Prefix length: /25
- 255.255.255.128 has 25 leading one-bits, so the prefix is /25.
A subnet needs 50 usable hosts. What is the smallest prefix length? Reserve the network and broadcast addresses.
Prefix length: /26
- 50 usable hosts are required, and the network and broadcast addresses are reserved.
- The smallest prefix lib/subnet.js returns for that count is /26 (255.255.255.192), with 62 usable hosts.
- /27 has 30 usable hosts, which is short of 50, so /26 is the smallest that fits.
Which subnet contains 172.16.5.40 with mask 255.255.255.192? Give the network in CIDR notation.
Network: 172.16.5.0/26
- Mask 255.255.255.192. The interesting octet is octet 4, value 192.
- Block size = 256 − 192 = 64. Subnets in that octet start on multiples of 64.
- Address octet 40 falls in the block that starts at 0.
- Network 172.16.5.0, broadcast 172.16.5.63. Usable hosts run from 172.16.5.1 to 172.16.5.62 (62 of 64).
- The subnet is 172.16.5.0/26.
Which subnet contains 10.1.4.77 with mask 255.255.252.0? Give the network in CIDR notation.
Network: 10.1.4.0/22
- Mask 255.255.252.0. The interesting octet is octet 3, value 252.
- Block size = 256 − 252 = 4. Subnets in that octet start on multiples of 4.
- Address octet 4 falls in the block that starts at 4.
- Octets after octet 3 are 0 in the network address and 255 in the broadcast address.
- Network 10.1.4.0, broadcast 10.1.7.255. Usable hosts run from 10.1.4.1 to 10.1.7.254 (1,022 of 1,024).
- The subnet is 10.1.4.0/22.
For 172.20.19.5/20, give the network address, broadcast address, first usable host and last usable host. Write none when there is no broadcast address.
Network address: 172.20.16.0 · Broadcast address: 172.20.31.255 · First usable host: 172.20.16.1 · Last usable host: 172.20.31.254
- Mask 255.255.240.0. The interesting octet is octet 3, value 240.
- Block size = 256 − 240 = 16. Subnets in that octet start on multiples of 16.
- Address octet 19 falls in the block that starts at 16.
- Octets after octet 3 are 0 in the network address and 255 in the broadcast address.
- Network 172.20.16.0, broadcast 172.20.31.255. Usable hosts run from 172.20.16.1 to 172.20.31.254 (4,094 of 4,096).
For 192.168.10.7/31, give the network address, broadcast address, first usable host and last usable host. Write none when there is no broadcast address.
Network address: 192.168.10.6 · Broadcast address: none · First usable host: 192.168.10.6 · Last usable host: 192.168.10.7
- Mask 255.255.255.254. The interesting octet is octet 4, value 254.
- Block size = 256 − 254 = 2. Subnets in that octet start on multiples of 2.
- Address octet 7 falls in the block that starts at 6.
- The network is 192.168.10.6. A /31 has no broadcast address: 192.168.10.6 and 192.168.10.7 are both usable (RFC 3021).
For 10.0.0.5/32, give the network address, broadcast address, first usable host and last usable host. Write none when there is no broadcast address.
Network address: 10.0.0.5 · Broadcast address: none · First usable host: 10.0.0.5 · Last usable host: 10.0.0.5
- Mask 255.255.255.255. The interesting octet is octet 4, value 255.
- Block size = 256 − 255 = 1. Subnets in that octet start on multiples of 1.
- Address octet 5 falls in the block that starts at 5.
- A /32 is the single address 10.0.0.5. There is no broadcast address.
Which subnet contains 10.40.15.9 with mask 255.240.0.0? Give the network in CIDR notation.
Network: 10.32.0.0/12
- Mask 255.240.0.0. The interesting octet is octet 2, value 240.
- Block size = 256 − 240 = 16. Subnets in that octet start on multiples of 16.
- Address octet 40 falls in the block that starts at 32.
- Octets after octet 2 are 0 in the network address and 255 in the broadcast address.
- Network 10.32.0.0, broadcast 10.47.255.255. Usable hosts run from 10.32.0.1 to 10.47.255.254 (1,048,574 of 1,048,576).
- The subnet is 10.32.0.0/12.
Questions
How long does it take to learn subnetting?
If you already know what an IP address and a prefix are, the method itself is an evening or two. Speed takes longer. Exam-style questions are timed, so the useful practice is repeating them until the block size and the host range come out without looking them up.
Is subnetting on the CCNA exam?
Yes. The CCNA exam topics include configuring and verifying IPv4 addressing and subnetting. The prefixes that come up most often in coursework are /24 through /30, along with the /31 point-to-point case.
What is the magic number in subnetting?
The magic number is the block size, 256 minus the mask octet that is not 255. For 255.255.255.192 that octet is 192, so the block size is 64 and subnets start at 0, 64, 128 and 192. An address belongs to the block whose start is the greatest multiple of that size that does not pass the address.
How should I practice subnetting?
Write the network, broadcast and host range before you check the answer, then read the steps for anything you missed. A short timed set of ten is closer to an exam than a long untimed session. Keep a cheat sheet nearby until the /25 to /30 block sizes are memorized.
What is special about a /31 or a /32?
A /32 is one address, used as a host route or a loopback, so there is no separate broadcast address. A /31 has two addresses and, on a point-to-point link, RFC 3021 makes both of them usable. The usual rule of subtracting two addresses starts at /30.