IPv4 Addressing (3): Masks, Prefixes & Assignment
This is where the pieces click together. Given any host address and its mask, you will be able to state the network address, the broadcast address, the range of usable hosts, and how that host finds its way off its own network.
Mask and prefix are the same thing
A subnet mask is a 32-bit number with a run of 1s followed by a run of 0s. The 1s cover the network portion; the 0s cover the host portion. The prefix length is just the count of those leading 1s. So there are two notations for the same idea:
| Prefix | Mask (dotted-decimal) | Binary mask |
|---|---|---|
| /8 | 255.0.0.0 | 11111111.00000000.00000000.00000000 |
| /16 | 255.255.0.0 | 11111111.11111111.00000000.00000000 |
| /24 | 255.255.255.0 | 11111111.11111111.11111111.00000000 |
| /25 | 255.255.255.128 | 11111111.11111111.11111111.10000000 |
| /26 | 255.255.255.192 | 11111111.11111111.11111111.11000000 |
When the mask sits exactly on octet boundaries (/8, /16, /24), it is octet-aligned and matches a classful default. Prefixes like /25 and /26 split an octet and belong to subnetting — they are the bridge to Week 7.
Analysing a host address
Given a host address and its mask, three values follow directly. The mask tells you which bits are network and which are host; then you simply set the host bits to all-0 or all-1:
- Network address — copy the host address, then set every host bit to
0. (In practice: bitwise-AND the address with the mask.) - Broadcast address — copy the host address, then set every host bit
to
1. - Usable range — all addresses between them: the first usable is network + 1, and the last usable is broadcast − 1.
Three worked examples
| Host address | Network | Broadcast | First usable | Last usable | Usable |
|---|---|---|---|---|---|
| 192.168.1.77/24 | 192.168.1.0 | 192.168.1.255 | 192.168.1.1 | 192.168.1.254 | 254 |
| 10.0.0.5/8 | 10.0.0.0 | 10.255.255.255 | 10.0.0.1 | 10.255.255.254 | 16,777,214 |
| 172.16.0.200/16 | 172.16.0.0 | 172.16.255.255 | 172.16.0.1 | 172.16.255.254 | 65,534 |
Read the /8 case carefully: the host bits run across the last three octets, so the broadcast is
10.255.255.255 and the usable range spans from 10.0.0.1 to
10.255.255.254. Likewise the /16 broadcast is 172.16.255.255 — only the
last two octets vary, because the host portion is 16 bits wide.
The 2h − 2 formula box
The larger the prefix, the fewer host bits remain, and the smaller the network. For a /24, h = 8, so usable = 28 − 2 = 256 − 2 = 254. That is the classic Class C figure, and it is worth walking through once more as a concrete check:
/24 network: 192.168.1.0/24 Total addresses: 2^8 = 256 Network address: 192.168.1.0 (host bits all 0) Broadcast address: 192.168.1.255 (host bits all 1) First usable: 192.168.1.1 Last usable: 192.168.1.254 Usable hosts: 256 - 2 = 254
How addresses are assigned
A host can receive its IP configuration in one of two ways:
| Method | How it works | Best for |
|---|---|---|
| Static (manual) | An administrator types the IP, mask, and gateway on the device. | Routers, servers, printers, switches — devices needing a fixed address |
| Dynamic (DHCP) | A DHCP server leases an address automatically for a period. | PCs, phones, laptops — large numbers of end devices |
DHCP (Dynamic Host Configuration Protocol) hands out not just the IP address but also the subnet mask, the default gateway, and DNS server addresses, so a client can join the network with no manual configuration. The trade-off is that a leased address can change; static assignment avoids that but does not scale. Network infrastructure — routers, servers, and the gateway interfaces themselves — are normally configured statically.
! Manually assign an address to a router interface R1(config)# interface gigabitEthernet 0/0 R1(config-if)# ip address 192.168.1.1 255.255.255.0 R1(config-if)# no shutdown ! Configure a DHCP pool to lease addresses to clients R1(config)# ip dhcp pool LAN R1(dhcp-config)# network 192.168.1.0 255.255.255.0 R1(dhcp-config)# default-router 192.168.1.1
The default gateway
A host can reach any address in its own network directly through Layer 2. But when the destination is on a different network, the host cannot deliver the frame itself — it needs a router. The default gateway is the IP address of the router interface on the host’s own subnet, and it is the “way out” of the local network.
The host’s reasoning is simple: compare the destination with its own network/mask. If the destination is local, send directly (ARP for the destination MAC). If the destination is remote, send the frame to the gateway’s MAC address, but keep the packet’s destination IP set to the final host. The router forwards it onward. A host with a wrong or missing default gateway can talk to its neighbours but cannot reach the Internet or any other subnet — a very common troubleshooting symptom.
192.168.1.1 on 192.168.1.0/24. That is why the gateway and the first usable
host address so often coincide.Octet alignment and the bridge to Week 7
An octet-aligned mask is one whose 1s finish exactly on an octet boundary, such as /8, /16, or /24. These masks are easy to read because each octet is either all-1 (a full network byte) or all-0 (a full host byte). Classful defaults are always octet-aligned.
Masks such as /25, /26, or /27 are not octet-aligned: the network boundary falls inside an octet, so one octet is part network and part host. Recognising alignment tells you at a glance whether a network is classful or a subnet — and that is exactly where Week 7 picks up.
Bridge to Week 7: subnetting
You now have everything subnetting builds on: the address structure, the mask/prefix, the
2h − 2 rule, and the network/broadcast boundaries. Subnetting
is simply borrowing bits from the host portion to create smaller networks — turning one
/24 into, say, four /26s. That move is what lets us size networks precisely and
escapes the waste of fixed classful sizes described in Lesson 3. Week 7 develops the technique in full;
for now, make sure you can analyse a host address and apply the formula without hesitation.
Key terms
| Term | Meaning |
|---|---|
| Subnet mask | A 32-bit value with a run of 1s (network bits) then 0s (host bits). |
| Prefix length | The number of leading 1s in the mask, written /n. |
| Network address | The address with all host bits 0; it names the network. |
| Broadcast address | The address with all host bits 1; reaches every host in the network. |
| Usable hosts | 2h − 2, where h is the number of host bits. |
| Default gateway | The router interface on the local subnet that a host uses to reach other networks. |
| DHCP | Dynamic Host Configuration Protocol; assigns IP, mask, gateway, and DNS automatically. |
| Octet alignment | When a mask's network bits end exactly on an octet boundary (/8, /16, /24). |
Review
Check what you have learned with these review questions.
Sources & references
- Postel, J. RFC 791: Internet Protocol (1981), Section 2.3 (Addressing) and Section 3.2. rfc-editor.org/rfc/rfc791.
- Braden, R. RFC 1122: Requirements for Internet Hosts — Communication Layers (1989), Section 3.3 (address/mask handling). rfc-editor.org/rfc/rfc1122.
- Droms, R. RFC 2131: Dynamic Host Configuration Protocol (1997). rfc-editor.org/rfc/rfc2131.
- Rekhter, Y. et al. RFC 1918: Address Allocation for Private Internets (1996). rfc-editor.org/rfc/rfc1918.
- Cisco. CCNA (200-301) Exam Topics, IP Connectivity / IPv4 addressing and configuration. cisco.com.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.