Skip to content

Subnet ranges

Module
Subnetting Foundations
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS, netlab 1.0, GNU Bash 5.2.21, tcpdump 4.99.4
On this page

You have a /26 and must number forty devices. Which addresses may you use? Find the two reserved ends first.

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.

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.

  1. 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.
  2. Calculate block size: 256 minus that octet’s mask value. Here, 256 minus 192 gives 64.
  3. 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.
  4. Broadcast is network plus block size minus 1 in that octet; set later octets to 255.
  5. 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.

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.

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.

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.

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

Laptop has 10.77.10.10/24. Calculate its network and broadcast before repeating these commands.

Read laptop address and subnet routes
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Compare laptop's address with its connected route and subnet broadcast entry.
Steps (12)
  1. Type netlab shell laptop -- ip address show eth0
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. 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
  7. Type netlab shell laptop -- ip route
  8. Press Enter
  9. 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
  10. Type netlab shell laptop -- ip route show table local
  11. Press Enter
  12. 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.

“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.

/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.

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.

Check web network and broadcast addresses
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Check the calculated endpoints against web's own settings.
Steps (12)
  1. Type netlab shell web -- ip address show eth0
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. 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
  7. Type netlab shell web -- ip route
  8. Press Enter
  9. 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
  10. Type netlab shell web -- ip route show table local
  11. Press Enter
  12. 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; network 192.0.2.128, usable 192.0.2.129 through 192.0.2.158, broadcast 192.0.2.159, count 30.
  • /28: mask octet 240, block 16; network 198.51.100.64, usable 198.51.100.65 through 198.51.100.78, broadcast 198.51.100.79, count 14.
  • /29: mask octet 248, block 8; network 203.0.113.8, usable 203.0.113.9 through 203.0.113.14, broadcast 203.0.113.15, count 6.
  • /23: third mask octet 254, block 2; network 172.16.8.0, usable 172.16.8.1 through 172.16.9.254, broadcast 172.16.9.255, count 510.
  • /20: third mask octet 240, block 16; network 10.4.16.0, usable 10.4.16.1 through 10.4.31.254, broadcast 10.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.

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.