What an IP address is made of
An IPv4 address is 32 bits, written as four numbers from 0 to 255, like 192.168.10.77. Each number is one byte, called an octet.
Those 32 bits are split into two parts. The first part names the network. The rest names the host, the single device on that network.
The /26 at the end, called the CIDR prefix, says how many bits belong to the network. Here it's 26, so 6 bits are left for hosts.
The four things you always find
- Network address: every host bit set to 0. It names the subnet.
- Broadcast address: every host bit set to 1. A message sent here reaches everyone in the subnet.
- Usable host range: everything between those two.
- Number of usable hosts: 2host bits − 2. The 2 are the network and broadcast addresses.
The subnet cheat sheet
| Prefix | Mask | Block size | Usable hosts |
|---|---|---|---|
| /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 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
The fast way: block size
You don't have to write out all 32 bits. Use this shortcut instead.
- Find the octet where the mask stops being 255. For /26 that's the fourth octet, with mask 192.
- Block size = 256 − that mask number. Here, 256 − 192 = 64.
- Subnets start at multiples of the block size: 0, 64, 128, 192.
- Find the multiple at or just below your number. 77 falls in the block that starts at 64.
- So the network is 192.168.10.64. The next block starts at 128, so the broadcast is 127.
The usable hosts run from .65 to .126, and there are 64 − 2 = 62 of them.
Try it yourself
Type any IPv4 address and its prefix, then press Solve. You'll see the binary AND worked out, plus the block-size method as a second way.
Solved examples
Example 1: a /26 network
Question: Find the network address, broadcast address and usable host range of 192.168.10.77/26.
- Write the given values
- Write the IP address in binary (8 bits per number)
- Build the subnet mask: 26 ones, then 6 zeros
- Network address = IP AND mask (a bit stays 1 only if both bits are 1)
- Broadcast address: keep the network bits and set every host bit to 1
- Count the addresses and usable hosts
There is also another method, shown after the solution: the block-size method (no binary).
- Write the given values
IP = 192.168.10.77 p = 26 - Write the IP address in binary (8 bits per number)
192 168 10 77 11000000 10101000 00001010 01001101 - Build the subnet mask: 26 ones, then 6 zeros
11111111.11111111.11111111.11000000 = 255.255.255.192
- Network address = IP AND mask (a bit stays 1 only if both bits are 1)
11000000.10101000.00001010.01001101 (IP) & 11111111.11111111.11111111.11000000 (mask) ─────────────────────────────────── 11000000.10101000.00001010.01000000 = 192.168.10.64
- Broadcast address: keep the network bits and set every host bit to 1
11000000.10101000.00001010.01111111 = 192.168.10.127
The last 6 bits are host bits. - Count the addresses and usable hosts
Total = 232 − 26 = 26 = 64 Usable = 64 − 2 = 62 We take away 2: the network address and the broadcast address can't be given to a device.
Fast way used in exams: find the "interesting" octet, the one where the mask is not 255 or 0.
- Block size = 256 − mask value in octet 4
= 256 − 192 = 64 Subnets in that octet start at 0, 64, 128, 192 … - Find the block that holds 77
Start = ⌊77 ÷ 64⌋ × 64 = 64 End = 64 + 64 − 1 = 127 Octet 4 of the network address is 64 and of the broadcast address is 127. Octets after it are 0 (network) and 255 (broadcast). This matches the answer above.
Example 2: a /20 network (the third octet)
Question: How many usable hosts are there in 10.4.17.200/20, and what is its network address?
- Write the given values
- Write the IP address in binary (8 bits per number)
- Build the subnet mask: 20 ones, then 12 zeros
- Network address = IP AND mask (a bit stays 1 only if both bits are 1)
- Broadcast address: keep the network bits and set every host bit to 1
- Count the addresses and usable hosts
There is also another method, shown after the solution: the block-size method (no binary).
- Write the given values
IP = 10.4.17.200 p = 20 - Write the IP address in binary (8 bits per number)
10 4 17 200 00001010 00000100 00010001 11001000 - Build the subnet mask: 20 ones, then 12 zeros
11111111.11111111.11110000.00000000 = 255.255.240.0
- Network address = IP AND mask (a bit stays 1 only if both bits are 1)
00001010.00000100.00010001.11001000 (IP) & 11111111.11111111.11110000.00000000 (mask) ─────────────────────────────────── 00001010.00000100.00010000.00000000 = 10.4.16.0
- Broadcast address: keep the network bits and set every host bit to 1
00001010.00000100.00011111.11111111 = 10.4.31.255
The last 12 bits are host bits. - Count the addresses and usable hosts
Total = 232 − 20 = 212 = 4096 Usable = 4096 − 2 = 4094 We take away 2: the network address and the broadcast address can't be given to a device.
Fast way used in exams: find the "interesting" octet, the one where the mask is not 255 or 0.
- Block size = 256 − mask value in octet 3
= 256 − 240 = 16 Subnets in that octet start at 0, 16, 32, 48 … - Find the block that holds 17
Start = ⌊17 ÷ 16⌋ × 16 = 16 End = 16 + 16 − 1 = 31 Octet 3 of the network address is 16 and of the broadcast address is 31. Octets after it are 0 (network) and 255 (broadcast). This matches the answer above.
In the /20 example the mask stops in the third octet (240), so the block size, 16, applies there. 17 falls in the block 16 to 31. That's why the network is 10.4.16.0 and the broadcast is 10.4.31.255.
Common mistakes
- Forgetting the − 2. A /26 has 64 addresses but only 62 usable hosts.
- Using the wrong octet. The block size applies to the octet where the mask isn't 255 or 0.
- Leaving later octets alone. For the network address, every octet after the interesting one becomes 0. For broadcast, they become 255.
Private address ranges
Three ranges are kept for home and office networks and never appear on the open internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Your home Wi-Fi almost surely uses one of them.
Practice questions
Work them out with the block-size method, then load each into the calculator to check.
A host has address 172.16.45.14 with mask 255.255.255.240 (/28). Find its subnet and broadcast address.
Show the answer
network 172.16.45.0, broadcast 172.16.45.15
Find the network and broadcast address of 192.168.1.130/25, and the number of usable hosts.
Show the answer
network 192.168.1.128, broadcast 192.168.1.255, 126 hosts