Subnet ranges
On this page
You have a /26 and must number forty devices. Which addresses may you use? Find the two reserved ends first.
Before you start
Section titled “Before you start”Finish Practice: Understanding IPv4 Addresses and Masks and CIDR notation. Keep the starting lab up, modes off. Begin at the VM prompt. These reads do not change the lab.
Name the two ends
Section titled “Name the two ends”With every host bit zero, the network address names the subnet itself. With every host bit one, the broadcast address addresses all hosts on that subnet. The usable range is the addresses between those ends that ordinary interfaces can use. Neither end is an ordinary host address in the subnets calculated here.
Predict: how many usable addresses does /26 have? Guess, then calculate using the method below. Keep your guess until calculating.
Use the same five steps
Section titled “Use the same five steps”- Find the octet where the prefix ends. At a dot boundary, use the last network octet. For
/26, use the fourth octet, whose mask value is 192. - Calculate block size: 256 minus that octet’s mask value. Here, 256 minus 192 gives 64.
- Find the largest multiple of the block size not above the address’s octet. That is the network address’s value there; set later octets to 0.
- Broadcast is network plus block size minus 1 in that octet; set later octets to 255.
- Usable addresses run from network plus 1 to broadcast minus 1. Their count is 2 raised to the host bit count, minus 2.
For 192.0.2.64/26, multiples of 64 are 0, 64, 128 and 192. Choose 64, not the next block. The broadcast’s last octet is 64 + 64 − 1 = 127.
192.0.2.64/26
Section titled “192.0.2.64/26”| Field | Value |
|---|---|
| Prefix | /26 |
| Network address | 192.0.2.64 |
| First usable | 192.0.2.65 |
| Last usable | 192.0.2.126 |
| Broadcast address | 192.0.2.127 |
| Usable count | 62 |
Check your answer
Six host bits give 2 raised to 6 = 64 addresses. Removing the two ends leaves 62, enough for forty devices. Usable does not mean occupied.
Repeat across different boundaries
Section titled “Repeat across different boundaries”For 198.51.100.128/25, the fourth mask octet is 128. The block size is 128, so the network begins at 128 and the broadcast ends at 255. Seven host bits give 128 addresses before removing the two ends.
198.51.100.128/25
Section titled “198.51.100.128/25”| Field | Value |
|---|---|
| Prefix | /25 |
| Network address | 198.51.100.128 |
| First usable | 198.51.100.129 |
| Last usable | 198.51.100.254 |
| Broadcast address | 198.51.100.255 |
| Usable count | 126 |
For 172.16.40.0/22, the mask is 255.255.252.0. Work in the third octet: 256 minus 252 is 4. Forty is a multiple of 4. The broadcast’s third octet becomes 43; its later octet becomes 255. Ten host bits give 1024 addresses; removing the two ends leaves 1022.
172.16.40.0/22
Section titled “172.16.40.0/22”| Field | Value |
|---|---|
| Prefix | /22 |
| Network address | 172.16.40.0 |
| First usable | 172.16.40.1 |
| Last usable | 172.16.43.254 |
| Broadcast address | 172.16.43.255 |
| Usable count | 1022 |
Compare with the machine
Section titled “Compare with the machine”Laptop has 10.77.10.10/24. Calculate its network and broadcast before repeating these commands.
learner@rootvolt:~$ netlab shell laptop -- ip address show eth0[sudo] password for learner: 4: eth0@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 02:77:10:00:00:10 brd ff:ff:ff:ff:ff:ff link-netns sw-home
inet 10.77.10.10/24 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::77:10ff:fe00:10/64 scope link
valid_lft forever preferred_lft foreverlearner@rootvolt:~$ netlab shell laptop -- ip routedefault via 10.77.10.1 dev eth0
10.77.10.0/24 dev eth0 proto kernel scope link src 10.77.10.10 learner@rootvolt:~$ netlab shell laptop -- ip route show table locallocal 10.77.10.10 dev eth0 proto kernel scope host src 10.77.10.10
broadcast 10.77.10.255 dev eth0 proto kernel scope link src 10.77.10.10
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1 learner@rootvolt:~$ Steps (12)
- Type
netlab shell laptop -- ip address show eth0 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
4: eth0@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 02:77:10:00:00:10 brd ff:ff:ff:ff:ff:ff link-netns sw-home inet 10.77.10.10/24 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::77:10ff:fe00:10/64 scope link valid_lft forever preferred_lft forever - Type
netlab shell laptop -- ip route - Press Enter
- Output:
default via 10.77.10.1 dev eth0 10.77.10.0/24 dev eth0 proto kernel scope link src 10.77.10.10 - Type
netlab shell laptop -- ip route show table local - Press Enter
- Output:
local 10.77.10.10 dev eth0 proto kernel scope host src 10.77.10.10 broadcast 10.77.10.255 dev eth0 proto kernel scope link src 10.77.10.10 local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1 local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1 broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
The route begins 10.77.10.0/24. ip route show table local lists the addresses that belong to the machine itself. Read only its broadcast 10.77.10.255 line for eth0; the lo lines belong to loopback. Many computers also print the broadcast after brd on the inet line, but this lab’s inet line has no brd value.
Mistakes to recognize
Section titled “Mistakes to recognize”“The first address is usable.” All-zero host bits name the subnet, so 192.0.2.64 is reserved in the worked /26.
“A subnet always ends in .255.” That same subnet ends at 192.0.2.127. The prefix selects the range.
Good to know
Section titled “Good to know”/31 is used on a link between exactly two devices, where both addresses are usable. /32 names one single address. The ordinary minus-two count does not apply to either.
Try it yourself
Section titled “Try it yourself”For 192.0.2.145/27, 198.51.100.74/28, 203.0.113.10/29, 172.16.9.8/23, and 10.4.19.7/20, write all five steps and the network, first usable, last usable, broadcast and count. Then calculate the range for web’s 10.77.20.80/24. Run the replay’s three web commands and compare your network and broadcast with its route and local table.
learner@rootvolt:~$ netlab shell web -- ip address show eth0[sudo] password for learner: 12: eth0@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 02:77:20:00:00:80 brd ff:ff:ff:ff:ff:ff link-netns sw-site
inet 10.77.20.80/24 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::77:20ff:fe00:80/64 scope link
valid_lft forever preferred_lft foreverlearner@rootvolt:~$ netlab shell web -- ip routedefault via 10.77.20.1 dev eth0
10.77.20.0/24 dev eth0 proto kernel scope link src 10.77.20.80 learner@rootvolt:~$ netlab shell web -- ip route show table locallocal 10.77.20.80 dev eth0 proto kernel scope host src 10.77.20.80
broadcast 10.77.20.255 dev eth0 proto kernel scope link src 10.77.20.80
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1 learner@rootvolt:~$ Steps (12)
- Type
netlab shell web -- ip address show eth0 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
12: eth0@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 02:77:20:00:00:80 brd ff:ff:ff:ff:ff:ff link-netns sw-site inet 10.77.20.80/24 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::77:20ff:fe00:80/64 scope link valid_lft forever preferred_lft forever - Type
netlab shell web -- ip route - Press Enter
- Output:
default via 10.77.20.1 dev eth0 10.77.20.0/24 dev eth0 proto kernel scope link src 10.77.20.80 - Type
netlab shell web -- ip route show table local - Press Enter
- Output:
local 10.77.20.80 dev eth0 proto kernel scope host src 10.77.20.80 broadcast 10.77.20.255 dev eth0 proto kernel scope link src 10.77.20.80 local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1 local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1 broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
Solution
/27: mask octet 224, block 32; network192.0.2.128, usable192.0.2.129through192.0.2.158, broadcast192.0.2.159, count 30./28: mask octet 240, block 16; network198.51.100.64, usable198.51.100.65through198.51.100.78, broadcast198.51.100.79, count 14./29: mask octet 248, block 8; network203.0.113.8, usable203.0.113.9through203.0.113.14, broadcast203.0.113.15, count 6./23: third mask octet 254, block 2; network172.16.8.0, usable172.16.8.1through172.16.9.254, broadcast172.16.9.255, count 510./20: third mask octet 240, block 16; network10.4.16.0, usable10.4.16.1through10.4.31.254, broadcast10.4.31.255, count 4094.
Web’s route names 10.77.20.0/24; its local table lists broadcast 10.77.20.255. The usable range is 10.77.20.1 through 10.77.20.254, count 254.
Leave for later
Section titled “Leave for later”Point-to-point and host routes and Allocating IPv4 subnets in Planning Address Space cover the exceptions and planning several subnets.
- Find the boundary octet and its block size.
- Reserve the network and broadcast addresses.
- Check calculated endpoints against the machine’s settings.
Next, Same subnet or gateway uses that range to choose a path.