Subnet Masks and CIDR Notation

What a Subnet Mask Does

A subnet mask is a 32-bit value that tells a device exactly which portion of an IP address is the network part and which part is the host part. It works by lining up against the IP address: wherever the mask has a 1, that bit belongs to the network; wherever it has a 0, that bit belongs to the host.

IP address:    192.168.1.10
Subnet mask:   255.255.255.0
Binary mask:   11111111.11111111.11111111.00000000
                <----------- network ----><-- host ->

CIDR Notation: A Shorter Way to Write the Same Thing

Instead of writing the full mask 255.255.255.0, CIDR notation simply counts the number of 1 bits and writes it after a slash: /24 means the first 24 bits are the network portion - exactly equivalent to 255.255.255.0.

CIDREquivalent subnet maskHost bits
/24255.255.255.08
/25255.255.255.1287
/26255.255.255.1926
/30255.255.255.2522

Calculating Usable Hosts from the Mask

The number of usable host addresses is 2^(host bits) - 2. Two addresses are always reserved: the very first (the network address itself) and the very last (the broadcast address) - neither can be assigned to an actual device.

/24  ->  8 host bits  ->  2^8 - 2  =  254 usable addresses
/26  ->  6 host bits  ->  2^6 - 2  =  62 usable addresses

Why Understanding This Matters

Every router, firewall rule and network design decision depends on correctly identifying which devices belong to the same network. Misreading a subnet mask is one of the most common sources of real-world "why can't these two devices talk to each other" networking problems.

Written by Lorens Mishra

Software Engineer Notes Management System Administrator

Discussion

0 comments
Sign in to join the discussion.

No comments yet. Be the first to say something.