Network security

Subnet Mask Calculator: How to Work Out Any IPv4 Subnet

Type in an address and a prefix, get the network, broadcast and host range. Here is what the calculator is doing, how to do it by hand, and which prefix to pick.

Cysoro Security TeamPublished · 8 min read
NETWORK SECURITY Subnet Mask Calculator Network, broadcast & host range in seconds 192.168.1.10/24 Network 192.168.1.0 Broadcast 192.168.1.255 Hosts .1 – .254 Usable 254 mask 255.255.255.0
Quick answer

A subnet mask calculator takes an IPv4 address and a subnet mask or CIDR prefix and returns the network address, broadcast address, first and last usable host, total address count and wildcard mask. For example, 192.168.1.10/24 belongs to network 192.168.1.0, broadcasts on 192.168.1.255, and offers 254 usable hosts from 192.168.1.1 to 192.168.1.254.

Key takeaways

  • A subnet mask splits a 32-bit IPv4 address into a network part and a host part; the CIDR prefix counts the network bits.
  • Usable hosts equal 2 to the power of the host bits, minus the network and broadcast addresses.
  • The most common home and office subnet is /24, which gives 254 usable hosts.

You type 192.168.1.10/24 into a calculator and it hands back a network address, a broadcast address and a range of usable hosts. Behind that instant answer is a small amount of binary arithmetic that anyone can learn. This guide explains what the calculator is doing, how to do the same math by hand, and which prefix to pick for a home or office network.

What does a subnet mask calculator do?

A subnet mask calculator takes an IP address and a subnet mask or CIDR prefix and returns the network address, broadcast address, first and last usable host, total address count and wildcard mask. It answers the question "which addresses belong to this subnet?" in one step, instead of you working through the binary math by hand.

You give it one of three inputs: an address with a CIDR prefix such as 192.168.1.10/24, an address with a dotted mask such as 192.168.1.10 255.255.255.0, or just a prefix to convert. The calculator then shows the full breakdown of the subnet that address sits in.

Network engineers use these tools when they plan VLANs, set up VPNs, write firewall rules and fix addressing mistakes. Home users meet them when a router asks for a subnet mask, or when two devices on the same Wi-Fi cannot see each other. You can check the address your own connection is using with our free what-is-my-IP tool.

What is a subnet mask?

A subnet mask is a 32-bit value that marks which bits of an IPv4 address belong to the network and which bits belong to individual hosts. The network bits are set to 1 and the host bits are set to 0. For example, 255.255.255.0 is 24 ones followed by 8 zeros, so the first three octets identify the network and the last octet identifies hosts.

Every IPv4 address is 32 bits long, written as four octets such as 192.168.1.10. Subnetting divides those 32 bits into two parts: the network portion, which identifies the subnet, and the host portion, which identifies individual devices inside it. Two devices are on the same subnet when their network portions match.

The mask itself is not an address and never appears as a destination. It is a rule for reading addresses. A device applies the mask to its own address with a bitwise AND to find its network address, and it uses that result to decide whether another device is local or must be reached through a gateway.

How do CIDR prefixes and subnet masks relate?

A CIDR prefix is the same information as a subnet mask, written as a count of leading 1 bits. The number after the slash in 192.168.1.0/24 says the first 24 bits are the network prefix, which is exactly the mask 255.255.255.0. RFC 4632, the document that defines classless addressing, describes a prefix as an address followed by a slash and the number of significant bits, in section 3.1.

Prefixes run from /0, the entire IPv4 address space, to /32, a single host. Each extra bit halves the size of the subnet. A /23 holds twice as many addresses as a /24, and a /25 holds half as many. This is why choosing a prefix is really choosing how many hosts you need.

CIDR prefixSubnet maskTotal addressesUsable hostsTypical use
/8255.0.0.016,777,21616,777,214Very large enterprise networks
/16255.255.0.065,53665,534Large office or campus networks
/20255.255.240.04,0964,094Mid-size site with room to grow
/24255.255.255.0256254Home networks and small offices
/25255.255.255.128128126Half of a /24, e.g. one floor
/26255.255.255.1926462Small department or VLAN
/27255.255.255.2243230Small team or lab network
/28255.255.255.2401614Point-of-sale or IoT segment
/29255.255.255.24886Tiny segment, e.g. printers
/30255.255.255.25242Router-to-router link

The usable host count is always two less than the total, because the first address is the network address and the last is the broadcast address. Neither can be assigned to a device. The one exception is a /31 point-to-point link, which has no broadcast address.

How a subnet mask splits an IPv4 address IP address 192 168 1 10 Subnet mask 255 255 255 0 Binary 11111111.11111111.11111111.00000000 Network part — 24 bits Host — 8 bits 192.168.1.10 / 255.255.255.0 = network 192.168.1.0/24, with 254 usable hosts.
One address, one mask: the first 24 bits name the network, the last 8 bits name the host. Illustration by Cysoro.

How do you calculate a subnet by hand?

You can work out any IPv4 subnet in four steps. Here is the math for 172.16.5.130/27, the same result a calculator produces, and the method works for any prefix.

Step 1: convert the prefix to a mask. A /27 means 27 network bits, so the mask is 255.255.255.224. The last octet is 11100000 in binary, which equals 224. The first three octets are full, so they are 255.

Step 2: find the block size. Subtract the interesting octet of the mask from 256: 256 minus 224 equals 32. Subnets in the last octet therefore start at 0, 32, 64, 96, 128, 160, 192 and 224.

Step 3: find the network address. Take the largest multiple of 32 that is less than or equal to 130. That is 128, so the network address is 172.16.5.128.

Step 4: find the broadcast address and host range. The next subnet starts at 160, so the broadcast address is one below it: 172.16.5.159. Usable hosts run from 172.16.5.129 to 172.16.5.158, which is 30 hosts in total.

Worked example: 172.16.5.130/27 1 Mask /27 = 255.255.255.224 last octet 11100000 2 Block size 256 − 224 = 32 blocks: 0, 32, 64, 96, 128, 160… 3 Network 130 falls in the 128 block, so the network is .128 4 Range broadcast .159 hosts .129–.158 30 usable hosts The block-size shortcut works for any prefix: 256 minus the interesting octet.
Four steps, one subnet: mask, block size, network address, host range. Illustration by Cysoro.

The shortcut in step 2 is the part worth memorizing. Find the octet where the mask is neither 255 nor 0 — the "interesting octet" — and subtract it from 256. That gives the spacing between subnets in that octet, and the network address is always a multiple of that spacing.

What is the difference between a subnet mask and a wildcard mask?

A wildcard mask is the subnet mask turned inside out. The mask has 1 bits for the network and 0 bits for the hosts, while the wildcard has 0 bits for the network and 1 bits for the hosts. To get it, subtract each octet of the mask from 255: 255.255.255.0 becomes 0.0.0.255, and 255.255.255.192 becomes 0.0.0.63.

Wildcard masks show up in Cisco access control lists and OSPF network statements, where they say which bits of an address must match exactly and which bits can vary. They are more flexible than subnet masks because their 1 bits do not have to form one block — but that flexibility is also why they confuse people.

Do not use a wildcard mask where a subnet mask belongs. A device configured with 0.0.0.255 as its subnet mask will not work, because a subnet mask must be a run of 1 bits followed by a run of 0 bits. The calculator shows both values so you can copy the right one into the right place.

How do you split a network into smaller subnets?

To split a network, borrow bits from the host portion by lengthening the prefix. Splitting 192.168.1.0/24 into /26s creates four subnets of 64 addresses each: 192.168.1.0/26, 192.168.1.64/26, 192.168.1.128/26 and 192.168.1.192/26. Each one has 62 usable hosts.

This is called variable length subnet masking, or VLSM, when the pieces are different sizes. You might give the guest Wi-Fi a /25 with 126 hosts, the printers a /28 with 14 hosts, and a router link a /30 with 2 hosts, all carved from the same /24. Right-sizing each subnet wastes fewer addresses than giving every segment a /24.

Plan before you cut. Write down how many hosts each segment needs, add room to grow, then pick the smallest prefix that covers each count. A segment that needs 40 hosts needs a /26 (62 usable), not a /27 (30 usable). If you run out of space later, renumbering is far more painful than planning.

What are the common subnetting mistakes?

Most subnetting errors come from one of five slips, and all of them are easy to check with a calculator before you apply a change.

  • Assigning the network or broadcast address to a host. In 192.168.1.0/24, .0 and .255 are reserved. A device given one of them will not communicate properly.
  • Using a mask with non-contiguous 1 bits. A mask such as 255.0.255.0 is invalid, because the 1 bits must come first in one block. Calculators reject it, but a typo in a router config may not.
  • Forgetting the gateway. Devices in different subnets need a router between them. Two correct subnets with no route between them still cannot talk.
  • Overlapping subnets. If 10.0.0.0/23 and 10.0.1.0/24 both exist, the second is inside the first. Traffic goes to the wrong place and faults are hard to trace.
  • Picking a prefix that is too small. A /28 holds 14 hosts. Add a fifteenth device and something has to move. Leave headroom of at least 20 percent.

Private address ranges are another common source of confusion. IANA reserves three blocks for private use: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. These addresses are not routable on the public internet, which is why your home router can use 192.168.1.0/24 while millions of other homes use the same range.

How do subnets improve network security?

Subnets limit how far an attacker can move. If every device sits in one flat /24, a compromised laptop can reach the printer, the file server and the camera system directly. Split the network into segments and a firewall or access list between them can block that lateral movement.

Good segmentation follows the job, not the floor plan. Put guest Wi-Fi on its own subnet with internet-only access, IoT devices on a subnet that cannot reach workstations, and servers on a subnet that only accepts connections from specific hosts. Each boundary is a place to enforce a rule.

Subnetting is not a substitute for encryption or authentication, but it is one of the cheapest controls in networking. It costs nothing, it uses the addressing you already have, and it turns a single breach into a contained incident instead of a network-wide one.

Our guide to securing your Wi-Fi covers the home side of this kind of segmentation.

For the office side, the small business cybersecurity checklist covers segmentation alongside backups, updates and device security.

The bottom line

A subnet mask calculator does in a second what takes a minute of binary arithmetic: it turns an address and a prefix into the network, broadcast and host range. Learn the four-step method once and you will understand the output instead of just trusting it.

Start with /24 for a home or small office, split it only when you have a reason, and check your work with the calculator before you change a live network.

You can confirm the address your own devices are using with the free what-is-my-IP tool.

To look up the names behind the addresses on your network, use the DNS lookup tool.

Frequently asked questions

What is the subnet mask for 192.168.1.0/24?

The subnet mask for a /24 is 255.255.255.0. The first 24 bits are network bits, set to 1, and the last 8 bits are host bits, set to 0. A /24 holds 256 addresses in total, with 254 usable for hosts.

How many usable hosts are in a /24 subnet?

A /24 subnet has 254 usable hosts. The formula is 2 to the power of the host bits, minus 2 for the network and broadcast addresses. A /24 has 8 host bits, so 2 to the power of 8 is 256, minus 2 gives 254.

What is the difference between a subnet mask and an IP address?

An IP address identifies one device on a network. A subnet mask identifies which part of that address is the network and which part is the host. The mask is not an address itself; it is the rule that splits the address into two parts.

What is a wildcard mask?

A wildcard mask is the inverse of a subnet mask: network bits are 0 and host bits are 1. For 255.255.255.0 the wildcard is 0.0.0.255. Wildcard masks are used in access control lists on routers and firewalls, not as subnet masks.

Can I use a subnet mask calculator for IPv6?

Yes, many calculators support IPv6, but the math is different. IPv6 addresses are 128 bits, subnets are usually /64, and there is no broadcast address. This guide covers IPv4, which is what most home and office networks still use.

What is the smallest usable subnet?

A /30 subnet gives two usable hosts and is the smallest block used for ordinary networks, often for a link between two routers. A /31 can be used for point-to-point links with two hosts and no broadcast address. A /32 is a single host address.

Sources

  1. IETF — RFC 4632: Classless Inter-domain Routing (CIDR)
  2. IANA — IPv4 Special-Purpose Address Space
  3. ARIN — IPv4 Private Address Space and Filtering
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 RFC 4632, the IANA IPv4 Special-Purpose Address Registry and ARIN's private address guidance.

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