Course / 05 Networks / Lesson 06 of 09

Subnets far enough to read a /24

Estimated time: 15 min reading · 15 min activity

Two addresses can look similar without belonging to the same subnet. A subnet is an IP address block identified by a shared prefix. The prefix gives the leading bits that must match; the remaining bits distinguish positions within the block.

An IPv4 address has 32 bits written as four decimal octets. An octet is eight bits, so each dotted number ranges from 0 through 255. The slash in /24 says that the first 24 bits are fixed. Those are exactly the first three octets; the final eight bits can vary.

Before you begin

Estimated time
15 min reading, 15 min activity. Setup and optional practice may take longer.
Where you work
Use the supplied original network cards, packet tables and stream transcripts in any browser, including on a phone. You need no account, paid lab or live network access. Reading a saved file in Wireshark is optional; installation time is separate from the estimate. Optional challenges take about ten extra minutes.
Without a lab
The page prints every address, row and message needed for its activity. Follow the numbered steps in notes and label your conclusions as predictions or interpretations of supplied evidence. The pcapng files are synthetic, constructed examples; opening one is different from recording a network. Reading works without JavaScript. Answer checking needs JavaScript and a secure context, such as HTTPS. Saving correct progress also needs usable browser storage.

After this lesson you can:

  • Compare complete octets for membership in a stated IPv4 /24.
  • Calculate the total addresses from 32 minus the prefix length.
  • Distinguish whole-block membership from ordinary host assignment.

01Example

Use the worked prefix 192.168.40.0/24. Compare the whole numbers between dots, not just similar-looking initial digits. These membership decisions are hand calculations, not results from the supplied script.

Prefix: 192.168.40.0/24
Fixed octets: 192 | 168 | 40
Variable octet: the fourth number

192.168.40.10 -> inside: all three fixed octets match
192.168.41.10 -> outside: the third octet changed

32 - 24 = 8 variable bits
2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 = 256 total addresses

02Three octets, for this /24 only

Compare from left to right. For a /24, all three initial octets must match the prefix. The final octet can vary without leaving the block. Compare each octet as a complete number: 5 is not 50, even though their decimal writing starts with the same digit.

A subnet mask writes the fixed-prefix positions as one bits and the variable positions as zero bits. For /24, its four octets are 255.255.255.0: three groups of eight one-bits followed by eight zero-bits. It describes the same boundary in another notation.

To count the whole block, subtract the prefix length from 32. Each remaining bit has two choices, so eight variable bits give 2 to the power of 8, or 256 addresses. This total includes every position. Do not subtract network or broadcast addresses when asked for the total.

In a conventional /24, the all-zero host portion names the network and the all-one host portion is the broadcast address. Broadcast is delivery intended for the subnet's hosts. Membership in the block differs from suitability for assigning an ordinary host address.

The three-octet shortcut works because 24 ends at an eight-bit boundary. Other prefixes can split an octet. /31 and /32 also need their own usage rules; do not apply a blanket usable-host subtraction or this shortcut to every prefix.

For this worked prefix all three fixed octets must match; total addresses describe a block size, with separate rules for host assignment.Model. A teaching model drawn by hand. It shows the idea, not real tool output.

Read the full explanation below.

192.168.40.10192.168.41.10

Network 192.168.40.0/24

192network168network40network0host
192network168network40network10host
Same /24 network
Compare the first three octets.

192 | 168 | 40 matches the first candidate: inside this /24.

Follow the explanation

  1. 192 | 168 | 40 matches the first candidate: inside this /24.
  2. The third octet is 41 instead of 40: outside this /24.
  3. Eight variable bits determine the total block size; host assignment has separate rules.
Read every state and value

1. 192 | 168 | 40 matches the first candidate: inside this /24.

Candidate
inside
Compared Octets
0 · 1 · 2
Size Visible
No

2. The third octet is 41 instead of 40: outside this /24.

Candidate
outside
Compared Octets
0 · 1 · 2
Size Visible
No

3. Eight variable bits determine the total block size; host assignment has separate rules.

Candidate
outside
Compared Octets
0 · 1 · 2
Size Visible
Yes
For this worked prefix all three fixed octets must match; total addresses describe a block size, with separate rules for host assignment.

03Choose the address inside 10.8.0.0/24

The guided prefix is 10.8.0.0/24, different from the worked and later question prefixes. Compare each activity address with its first three complete octets before reading the printed check.

The source file check-subnet.py uses Python's standard-library ipaddress module, a bundled tool for representing addresses and networks. Its address in network expression tests membership. The printed lines below retain the output recorded in the earlier 2026-10-12 exercise. You can complete the same reasoning without running the script.

Compare whole IPv4 octets

IPv4 has 32 bits in four octets. An octet is eight bits written as one
dotted decimal number from 0 through 255. A /24 fixes 24 leading bits,
exactly the first three octets. Compare complete numbers: 5 is not 50.

A subnet mask marks fixed bits with 1 and variable bits with 0.
For /24 this is 255.255.255.0. Eight bits remain free. Each bit has two
possible values, giving 2 to the power 8 = 256 total addresses. That
total includes network and broadcast positions; it is not an ordinary
usable-host count. Other prefixes need their own membership rules.

Prefix cards. Original fictional addresses. Not your computer's addresses.

Worked prefix 192.168.40.0/24
The prefix length is 24 bits. In this octet-aligned example the first three octets stay 192.168.40.
192.168.40.10 is inside.
192.168.41.10 is outside because the third octet differs.
The mask with those same 24 one-bits is 255.255.255.0.
Eight bits remain, so the prefix covers 256 addresses. This counts the whole block rather than only assignable ordinary-host addresses.

Activity prefix 10.8.0.0/24
10.8.0.15   compare the first three octets
10.8.1.15   compare the first three octets
10.9.0.15   compare the first three octets
Predict before reading the check. Check: 10.8.0.15 is inside. The other two are outside.

A /31 or a /32 does not use this lesson's three-octet habit. Stay with the stated /24.

Download the prefix cards

import ipaddress

network = ipaddress.ip_network("10.8.0.0/24")
for text in ("10.8.0.15", "10.8.1.15", "10.9.0.15"):
    address = ipaddress.ip_address(text)
    print(text, "in" if address in network else "out")

Download the membership script for source reading

  1. For 10.8.0.15, 10.8.1.15, and 10.9.0.15, compare the first three octets with 10.8.0.
  2. Check: 10.8.0.15 is inside. The other two are outside.
  3. Read the script as a source-review extension: import loads ipaddress; ip_network builds the stated network object; ip_address builds each address object. The expression address in network tests membership, and print displays the address with in or out. Compare these operations with your paper decisions.
  4. Finish from the paper comparison; running the script is unnecessary. Its membership test differs from IPv4Address.is_private, an attribute that classifies a wider set of special-use addresses rather than only the three RFC 1918 private blocks.
Earlier recorded stdout, 2026-10-12:
10.8.0.15 in
10.8.1.15 out
10.9.0.15 out

04Optional challenge

Allow about ten extra minutes. Compare 172.16.5.9 and 172.16.6.9 with 172.16.5.0/24 on paper. Explain which octet decides membership. Then state how many bits can vary without using those two example addresses to count the entire block.

05Module case

Combine host roles, subnet membership and listener interpretation in the supplied network-case. The case uses shelf .15, rather than the .23 address on other cards. Use the exact address in the current case instead of carrying an earlier value forward.

Check your note against its rubric: locate desk and shelf in the stated /24, place remote outside it, read the printed listener port with TCP, and name the boundary device's role. Explain each result from the supplied evidence and stop with the note. This synthesis needs no scan or live network access.

Combine the network roles in one evidence note

Use the exact address and listener supplied by this case. An earlier
card can reuse a host name with a different value. State subnet
membership, destination port, transport and the boundary device role,
then explain each from the printed evidence. No connection or scan is
needed. Use the final rubric only after drafting your note.

Networks module review case. Original fictional card. Do not scan.

Endpoint shelf
IPv4 192.168.50.15
Prefix to test 192.168.50.0/24
Listener row 9090/tcp, notes page
Transport named on the row: TCP

Other addresses on the card
desk 192.168.50.10
remote 203.0.113.10
gate is the router between this /24 and other networks

Rubric, answered from this card
1. shelf 192.168.50.15 and desk 192.168.50.10 share 192.168.50.0/24. remote does not.
2. The stated listener is 9090/tcp. A customary port 80 is not on this row.
3. TCP is the transport. The notes page is the application name on the row.
4. gate is the device that connects the segment to other networks.

Download the Networks module case

  1. Say whether shelf 192.168.50.15 and desk 192.168.50.10 share 192.168.50.0/24, and whether remote 203.0.113.10 does.
  2. Read the listener row 9090/tcp. Name the port and the transport printed on that row. A customary port 80 is not the row.
  3. Name gate's role. The rubric in the file is the whole case. Stop. Do not scan.

06Cards for the checks

The checks below use these cards. They are original fictional text, safe to read anywhere.

Independent IPv4 prefixes: compare whole dotted numbersOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.

Prefix 172.20.7.0/24
172.20.7.200
172.20.8.7
172.21.7.7
172.2.7.7
 
Shelf case prefix 192.168.50.0/24, desk 192.168.50.10

07Fresh cases for the checks

Use these fictional cases for the checks below. They have different inputs from the worked examples. Read them here or make notes; no installation or external service is needed.

Subnet case A: independent conventional /24Owned fixture. An original file made for this course. Follow the activity's instructions in your own lab.

Host address: 10.73.18.90/24.
A /24 fixes the first three complete octets; the fourth can vary.
In this conventional /24, all-zero host bits name the network and all-one host bits name the broadcast.
Addresses for classification: 10.73.18.0; 10.73.18.255; 10.73.18.24; 10.73.19.24.

08Explain your prediction

Optional written self-check: Show the fixed and variable octets, then distinguish membership, network, broadcast and ordinary-host suitability. Limit this shortcut to the taught /24 case.

09Common mistakes

If an address with a changed third octet looks inside a /24, compare all three fixed octets again. Matching only the first two is insufficient.

If you get 254 for a total-address question, separate total positions from ordinary host assignments. Eight free bits supply 256 positions before any role-based exclusions.

If a proposed shortcut uses only decimal string beginnings, compare whole dotted numbers. A prefix length counts binary bits; it does not count printed decimal characters.

References

  • RFC 4632: Classless Inter-domain Routing

    Section 3.1. A prefix is the most significant N bits, written with slash notation. The /24 three-octet reading is the octet-aligned case. The /31 note points at RFC 3021. Other prefix lengths need their own rules. The 256-address count is 2 to the power of 8.

  • Python 3.12: ipaddress howto

    The containment examples. address in network is true for 192.0.2.1 in 192.0.2.0/24 and false for 192.0.2.1 in 192.0.3.0/24. Read the membership examples alongside the supplied source.