Subnetting and CIDR Basics — Understand IP Address Division from Scratch

"So how many addresses does a /24 actually give me?" "What is the difference between a subnet mask and CIDR?" — these are common stumbling blocks in network design. In this article we start from the 32-bit structure of an IPv4 address and build up to how the network and host portions are split, subnet masks and prefix length, the math of usable host counts, and a step-by-step example of actually splitting a subnet — all with verified, concrete examples.

1. What an IPv4 address is — 32 bits and four octets

An IPv4 address is a 32-bit number. We divide it into four groups of 8 bits, write each as a decimal number (0–255), and join them with . to get the familiar notation. Each 8-bit group is called an octet.

For example, 192.168.10.1 looks like this in binary.

Notation1st octet2nd octet3rd octet4th octet
Decimal192168101
Binary11000000101010000000101000000001

One octet is 8 bits, so it can represent 2^8 = 256 values, that is 0–255. Across all 32 bits you can express 2^32 ≈ 4.3 billion addresses.

2. The network portion and the host portion

An IP address is broadly split into two parts. The leading network portion tells you "which network (subnet) this is," and the trailing host portion tells you "which device within that network." As a postal analogy, the network portion is the "town and street," and the host portion is the "room number" within that address.

Devices that share the same network portion can communicate directly without going through a router. Conversely, to reach a host with a different network portion, traffic goes through a router. In other words, deciding "how far the network portion extends" is exactly what it means to split (subnet) a network.

3. Subnet masks and prefix length (CIDR)

What tells you "how far the network portion extends" is the subnet mask. The mask is 32 bits, and it marks the network portion with 1s and the host portion with 0s. The 1s are always packed contiguously from the left.

For instance, if the network portion is the leading 24 bits, the mask looks like this.

NotationValue
Binary11111111.11111111.11111111.00000000
Decimal (dotted notation)255.255.255.0
CIDR notation (prefix length)/24

CIDR notation (Classless Inter-Domain Routing) is a shorthand that writes the number of consecutive leading 1s in the mask as a slash and a number, such as /24. 255.255.255.0 and /24 mean exactly the same thing. For example, 192.168.10.1/24 means "the address 192.168.10.1, with the leading 24 bits as the network portion."

A handy rule: the prefix length n is simply "the number of bits in the network portion." Then 32 − n is the number of bits in the host portion. For a /24, the host portion is 32 − 24 = 8 bits.

4. Network address, broadcast address, and usable host count

Within a single subnet, two addresses carry special meaning.

Therefore, in a subnet with prefix length n, the usable host count that can actually be assigned to devices is given by the following formula.

Usable host count = 2^(32 − n) − 2
(subtract the network address and the broadcast address — 2 in total — from the total number of addresses 2^(32−n))

Take 192.168.10.0/24 as an example. The host portion is 8 bits, so the total number of addresses is 2^8 = 256, and the usable hosts number 256 − 2 = 254. Concretely, it works out as follows.

RoleAddress
Network address192.168.10.0
First usable host192.168.10.1
Last usable host192.168.10.254
Broadcast address192.168.10.255

The /31 and /32 exceptions

The − 2 rule above has exceptions.

5. Private addresses (RFC1918) and IP classes

Separate from the global addresses used on the internet, private addresses are reserved for use inside an organization's network. RFC1918 defines the following three ranges. On home or office LANs, you can use these ranges freely.

Range (CIDR)Address rangeOld class
10.0.0.0/810.0.0.010.255.255.255Class A equivalent
172.16.0.0/12172.16.0.0172.31.255.255Class B equivalent
192.168.0.0/16192.168.0.0192.168.255.255Class C equivalent

Because these addresses are not used on the internet, they are translated to a global address by NAT when communicating externally.

The former IP classes (A / B / C)

Before CIDR became widespread, the class was fixed by the leading bits of the address. Knowing this as historical background also makes the "old class" column in the table above easier to understand.

ClassLeading octet rangeDefault network portionMask
Class A0–1278 bits/8 (255.0.0.0)
Class B128–19116 bits/16 (255.255.0.0)
Class C192–22324 bits/24 (255.255.255.0)
Today the standard is CIDR (classless), where you choose the prefix length freely according to the number of hosts you need, regardless of class. It is enough to understand classes as a purely historical distinction.

6. A subnetting example — splitting a /24 into four /26 subnets

Suppose you want to split one /24 (254 hosts) into smaller pieces, one per department. By borrowing 2 bits from the host portion and giving them to the network portion, the prefix length becomes 24 + 2 = /26, and the subnet is divided into 2^2 = 4 pieces.

A /26 has a host portion of 32 − 26 = 6 bits, so the total number of addresses per subnet is 2^6 = 64, with 64 − 2 = 62 usable hosts. Splitting 192.168.10.0/24 into four yields the following.

SubnetNetwork addressUsable host rangeBroadcast
1st192.168.10.0/26.1.62192.168.10.63
2nd192.168.10.64/26.65.126192.168.10.127
3rd192.168.10.128/26.129.190192.168.10.191
4th192.168.10.192/26.193.254192.168.10.255

Notice that the network addresses go up by 64 each time: 0, 64, 128, 192. This matches the total number of addresses in one subnet (64). This "increment (block size)" is given by 2^(32−n) and is the single most useful landmark when doing subnet calculations.

Common prefixes and host counts

CIDRSubnet maskHost bitsTotal addressesUsable hosts
/24255.255.255.08256254
/25255.255.255.1287128126
/26255.255.255.19266462
/27255.255.255.22453230
/28255.255.255.24041614
/29255.255.255.248386
/30255.255.255.252242
/31255.255.255.254122 (RFC3021)
/32255.255.255.255011 (single host)
Free Tool Check it for real with the Subnet Calculator Just enter an IP address and prefix length to instantly compute the network address, broadcast address, usable host range, and host count. Great for double-checking your subnet splits.

Frequently Asked Questions (FAQ)

How many usable hosts are there in a /24?

A /24 has an 8-bit host portion, so the total number of addresses is 2^8 = 256. Of those, the first one (the network address) and the last one (the broadcast address) cannot be assigned to devices, so the number of actually usable hosts is 256 - 2 = 254.

What is the difference between CIDR and a subnet mask?

Both express the length of the network portion and mean the same thing. A subnet mask is written as four octets such as 255.255.255.0, while CIDR notation is a shorthand that writes the number of consecutive 1s in that mask as a slash and a number, such as /24. So 255.255.255.0 and /24 are equivalent.

What is a private address?

These are addresses reserved by RFC1918 for use inside an organization's network, in three ranges: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. They are not used on the public internet and can be used freely on home or office LANs. When communicating externally, they are translated to a global address by NAT.

← Back to the Tech Blog list