Network security

Subnet Mask Cheat Sheet: CIDR, Hosts and Masks for /8 to /32

A subnet mask splits an IP network into smaller networks. This cheat sheet gives you every CIDR prefix, mask and host count in one place, with the formulas to work out any subnet.

Cysoro Security TeamPublished · 8 min read
CIDR • MASK • HOSTS/24 255.255.255.0 254/25 255.255.255.128 126/26 255.255.255.192 62/27 255.255.255.224 30/30 255.255.255.252 2Usable hosts = total − 2 NETWORK SECURITY Subnet maskcheat sheet Every CIDR, mask and host count.
Quick answer

A /24 subnet mask is 255.255.255.0, with 256 total addresses and 254 usable hosts. In general, a prefix of length N leaves 32 minus N host bits, giving 2 to the power of 32 minus N total addresses and two fewer usable hosts, because one address is the network address and one is the broadcast address.

Key takeaways

  • A /24 mask is 255.255.255.0 with 254 usable hosts, a /25 has 126, a /26 has 62, and a /30 has 2.
  • Usable hosts equal total addresses minus 2, except for /31 point-to-point links and /32 host routes.
  • The magic number, 256 minus the mask octet, tells you where the next subnet starts.

A subnet mask is the number that tells a device which part of an IP address is the network and which part is the host. Learn to read it once, and you can work out any network size, any host count, and any subnet boundary in seconds.

What is a subnet mask?

A subnet mask is a 32-bit number, written as four decimal octets, that splits an IPv4 address into a network part and a host part. The 1 bits mark the network part, and the 0 bits mark the host part.

For example, in 192.168.1.10 with mask 255.255.255.0, the first three octets are the network, 192.168.1.0, and the last octet identifies the host, 10. Every device on that network shares the same network part and differs in the host part.

CIDR notation writes the same idea more compactly. The number after the slash is the count of 1 bits in the mask, so 192.168.1.0/24 means the same as mask 255.255.255.0. TP-Link's subnet mask guide explains the same mapping, and it is the form you will see in routers, firewalls and cloud consoles.

Subnet mask cheat sheet: the full CIDR table

This is the table to bookmark. It maps every common prefix to its mask, wildcard mask, total addresses and usable hosts, using the standard rule that usable hosts are total addresses minus the network and broadcast addresses.

CIDRSubnet maskWildcard maskTotal addressesUsable hosts
/8255.0.0.00.255.255.25516,777,21616,777,214
/16255.255.0.00.0.255.25565,53665,534
/20255.255.240.00.0.15.2554,0964,094
/22255.255.252.00.0.3.2551,0241,022
/23255.255.254.00.0.1.255512510
/24255.255.255.00.0.0.255256254
/25255.255.255.1280.0.0.127128126
/26255.255.255.1920.0.0.636462
/27255.255.255.2240.0.0.313230
/28255.255.255.2400.0.0.151614
/29255.255.255.2480.0.0.786
/30255.255.255.2520.0.0.342
/31255.255.255.2540.0.0.122
/32255.255.255.2550.0.0.011

The values above match the Linuxize CIDR cheatsheet, which lists every prefix from /0 to /32 with the same address and host counts. The most-used rows are /24, /25, /26, /27 and /30, so learn those five first and look up the rest.

Three rows deserve a special note. A /24 gives 254 hosts and is the default size of a home or small-office network. A /30 gives 2 hosts and is the classic point-to-point link between two routers. A /26 gives 62 hosts and is the usual answer when a /24 is wasteful but a /27 is too tight.

How do I read a subnet mask?

Read a mask octet by octet. Each octet is 8 bits, and the decimal value tells you how many of those bits are set to 1: 255 is 8 bits, 254 is 7, 252 is 6, 248 is 5, 240 is 4, 224 is 3, 192 is 2, 128 is 1, and 0 is none.

Add the bits across the four octets to get the CIDR prefix. For 255.255.255.192, that is 8 plus 8 plus 8 plus 2, which is 26, so the mask is /26. For 255.255.240.0, it is 8 plus 8 plus 4 plus 0, which is 20, so the mask is /20.

How a mask splits an address: 192.168.1.10 /24 Network part — 24 bits 192.168.1. same for every device here Host part — 8 bits 10 identifies this one device Mask 255.255.255.0 = 24 one bits, then 8 zero bits Network address .0 • Usable hosts .1 to .254 • Broadcast .255 The mask, not the address, decides where the network ends.
Network part, host part, and the three special addresses in a /24. Illustration by Cysoro.

The network address is the first address in the subnet, with all host bits set to 0, and the broadcast address is the last address, with all host bits set to 1. Neither can be assigned to a host, which is why usable hosts are always total addresses minus 2 in a normal subnet.

What are the subnetting formulas?

Four formulas cover almost every subnetting question. Memorize them and you can work out any prefix without a calculator.

  • Total addresses: 2 to the power of host bits, where host bits equal 32 minus the prefix. A /24 has 8 host bits, so 2 to the power of 8 is 256 addresses.
  • Usable hosts: total addresses minus 2, for prefixes /0 to /30. A /26 has 64 addresses, so 62 usable hosts.
  • Block size: 256 minus the mask octet where the prefix ends. For /27, the mask is 255.255.255.224, so 256 minus 224 is 32.
  • Number of subnets: 2 to the power of the new prefix minus the old prefix. Splitting a /24 into /26 subnets gives 2 to the power of 2, or 4 subnets.

The wildcard mask is 255.255.255.255 minus the subnet mask. For /26, that is 0.0.0.63. The magic number is the same idea in one octet: 256 minus the mask octet, which tells you the step between subnets. For /26, the magic number is 64, so subnets start at .0, .64, .128 and .192.

Four formulas, one worked example: /26 Total addresses = 2^(32 - 26) = 2^6 = 64 Usable hosts = 64 - 2 = 62 hosts Magic number = 256 - 192 = 64 — subnets at .0, .64, .128, .192 Wildcard = 255.255.255.255 - mask = 0.0.0.63 Work one example by hand and the formulas stick.
The four subnetting formulas, worked through for a /26. Illustration by Cysoro.

Two exceptions break the minus-2 rule. A /31 has 2 addresses and both are usable on point-to-point links, under RFC 3021, because there is no need for a network or broadcast address when only two devices share the link. A /32 is a single host route, with 1 address and 1 usable host.

How many hosts do I need? Picking the right mask

Pick the smallest subnet that fits your hosts, with room to grow. A subnet that is too small forces a renumbering later, and a subnet that is too large wastes addresses and makes broadcast traffic noisier.

Hosts neededHost bitsMaskUsable hosts
Up to 22/302
Up to 63/296
Up to 144/2814
Up to 305/2730
Up to 626/2662
Up to 1267/25126
Up to 2548/24254
Up to 5109/23510
Up to 1,02210/221,022

To use the table, find the first row whose usable hosts cover your count, then use that mask. For 40 hosts, that is a /26 with 62 usable hosts. For 200 hosts, that is a /24 with 254 usable hosts. Always leave headroom: a subnet that is exactly full on day one is a problem by the end of the year.

Check your own network first with the what is my IP tool to see your current address, then look at your router's settings to see the mask it uses. Most home routers use /24, and most small offices do too.

How do I subnet a /24 into four /26 networks?

Subnetting a /24 into four /26 networks is the classic worked example, and it shows the whole method in one go. Start with 192.168.1.0/24 and borrow 2 bits from the host part to make the new prefix /26.

  1. Find the block size. For /26, the mask is 255.255.255.192, so the magic number is 256 minus 192, which is 64.
  2. List the subnets. Starting at .0 and stepping by 64: 192.168.1.0/26, 192.168.1.64/26, 192.168.1.128/26 and 192.168.1.192/26.
  3. Find the ranges. The first subnet runs from .0 to .63, with usable hosts .1 to .62 and broadcast .63. The second runs from .64 to .127, with usable hosts .65 to .126 and broadcast .127.
  4. Repeat for the rest. The third subnet is .128 to .191, usable .129 to .190, broadcast .191. The fourth is .192 to .255, usable .193 to .254, broadcast .255.
  5. Assign them. Give one subnet to staff, one to guests, one to printers and smart devices, and keep one spare.

That is VLSM in miniature: one /24, four equal subnets, no addresses wasted. For unequal needs, use different sizes instead, such as one /25 for 100 hosts, one /26 for 50 hosts, and two /27 subnets for 25 hosts each, which still adds up to one /24. Our guide to how to secure your Wi-Fi shows why separating guests from staff matters once the subnets exist.

What are the private IP ranges?

Private IP ranges are reserved for internal networks and are not routed on the public internet. Your home and office networks use them, and your router translates them to a public address when you go online.

RangeCIDRAddressesTypical use
10.0.0.0 to 10.255.255.25510.0.0.0/816,777,216Large corporate networks
172.16.0.0 to 172.31.255.255172.16.0.0/121,048,576Medium networks, Docker defaults
192.168.0.0 to 192.168.255.255192.168.0.0/1665,536Home and small-office networks

Most home routers use 192.168.0.0/24 or 192.168.1.0/24, which is one /24 slice of the 192.168.0.0/16 private range. Large companies use 10.0.0.0/8 because it gives room for thousands of subnets. If you see an address in one of these ranges, it is internal, and it will not work as a public address.

Do not use a public range for an internal network, and do not use a private range on a public-facing server. Both mistakes cause routing problems that are hard to diagnose, because the address looks valid until traffic tries to leave the network.

What are common subnet mask mistakes?

Most subnetting mistakes come from forgetting the network and broadcast addresses, mixing up the mask and the wildcard, or using a mask that does not match the gateway.

  • Counting 256 hosts in a /24: there are 256 addresses, but only 254 usable hosts. The .0 and .255 addresses are reserved.
  • Using a wildcard as a mask: 0.0.0.255 is the wildcard for /24, not the mask. The mask is 255.255.255.0.
  • Wrong gateway: the gateway must be inside the same subnet as the host. A host at 192.168.1.10/24 cannot use a gateway at 192.168.2.1.
  • Overlapping subnets: two subnets that share an address range will route traffic to the wrong place. Check the ranges before you assign them.
  • Forgetting IPv6: IPv6 uses prefixes too, but with 128 bits. A typical home IPv6 assignment is /64, which is far larger than any IPv4 subnet.
Subnet mask mistakes to avoid Counting 256 hosts in a /24 — it is 254 usable Using the wildcard 0.0.0.255 as if it were the mask Putting the gateway outside the host's subnet Creating two subnets that overlap Check the range, the gateway and the broadcast address before you save.
Four mistakes that cause most subnetting problems. Illustration by Cysoro.

When a device cannot reach its gateway, the mask is the first thing to check. A wrong mask makes the device think a local address is remote, or a remote address is local, and either way the traffic goes to the wrong place. For a wider network checklist, see our small business cybersecurity checklist.

The bottom line

Keep this cheat sheet close: /24 is 255.255.255.0 with 254 hosts, /25 has 126, /26 has 62, /27 has 30, and /30 has 2. The formulas do the rest, and the magic number tells you where each subnet starts.

Check your current network with the free DNS lookup tool to see how your addresses resolve, then use the table above whenever you plan a new subnet instead of guessing the mask.

Frequently asked questions

What is the subnet mask for a /24?

The subnet mask for a /24 is 255.255.255.0. It has 256 total addresses and 254 usable hosts, from .1 to .254 in the last octet, with .0 as the network address and .255 as the broadcast address.

How many hosts are in a /26 subnet?

A /26 subnet has 64 total addresses and 62 usable hosts. Its mask is 255.255.255.192, its wildcard mask is 0.0.0.63, and its block size is 64, so subnets start at .0, .64, .128 and .192.

How do I convert a subnet mask to CIDR?

Count the 1 bits in the mask. The mask 255.255.255.0 has 24 one bits, so it is /24. The mask 255.255.240.0 has 20 one bits, so it is /20. Each 255 octet is 8 bits, 254 is 7, 252 is 6, 248 is 5, 240 is 4, 224 is 3, 192 is 2 and 128 is 1.

What is the difference between total addresses and usable hosts?

Total addresses include the network address and the broadcast address, which cannot be assigned to a host. Usable hosts are total addresses minus 2. The exceptions are /31, which has 2 usable addresses on point-to-point links, and /32, which is a single host route.

What is a wildcard mask?

A wildcard mask is the inverse of a subnet mask: 255.255.255.255 minus the mask. For a /26, the mask is 255.255.255.192 and the wildcard is 0.0.0.63. Wildcard masks are used in access control lists and some routing configurations.

What subnet mask should a home network use?

Most home networks use /24, or 255.255.255.0, which gives 254 usable hosts and is more than enough for a home. A /25 or /26 is a better choice if you want to split a home network into separate subnets for guests or smart devices.

What is VLSM?

VLSM, or Variable Length Subnet Masking, means using different subnet sizes inside one network, so each subnet gets only the addresses it needs. For example, a /24 can hold four /26 subnets, or one /25, one /26 and two /27 subnets, instead of wasting a full /24 on a small group.

Sources

  1. Linuxize — CIDR and Subnet Mask Cheatsheet
  2. TP-Link — What Is a Subnet Mask and How Does It Work?
  3. Networking Signal — CIDR to Subnet Mask Converter
  4. OpenVPN — Subnet Calculator: IPv4 and IPv6 CIDR Tool
  5. ComputingForGeeks — Subnetting Cheat Sheet: Masks, Hosts and VLSM
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against the Linuxize CIDR cheatsheet, TP-Link's subnet mask guide and the OpenVPN subnet calculator tables.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free