Frequently Asked Questions

How do I calculate the number of hosts per subnet?

The formula is:

Usable hosts = 2^(host bits) − 2

Where host bits = 32 − prefix length (for IPv4).

You subtract 2 because the first address (all host bits = 0) is the network address and the last (all host bits = 1) is the broadcast address — neither can be assigned to a device.

PrefixHost bitsTotal addressesUsable hosts
/82416,777,21616,777,214
/161665,53665,534
/248256254
/257128126
/2666462
/2753230
/2841614
/29386
/30242
/31122*
/32011*

* /31 and /32 are special cases (RFC 3021) — no broadcast address exists, so both addresses in a /31 are usable for point-to-point links.

Example: 192.168.10.0/25 → host bits = 32 − 25 = 7 → 2⁷ − 2 = 126 usable hosts

What is CIDR notation and how does it work?

CIDR (Classless Inter-Domain Routing) notation writes an IP address followed by a slash and a prefix length: 192.168.1.0/24

The number after the slash tells you how many leading bits are the network portion. The remaining bits are for hosts.

How it maps to a subnet mask:

CIDRBinary maskDotted-quad mask
/811111111.00000000.00000000.00000000255.0.0.0
/1611111111.11111111.00000000.00000000255.255.0.0
/2411111111.11111111.11111111.00000000255.255.255.0
/2511111111.11111111.11111111.10000000255.255.255.128
/3011111111.11111111.11111111.11111100255.255.255.252

Why it exists: Before 1993, IP addresses were divided into fixed classes (A = /8, B = /16, C = /24), which wasted enormous amounts of address space. CIDR allows any prefix length from /0 to /32, so you can allocate exactly the size you need.

In IPv6, the same concept applies to 128-bit addresses with prefix lengths from /0 to /128 (e.g., 2001:db8::/64).

What is the difference between a subnet mask and CIDR?

They're the same thing in two different formats. A subnet mask and CIDR notation both describe the network/host boundary of an IP address — the only difference is how you write it.

Subnet Mask (dotted decimal)CIDR (prefix length)
Format255.255.255.128/25
What it says"These 32 bits are the mask""The first 25 bits are network"
Where you'll see itOS settings, legacy configsRouting tables, cloud consoles, modern docs

They convert directly:

255.255.255.128  →  11111111.11111111.11111111.10000000  →  25 ones  →  /25

Why CIDR won in practice:

When you still see dotted-decimal masks: Windows "View IP Properties" dialog, older Cisco/IOS configs, some ACLs and legacy documentation.

How do you calculate the number of hosts in a subnet?

Formula:

Usable hosts = 2^(host bits) − 2

Where host bits = 32 − prefix length.

Step-by-step for 192.168.10.0/25:

The "−2" accounts for the two reserved addresses (network and broadcast).

Reverse lookup (given a host count, find the prefix):

prefix = 32 − ceil(log2(required_hosts + 2))

e.g. need 50 hosts → log₂(52) ≈ 5.7 → round up to 6 → prefix = 32 − 6 = /26 (62 usable).

PrefixHost bitsUsable hosts
/248254
/257126
/26662
/27530
/28414
/2936
/3022

What is the difference between a network address and a broadcast address?

These are the two "bookend" addresses in every subnet — the first and last. Neither can be assigned to a device.

Network AddressBroadcast Address
PositionFirst address in the subnetLast address in the subnet
Host bitsAll 0All 1
PurposeIdentifies the subnet itself (used in routing tables)Sends a packet to every device on the subnet
CalculateIP AND masknetwork OR wildcard
Example (/24)192.168.1.0192.168.1.255
Example (/25)192.168.10.0192.168.10.127

In short: the network address says *"this is the subnet"*; the broadcast address says *"talk to everyone in this subnet at once."

Special cases: