Internet Protocol Version 4 (IPv4) — Part 3
An address alone does not tell a device which network it belongs to. For that you need a subnet mask. This lesson introduces the mask, the network and host portions, prefix notation, and the two addresses in every network that can never belong to a host: the network address and the broadcast address.
What is a subnet mask?
A subnet mask is a 32-bit number, written in the same dotted-decimal form as an IPv4 address, that sits alongside the address and says: these bits are the network, those bits are the host. The mask is built from a run of contiguous 1s starting at the left, followed by 0s to the end. The 1s mark the network portion; the 0s mark the host portion.
Without a mask, 192.168.10.45 is just a number. With the mask 255.255.255.0, we learn that 192.168.10 identifies the network and 45 identifies the host inside it.
Network portion vs host portion
Look at the mask in binary. Every 1 aligns with a network bit of the address; every 0 aligns with a host bit.
Address: 192.168.10.45 prefix /24
Binary : 11000000.10101000.00001010.00101010
Mask : 11111111.11111111.11111111.00000000
[===== network bits (24) =====][ host bits (8) ]
Here the first 24 bits are network and the final 8 bits are host. Because the mask's ones are contiguous, the boundary is easy to see. The number of host bits, usually called h, determines how many devices the network can hold.
Default masks by class
In classful addressing each class came with a default mask that matched its size. These three masks you must know instantly:
| Class | Default mask | Prefix | Network / host split |
|---|---|---|---|
| A | 255.0.0.0 | /8 | 8 network bits, 24 host bits |
| B | 255.255.0.0 | /16 | 16 network bits, 16 host bits |
| C | 255.255.255.0 | /24 | 24 network bits, 8 host bits |
255 = 8 ones, 0 = 0 ones. So 255.255.255.0 = 8 + 8 + 8 + 0 = /24. Count the ones to get the prefix.Prefix / CIDR notation and host counts
Instead of writing a mask, engineers often write a slash and the number of network bits: 192.168.10.45/24. This is prefix notation, also called CIDR (Classless Inter-Domain Routing) notation. The number after the slash is the count of leading 1s in the mask. Because the address is always 32 bits, host bits = 32 − prefix.
For example, /24 → host bits h = 32 − 24 = 8; /26 → h = 32 − 26 = 6. This is the h you will plug into the host-count formula.
| Prefix | Mask | Host bits h | Usable hosts (2h−2) |
|---|---|---|---|
| /8 | 255.0.0.0 | 24 | 16,777,214 |
| /16 | 255.255.0.0 | 16 | 65,534 |
| /24 | 255.255.255.0 | 8 | 254 |
| /25 | 255.255.255.128 | 7 | 126 |
| /26 | 255.255.255.192 | 6 | 62 |
| /27 | 255.255.255.224 | 5 | 30 |
| /28 | 255.255.255.240 | 4 | 14 |
| /29 | 255.255.255.248 | 3 | 6 |
| /30 | 255.255.255.252 | 2 | 2 |
Network and broadcast addresses
Two addresses in every subnet are reserved and cannot be given to a host.
- The network address — the address with all host bits set to 0. It names the network itself (the “first” address).
- The broadcast address — the address with all host bits set to 1. A packet sent here goes to every host in the subnet (the “last” address).
Every host address sits strictly between these two. That is exactly why the host formula subtracts 2.
Example: a /24 has h = 8 host bits, so 28 = 256 total addresses, and 256 − 2 = 254 usable hosts. A /26 has h = 6, so 26 = 64 total, and 64 − 2 = 62 usable hosts.
A full worked example
Take 192.168.10.45 with mask 255.255.255.0 (/24):
- Host bits: h = 32 − 24 = 8.
- Network address: set all host bits to 0 →
192.168.10.0. - Broadcast address: set all host bits to 1 →
192.168.10.255. - Usable host range:
192.168.10.1through192.168.10.254. - Usable hosts: 28 − 2 = 254.
| Role | Address | Note |
|---|---|---|
| Network | 192.168.10.0 | all host bits 0 — not usable |
| First host | 192.168.10.1 | first usable |
| Given host | 192.168.10.45 | inside the range |
| Last host | 192.168.10.254 | last usable |
| Broadcast | 192.168.10.255 | all host bits 1 — not usable |
Why subnet? (a teaser)
If every device in an organisation shared one huge Class A network, you would waste millions of addresses and every broadcast would interrupt every device. Subnetting splits one network block into smaller logical subnetworks. Each subnet has its own network address, broadcast address, and host range, which:
Reduces broadcast traffic
Broadcasts stay inside a smaller domain instead of reaching every device.
Improves security
Routers and ACLs can control traffic between subnets.
Uses addresses efficiently
Each subnet can be sized to its real need.
This lesson gives you the vocabulary — mask, prefix, network, broadcast, host count. The complete subnetting procedure (finding subnet boundaries across larger blocks and VLSM) is developed in a later week (Week 7). First, Lesson 7 shows the arithmetic that ties it all together: the bitwise AND.
Key terms
Subnet mask
A 32-bit value of contiguous leading 1s that separates the network and host portions of an address.
Network portion
The bits marked by 1s in the mask; identifies the subnet.
Host portion
The bits marked by 0s in the mask; identifies the device within the subnet.
Prefix / CIDR notation
Writing the mask as a slash plus the count of network bits, e.g. /24.
Network address
The address with all host bits 0; names the subnet and is not assigned to a host.
Broadcast address
The address with all host bits 1; reaches every host in the subnet and is not assigned to a host.
Usable hosts
2h − 2, where h = 32 − prefix.
Sources & references
- Postel, J. RFC 791: Internet Protocol (1981). Address and subnet structure.
- Braden, R. RFC 1122: Requirements for Internet Hosts — Communication Layers (1989).
- Rekhter, Y. et al. RFC 1918: Address Allocation for Private Internets (1996).
- Arkko, J., Cotton, M. & Vegoda, L. RFC 5737: IPv4 Address Blocks Reserved for Documentation (2010).
- Cotton, M. & Vegoda, L. RFC 5735: Special Use IPv4 Addresses (2010).
- Cheshire, S., Aboba, B. & Guttman, E. RFC 3927: Dynamic Configuration of IPv4 Link-Local Addresses (2005).
- Weil, J. et al. RFC 6598: IANA-Reserved IPv4 Prefix for Shared Address Space (2012).
- IANA. IPv4 Special-Purpose Address Registry.
- Cisco. CCNA (200-301) Exam Topics, Network Fundamentals (IP addressing and subnetting).
Review
Check what you have learned with these review questions.
Sources & references
- Postel, J. RFC 791: Internet Protocol (1981). Address and subnet structure. rfc-editor.org/rfc/rfc791.
- Braden, R. RFC 1122: Requirements for Internet Hosts — Communication Layers (1989). rfc-editor.org/rfc/rfc1122.
- Rekhter, Y. et al. RFC 1918: Address Allocation for Private Internets (1996). rfc-editor.org/rfc/rfc1918.
- Arkko, J., Cotton, M. & Vegoda, L. RFC 5737: IPv4 Address Blocks Reserved for Documentation (2010). rfc-editor.org/rfc/rfc5737.
- Cotton, M. & Vegoda, L. RFC 5735: Special Use IPv4 Addresses (2010). rfc-editor.org/rfc/rfc5735.
- Cheshire, S., Aboba, B. & Guttman, E. RFC 3927: Dynamic Configuration of IPv4 Link-Local Addresses (2005). rfc-editor.org/rfc/rfc3927.
- Weil, J. et al. RFC 6598: IANA-Reserved IPv4 Prefix for Shared Address Space (2012). rfc-editor.org/rfc/rfc6598.
- IANA. IPv4 Special-Purpose Address Registry. iana.org.
- Cisco. CCNA (200-301) Exam Topics, Network Fundamentals (IP addressing and subnetting). cisco.com.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.