How does a subnet mask divide an address?
Write the address and the mask in binary and line them up. Wherever the mask has a 1, the bit belongs to the network; wherever it has a 0, the bit belongs to the host. A mask of 255.255.255.0 is twenty-four ones followed by eight zeros, so for 192.0.2.77 the network is 192.0.2.0 and the host part is 77. A computer uses this to make one decision for every packet: is the destination on my own network, so I can deliver it directly, or somewhere else, so I hand it to the gateway?
What is CIDR notation?
Classless Inter-Domain Routing replaced the old class A, B and C system in 1993 and introduced the short form. Instead of writing 255.255.255.0, you append the number of network bits to the address: 192.0.2.0/24. Any length from /0 to /32 is valid, which lets networks be sized to need rather than to three fixed classes. Routing tables, firewall rules and cloud consoles all use the slash form, so it is worth knowing the common ones by heart.
How many addresses does each prefix hold?
| Prefix | Dotted mask | Total addresses | Usable hosts (classic rule) |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /26 | 255.255.255.192 | 64 | 62 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
| /31 | 255.255.255.254 | 2 | 2 on point-to-point links |
| /32 | 255.255.255.255 | 1 | A single host route |
The classic rule subtracts two from every block: the first address names the network and the last is the broadcast address. The formula is 2 raised to the number of host bits, minus two.
Why does a server link use a /31?
A link between a router and one server has exactly two ends. A /30 spends four addresses on it, two of them on a network and broadcast address that nothing on a point-to-point link needs. RFC 3021 lets a /31 drop both, so the two addresses become the gateway and the server. Every one of our machines is delivered this way: one public IPv4 on a /31, with the other address in the pair as its gateway. That saves addresses without changing anything you do on the box. IPv4 on a /31 shows how the config looks on each image.
How do I see and calculate masks on Linux?
ip -4 -br addr show
ip route show default
ipcalc 192.0.2.77/26 # Debian and Ubuntu: apt install ipcalc
python3 -c "import ipaddress as i; n=i.ip_network('192.0.2.64/26'); print(n.netmask, n.num_addresses, n[1], n[-2])"
The brief address listing shows each interface with its prefix length; the route command shows the gateway. On the Red Hat family, ipcalc comes from a different project with slightly different flags, so the Python one-liner is the portable fallback. The ip command has more address commands.
Where else do masks show up on a server?
- Firewall rules:
198.51.100.0/24in an allow rule means the whole office range, while/32means one address. - Tunnels: a WireGuard interface with 10.44.0.1/24 treats the other peers in that range as directly reachable over the tunnel.
- Application settings: trusted proxy lists, database host rules in
pg_hba.confand rate-limit exemptions all take CIDR blocks. - Virtual machines: a private bridge for guests on Proxmox usually gets a /24 such as 10.10.10.0/24 with the host as gateway and NAT outward.
How do I split a block into smaller subnets?
Each extra prefix bit halves the block. A /24 splits into two /25s, four /26s or eight /27s, and the boundaries always fall on multiples of the block size: a /26 can start at .0, .64, .128 or .192, never at .50. This matters when you plan addresses for virtual machines or containers on a single host, where you might give one bridge 10.20.0.0/26 for web guests and another 10.20.0.64/26 for databases. Keeping blocks aligned this way also lets a firewall rule cover a whole tier with one CIDR entry.
Is there a quick way to work out a mask in your head?
Learn the eight values one octet can take: 128, 192, 224, 240, 248, 252, 254 and 255, which correspond to one through eight network bits. For any prefix between /24 and /32, the last octet of the mask is simply the value for the bits beyond 24, and the block size is 256 minus that value. A /27 therefore has a final octet of 224 and blocks of 32 addresses. The same trick works in the third octet for prefixes between /16 and /24.
What goes wrong when a mask is wrong?
A mask that is too wide makes the host think distant addresses are local, so it sends ARP requests that nobody answers and the traffic never reaches the gateway. A mask that is too narrow sends local traffic to the gateway, which may or may not forward it back. On a /31 link, using /32 by mistake leaves the gateway unreachable unless a specific on-link route is added. When a reinstall or hand edit leaves a machine without network access, the mask is one of the first things to compare against the values in your panel.
Every Machine Ships With One IPv4 on a /31
| Server | Processor | Cores / threads | Memory | Storage | Network | Per month | Smallest order |
|---|---|---|---|---|---|---|---|
| E1 | Intel Xeon E3-1240 v3 | 4 / 8 | 16 GB DDR3 | 2x 240 GB SSD | 2x 1 Gbps | $30.52 | $91.56 (3 months) |
| S1 | Intel Xeon E-2276G | 6 / 12 | 64 GB DDR4 | 1x 1 TB NVMe | 2x 10 Gbps | $53.32 | $53.32 (1 month) |
| D1 | 2x Intel Xeon Gold 5315Y | 16 / 32 | 128 GB DDR4 | 2x 1 TB NVMe | 2x 25 Gbps | $202.94 | $202.94 (1 month) |
Keep Reading
IPv4 on a /31
Why each machine gets one public IPv4 on a /31 network, how the two addresses split between gateway and server, and how to configure it.
OpenIP address
What an IP address is, how IPv4 and IPv6 differ, public versus private ranges, CIDR notation and how traffic finds your server.
OpenStatic IP address
An IP address that stays the same, why servers need one, how a /31 point-to-point setup works and how to check the network config on Linux.
OpenThe ip command
Read addresses, links, routes and neighbors with ip, understand the /31 setup on our machines and make test changes without losing SSH.
OpenFAQ
Quick Answers
The first 24 bits of the address identify the network, leaving 8 bits for hosts. It equals the mask 255.255.255.0 and holds 256 addresses.
A point-to-point link only needs two addresses. RFC 3021 allows a /31 so both become usable: one for the gateway and one for the server.
Six under the classic rule: eight addresses minus the network and broadcast addresses.
Run ip -4 -br addr show. The number after the slash in each address is the prefix length.
Each machine comes with one public IPv4 on a /31. Plan services around that single address; a reverse proxy lets many sites share it.