Addressing and Subnet Formats · Topic 2 of 3
IPv4 Addresses, Subnet Masks and Slash Notation
Learn how an IPv4 address and subnet mask work together, how slash notation and a subnet calculator help, and what a broadcast domain is in a network.
- 5 min
- Includes a diagram
- An IPv4 address has 32 bits, written as four decimal octets.
- The subnet mask separates the network part from the host part.
- Slash notation counts the 1 bits in the mask, so 255.255.255.0 is /24.
What it is
An IPv4 address identifies a device, and the subnet mask says which part of the address names the network.
An IPv4 address has 32 bits. It is written as four decimal numbers, called octets, separated by dots, for example 192.168.1.77.
Splitting a large network into smaller ones is called subnetting. Smaller networks are easier to manage and keep broadcast traffic under control.
How it works
The mask marks the leading bits that belong to the network, and the remaining bits identify the host.
Subnet mask and slash notation
A subnet mask is a 32 bit value. Where the mask has 1 bits, the address belongs to the network. Where it has 0 bits, the address belongs to the host.
Slash notation, also called the prefix length, counts the 1 bits. A mask of 255.255.255.0 has 24 one bits, so it is written /24. The address and prefix are written together as 192.168.1.0/24.
| Prefix | Subnet mask | Addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /30 | 255.255.255.252 | 4 | 2 |
Network, broadcast and host addresses
Each subnet has three kinds of address.
- The network address has all host bits set to 0. It names the subnet and is not given to a device.
- The broadcast address has all host bits set to 1. A packet sent to it reaches every host in the subnet.
- The addresses in between are the usable host addresses.
The number of usable hosts is two to the power of the host bits, minus 2. For a /26 there are 6 host bits, so 64 minus 2 gives 62 usable hosts.
A worked example
Take the host 192.168.1.77/26. A /26 splits the last octet into blocks of 64, starting at 0, 64, 128 and 192.
The address 77 falls in the block that starts at 64. So the network address is 192.168.1.64, the broadcast address is 192.168.1.127, and the usable range is 192.168.1.65 to 192.168.1.126.
Using a subnet calculator
A subnet calculator is a tool that does this arithmetic for you. You enter an address and a prefix, and it shows the mask, network address, broadcast address and host range. It is a good way to check your own work, and you should still be able to do small examples by hand.
Broadcast domains
A broadcast domain is the group of devices that receive each other's broadcasts. A broadcast stays inside its own subnet.
A switch forwards broadcasts to all its ports, so everything on one switch and one VLAN is in the same broadcast domain. A router does not forward broadcasts. Each router interface therefore sits in a separate broadcast domain.
Smaller broadcast domains mean less unwanted traffic. This is a main reason for subnetting.
What to remember for the exam
Seven facts cover most questions on this topic.
- An IPv4 address has 32 bits, written as four decimal octets.
- The subnet mask separates the network part from the host part.
- Slash notation counts the 1 bits in the mask, so 255.255.255.0 is /24.
- The network address has all host bits 0. The broadcast address has all host bits 1.
- Usable hosts equal two to the power of the host bits, minus 2.
- A subnet calculator shows the mask, network, broadcast and host range from an address and prefix.
- A router separates broadcast domains. A switch does not.
Memorise the masks for /24, /25, /26, /27, /28 and /30. They cover most exam questions.
Common mistakes
These four errors appear again and again.
Giving a device the network or broadcast address. Both are reserved in a normal subnet, so only the addresses between them are usable.
Forgetting to subtract two. A /24 has 256 addresses but 254 usable hosts.
Counting the prefix from the wrong end. The slash number is the count of network bits, not host bits.
Putting two hosts with different masks on one link. They disagree about which addresses are local, and communication can fail.
Two devices in the same subnet must use the same mask. A mismatch can make some addresses look remote when they are local.
Check yourself
Work through these three questions.
What does /24 mean and what is its mask?
It means the first 24 bits are the network part. The mask is 255.255.255.0.
How many usable host addresses are in a /27?
A /27 has 5 host bits, which gives 32 addresses. After subtracting the network and broadcast addresses, 30 are usable.
What separates broadcast domains?
A router separates them, because it does not forward broadcasts.
Topic 2 of 3 in Addressing and Subnet Formats
Test yourself on Addressing and Subnet Formats
The full Cisco CCST 100-150 Networking question bank has 749 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.