正在加载,请稍候…

CIDR and Subnet Masks Explained: What /24 Actually Means

A plain-English guide to CIDR notation and subnet masks — what /24, /16, /8 mean, how to calculate usable hosts, and how to split a network into subnets without a calculator.

What Does /24 Actually Mean?

If you've seen addresses like 192.168.1.0/24 or 10.0.0.0/8 and wondered what the number after the slash means, here's the short answer: it's the number of bits used for the network portion of the address. The remaining bits identify individual hosts on that network.

A /24 means 24 bits are the network address, leaving 8 bits for hosts — which gives you 256 addresses (254 usable, since the first and last are reserved).

IP Addresses Are Just 32-Bit Numbers

An IPv4 address like 192.168.1.100 is four groups of 8 bits (octets). In binary:

192  = 11000000
168  = 10101000
1    = 00000001
100  = 01100100

192.168.1.100 = 11000000.10101000.00000001.01100100

A subnet mask marks which part of this 32-bit number is the network and which part is the host. The mask is a sequence of 1s followed by a sequence of 0s:

/24 mask = 11111111.11111111.11111111.00000000
         = 255.255.255.0

Network bits (covered by 1s): 192.168.1 Host bits (covered by 0s): 100

CIDR Prefix to Subnet Mask Reference

CIDR Subnet Mask Hosts Typical Use
/8 255.0.0.0 16,777,214 Large enterprise, Class A
/16 255.255.0.0 65,534 Medium enterprise, Class B
/24 255.255.255.0 254 Small office, home network
/25 255.255.255.128 126 Half a /24
/26 255.255.255.192 62 Department subnet
/27 255.255.255.224 30 Small team
/28 255.255.255.240 14 Server cluster
/29 255.255.255.248 6 Point-to-point + servers
/30 255.255.255.252 2 Point-to-point link
/32 255.255.255.255 1 Single host route

The formula for usable hosts: 2^(32 - prefix) - 2. Subtract 2 for the network address (all host bits = 0) and broadcast address (all host bits = 1).

Breaking Down a /24 Network

Take 192.168.10.0/24:

  • Network address: 192.168.10.0 (host bits all zero — not assignable)
  • First usable host: 192.168.10.1
  • Last usable host: 192.168.10.254
  • Broadcast address: 192.168.10.255 (host bits all one — not assignable)
  • Total usable hosts: 254

How to Split a /24 into Smaller Subnets

You can divide a /24 into smaller subnets by borrowing bits from the host portion. Each additional bit you borrow doubles the number of subnets and halves the number of hosts per subnet.

Split 192.168.10.0/24 into four /26 subnets:

Subnet Range Usable Hosts
192.168.10.0/26 .0 – .63 .1 – .62 (62 hosts)
192.168.10.64/26 .64 – .127 .65 – .126 (62 hosts)
192.168.10.128/26 .128 – .191 .129 – .190 (62 hosts)
192.168.10.192/26 .192 – .255 .193 – .254 (62 hosts)

Each /26 has 62 usable hosts. Four subnets × 62 hosts + 8 reserved addresses = 256 total. The math always adds up.

Private Address Ranges

Three ranges are reserved for private networks (RFC 1918) and are not routable on the public internet:

Range CIDR Addresses
10.0.0.0 – 10.255.255.255 10.0.0.0/8 16.7 million
172.16.0.0 – 172.31.255.255 172.16.0.0/12 1 million
192.168.0.0 – 192.168.255.255 192.168.0.0/16 65,536

Home routers use 192.168.x.x. AWS VPCs default to 10.0.0.0/16. Docker uses 172.17.0.0/16 by default.

Reading Cloud Network Configs

When you create a VPC or virtual network in AWS, GCP, or Azure, CIDR notation defines its size:

AWS VPC:          10.0.0.0/16    → 65,534 addresses
  Subnet A:       10.0.1.0/24   → 251 usable (AWS reserves 5 per subnet)
  Subnet B:       10.0.2.0/24   → 251 usable
  Subnet C:       10.0.3.0/24   → 251 usable

Docker default:   172.17.0.0/16
  Container range: 172.17.0.2 – 172.17.255.254

AWS reserves 5 addresses per subnet (first 4 + last 1), so a /24 in AWS gives 251 usable addresses, not 254.

Checking if an IP Is in a Subnet

import ipaddress

network = ipaddress.ip_network('192.168.10.0/24')
ip = ipaddress.ip_address('192.168.10.42')

print(ip in network)           # True
print(network.num_addresses)   # 256
print(list(network.hosts())[:3])  # [192.168.10.1, .2, .3]
// No built-in, but easy to implement
function ipToInt(ip) {
  return ip.split('.').reduce((acc, octet) => (acc << 8) | parseInt(octet), 0) >>> 0;
}

function isInSubnet(ip, cidr) {
  const [net, bits] = cidr.split('/');
  const mask = ~(0xFFFFFFFF >>> parseInt(bits)) >>> 0;
  return (ipToInt(ip) & mask) === (ipToInt(net) & mask);
}

console.log(isInSubnet('192.168.10.42', '192.168.10.0/24')); // true

→ Use the IPv4 Subnet Calculator to instantly break down any CIDR block — shows network address, broadcast, host range, and all subnets.