Skip to content

IPv4, CIDR, masks and hosts

IPv4 Subnetting Explained: CIDR, Subnet Masks and Hosts

Subnetting splits an IPv4 network into smaller networks. Once you can read a subnet mask in binary, you can work out the prefix, the number of usable hosts and the network address of any IP in seconds. This is core material for CompTIA Network+ and Cisco CCNA.

IPv4 addresses

An IPv4 address is 32 bits, written as four 8-bit octets in decimal. Each octet is 0–255.

192.168.10.77

11000000.10101000.00001010.01001101

Network and host

Every address has two parts. The left bits name the network; the right bits name a device (host) on it. The subnet mask marks the split: 1s for the network, 0s for the host.

11111111
255
11111111
255
11111111
255
00000000
0

255.255.255.0

CIDR prefixes

A prefix like /26 is a short way to write the mask: it counts the 1s. 26 ones is 8 + 8 + 8 + 2, so the last octet is 11000000 = 192.

11111111
255
11111111
255
11111111
255
11000000
192

/26 = 255.255.255.192

Learn the last-octet values. They are the place values added up from the left:

Subnet prefixes /24 to /32 with mask, block size and usable hosts
PrefixSubnet maskBlockUsable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
/31255.255.255.25422
/32255.255.255.25511

Counting hosts

Host bits = 32 − prefix. They give 2host bits addresses, but two are reserved: the first is the network address and the last is the broadcast.

/26: 32 − 26 = 6 → 2⁶ − 2 = 62

  • /31 links have 2 usable addresses, a /32 is a single host.

Finding the network

Use the block size: 256 minus the mask value in the interesting octet (the first one that isn't 255). Networks start at multiples of the block size.

  1. 1192.168.10.77/26 → mask 255.255.255.192
  2. 2Block size: 256 − 192 = 64
  3. 3Blocks: 0, 64, 128, 192. 77 falls in 64–127
  4. 4Network 192.168.10.64, broadcast 192.168.10.127

In binary this is just an AND: keep the network bits of the address and set the host bits to 0.

Subnet calculator

Drag the slider to change the prefix and enter any IP to see its network, broadcast and host range.

/2626 network bits
6 host bits
11111111
255
11111111
255
11111111
255
11000000
192
Subnet mask
255.255.255.192
Usable hosts
62
Block size
64
Network
192.168.10.64/26
Broadcast
192.168.10.127
Host range
192.168.10.65 – 192.168.10.126

Where you'll see it

  • Home Wi-Fi: 192.168.1.0/24
  • Cloud networks (VPCs) and firewall rules
  • Networking exams like CompTIA Network+ and CCNA

Frequently asked questions

What does /24 mean?
/24 is a CIDR prefix: the first 24 bits of the address are the network part. As a subnet mask it is 255.255.255.0, leaving 8 host bits.
How many usable hosts are in a /26?
A /26 has 32 − 26 = 6 host bits, so 2⁶ = 64 addresses. Two are reserved (network and broadcast), leaving 62 usable hosts.
What is the subnet mask for /26?
26 ones is 8 + 8 + 8 + 2, so the mask is 255.255.255.192 (the last octet is 11000000 = 192).
How do you find the network address?
Work out the block size (256 minus the mask value in the interesting octet), list the multiples of the block size, and find the block your IP falls in. The start of that block is the network address and the last address is the broadcast.
How many usable hosts does a /31 or /32 have?
A /31 has 2 usable addresses (used for point-to-point links) and a /32 is a single host.

Practise Subnetting as a game

The Binary Game turns this lesson into quick rounds with a breakdown after every answer. Free to start on iPhone and iPad.