A router’s settings page asks for 255.255.255.0. A cloud console asks for /24. They are the same thing written two ways, and once the binary underneath is visible, the arithmetic behind every subnet question, how many hosts, which addresses, whether two devices can talk directly, comes down to counting bits. Every number below was calculated with Python 3.13’s standard ipaddress module, so each one can be checked by running the same calls.
An address has two halves
Network and host
An IPv4 address is 32 bits, written as four decimal numbers from 0 to 255. Some of those bits on the left say which network the device is on. The rest say which device it is on that network. The subnet mask is the instruction that says where the split falls.
Take a laptop at 192.168.1.130 with the mask 255.255.255.192. Written out in binary:
address 11000000.10101000.00000001.10000010 192.168.1.130
mask 11111111.11111111.11111111.11000000 255.255.255.192
AND 11000000.10101000.00000001.10000000 192.168.1.128
Every 1 in the mask marks a network bit, every 0 a host bit. A bitwise AND of the address and the mask keeps the network bits and zeroes the rest, and the result, 192.168.1.128, is the network address. A device does exactly this calculation when it decides whether a destination is local or has to go through the router.
The slash is a count
The mask above has 26 ones in a row. CIDR notation just writes that number: 192.168.1.130/26. RFC 4632, the current specification for Classless Inter-Domain Routing, defines the prefix as an address followed by a slash and a decimal value between 0 and 32 giving the number of significant bits. Its own example is 172.16.0.0/16, with a 255.255.0.0 mask, where the /16 means the most significant 16 bits are ones and the least significant 16 are zeros.
Since a mask is always a run of ones followed by zeros, the two forms carry exactly the same information. /26 is shorter to type.

The table everyone ends up memorizing
Masks, sizes and usable hosts
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 512 | 510 |
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
The pattern is one rule. A prefix of n leaves 32 minus n host bits, and that many bits can count 2 to that power of addresses. A /24 leaves 8 bits, 2 to the 8th is 256. Each step of one in the prefix halves the block.
Why two are subtracted
In each block, the address with all host bits set to zero is the network address, and the one with all host bits set to one is the broadcast address. Neither can be given to a device. For 192.168.1.130/26 those are 192.168.1.128 and 192.168.1.191, leaving 192.168.1.129 through 192.168.1.190, which is 62 hosts.
Splitting a network: subnetting
Four /26s from one /24
Borrowing bits from the host side and giving them to the network side cuts a block into smaller ones. A /24 borrowing two bits becomes four /26s:
| Subnet | Network | Broadcast | Hosts |
|---|---|---|---|
| 192.168.1.0/26 | .0 | .63 | .1 to .62 |
| 192.168.1.64/26 | .64 | .127 | .65 to .126 |
| 192.168.1.128/26 | .128 | .191 | .129 to .190 |
| 192.168.1.192/26 | .192 | .255 | .193 to .254 |
Each boundary falls on a multiple of 64, the block size. That is the fastest mental shortcut there is: in a /26 the network addresses in the last octet are 0, 64, 128 and 192, and any address belongs to the highest one that does not exceed it. 130 lands in the block starting at 128.
The question that matters day to day
Changing the mask changes who counts as a neighbor. Two devices, 192.168.1.60 and 192.168.1.70:
| Mask | Same subnet? |
|---|---|
| /24 (255.255.255.0) | Yes |
| /26 (255.255.255.192) | No: .60 is in 0–63, .70 is in 64–127 |
Under the /26, the device at .60 will not send to .70 directly. It will hand the packet to its default gateway. If that gateway sits in a different subnet or the router has no route between the two, the traffic simply goes nowhere, and a printer that worked yesterday is unreachable today. A mismatched mask on one machine is one of the more common causes of “it pings from some computers and not others.”

Joining networks: aggregation
Why CIDR was invented
Before CIDR, IPv4 used fixed classes. RFC 4632 records the two problems that broke that system: Class B space was running out because a Class B was too large for most organizations and a Class C too small, and global routing tables were growing faster than routers and operators could handle. In the class scheme, Class A corresponds to /8 and Class C to /24. CIDR let a network be any power-of-two size in between.
The RFC states the outcome directly: the community chose to deprecate the Class A/B/C network address assignment system. Terms like “Class C network” still turn up in documentation and home router menus, usually meaning “a /24.”
One route instead of many
The other half of CIDR is combining blocks. The RFC’s example is a provider holding 10.24.0.0/13 that hands out smaller pieces such as 10.24.0.0/21 and 10.24.16.0/20 to customers, then announces the single /13 to the rest of the Internet. Checked by calculation, the /13 runs from 10.24.0.0 to 10.31.255.255, 524,288 addresses, and both customer blocks fall inside it.
The same works at home scale. Four adjacent /24s, 192.168.0.0 through 192.168.3.0, collapse into one route: 192.168.0.0/22. But 192.168.1.0/24 and 192.168.2.0/24 do not combine, even though they sit side by side. A /23 has to start on a multiple of 2 in the third octet, and 1 is not one. Aggregation only works on blocks that line up on the larger block’s boundary.
The address ranges a home network uses
RFC 1918
Home and office networks almost always use addresses from three blocks reserved by RFC 1918 in February 1996:
| Block | Range | Size |
|---|---|---|
| 10.0.0.0/8 | 10.0.0.0 – 10.255.255.255 | 16,777,216 |
| 172.16.0.0/12 | 172.16.0.0 – 172.31.255.255 | 1,048,576 |
| 192.168.0.0/16 | 192.168.0.0 – 192.168.255.255 | 65,536 |
The RFC’s rule for them is that routing information about private networks shall not be propagated on inter-enterprise links. The same addresses are reused in millions of separate networks, and a router doing network address translation stands between each one and the public Internet.
The /12 catches people
The middle block is the one that gets misread. It does not cover all of 172.x.x.x. It stops at 172.31.255.255. Python’s ipaddress module agrees: 172.31.255.1 reports as private and 172.32.0.1 does not. A network numbered in 172.32.0.0 is using someone else’s public address space.

The edge cases: /31 and /32
Two addresses, both usable
By the subtract-two rule, a /31 would have zero hosts. For links with exactly two ends, such as a connection between two routers, that rule was dropped. RFC 3021, from December 2000, allows 31-bit prefixes on point-to-point links, so that each one uses two addresses instead of four. Its example: a network with 500 such links saves 1,000 addresses. With a 31-bit mask, the RFC says, the two addresses MUST be interpreted as host addresses, and there is no network or broadcast address.
Python follows the RFC: the hosts of 10.0.0.0/31 come back as 10.0.0.0 and 10.0.0.1.
A single address
A /32 is one address and nothing else. It shows up in firewall rules and access lists to mean exactly one machine, and in routing tables for a host route.
Checking the math without doing it by hand
On the machine itself
ip -4 addr show on Linux prints each interface’s address already in CIDR form, for example inet 192.0.2.2/24 brd 192.0.2.255, with the broadcast address beside it.
Python, three lines
import ipaddress
n = ipaddress.ip_interface('192.168.1.130/26').network
print(n, n.netmask, n.broadcast_address, n.num_addresses)
192.168.1.128/26 255.255.255.192 192.168.1.191 64
One detail of the module is a useful check on typing errors. Asking for a network with host bits set, ipaddress.ip_network('192.168.1.130/26'), raises ValueError: 192.168.1.130/26 has host bits set. A network address has to be the bottom of its block. ip_interface is the call for “this device’s address and its mask.”
The module also prints a mask’s inverse, the wildcard or host mask some firewall and router syntaxes use instead. For a /26 it is 0.0.0.63: the same split, with the ones and zeros swapped.
Sources
- RFC 4632, “Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan,” August 2006: https://www.rfc-editor.org/rfc/rfc4632.html
- RFC 1918, “Address Allocation for Private Internets,” February 1996: https://www.rfc-editor.org/rfc/rfc1918.html
- RFC 3021, “Using 31-Bit Prefixes on IPv4 Point-to-Point Links,” December 2000: https://www.rfc-editor.org/rfc/rfc3021.html
