Subnet Masks and CIDR Notation
- Networking Fundamentals & OSI Model
- TCP/IP Model
- Network Topologies
- IP Addressing & Subnetting
- Routing Algorithms & Protocols
- Switching Concepts
- Transport Layer Protocols (TCP & UDP)
- Application Layer Protocols
- Network Security & Firewalls
- Wireless Networking & Wi-Fi
- Network Address Translation (NAT)
- DNS Deep Dive
- Congestion Control & Flow Control
- Error Detection & Correction
- Network Devices
- VPN & Tunneling
- Load Balancing & CDN Networking
- Socket Programming
- Network Troubleshooting Tools
- Physical Layer & Transmission Media
- Data Link Layer & MAC Addressing
- Ethernet Protocol
- ARP (Address Resolution Protocol)
- ICMP Protocol
- Unicast, Multicast, Broadcast and Anycast
- Proxy Servers
- Port Numbers Reference
- Network Performance Metrics
- Quality of Service (QoS)
- Software-Defined Networking (SDN)
- HTTP/2 and HTTP/3 Overview
- 5G and Mobile Networks
- IoT Networking Basics
- VoIP Networking Basics
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.
| CIDR | Equivalent subnet mask | Host bits |
|---|---|---|
| /24 | 255.255.255.0 | 8 |
| /25 | 255.255.255.128 | 7 |
| /26 | 255.255.255.192 | 6 |
| /30 | 255.255.255.252 | 2 |
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 addressesWhy 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.