Cactus

Subnet calculator

Enter an IPv4 or IPv6 address with a prefix (CIDR) to see the network and broadcast addresses, the usable host range, the mask, and what kind of address it is.

How this works
  • This is pure math — Cactus works it out from the address and prefix and never connects to anything.
  • What you enter is used to show this result and isn't stored.

Also accepts a netmask (192.168.1.0 255.255.255.0) or a bare address.

What is a subnet calculator?

A subnet calculator takes an IP address and a CIDR prefix - or a subnet mask - and works out the details for you: the network address, the broadcast address, the range of usable host addresses, the subnet and wildcard masks, and what kind of address it is. It saves doing the binary by hand, which is handy when you're planning a network, splitting a block into smaller subnets, or writing a firewall rule.

IPv4 CIDR reference table (/0 to /32)

Every IPv4 prefix with its subnet mask, wildcard mask, total addresses, and usable hosts. Usable hosts is the total minus the network and broadcast addresses - except /31 (a point-to-point link) and /32 (a single host), which don't reserve them.

CIDR Subnet mask Wildcard Total addresses Usable hosts Common use
/0 0.0.0.0 255.255.255.255 4,294,967,296 4,294,967,294
/1 128.0.0.0 127.255.255.255 2,147,483,648 2,147,483,646
/2 192.0.0.0 63.255.255.255 1,073,741,824 1,073,741,822
/3 224.0.0.0 31.255.255.255 536,870,912 536,870,910
/4 240.0.0.0 15.255.255.255 268,435,456 268,435,454
/5 248.0.0.0 7.255.255.255 134,217,728 134,217,726
/6 252.0.0.0 3.255.255.255 67,108,864 67,108,862
/7 254.0.0.0 1.255.255.255 33,554,432 33,554,430
/8 255.0.0.0 0.255.255.255 16,777,216 16,777,214 Very large network (old Class A)
/9 255.128.0.0 0.127.255.255 8,388,608 8,388,606
/10 255.192.0.0 0.63.255.255 4,194,304 4,194,302
/11 255.224.0.0 0.31.255.255 2,097,152 2,097,150
/12 255.240.0.0 0.15.255.255 1,048,576 1,048,574
/13 255.248.0.0 0.7.255.255 524,288 524,286
/14 255.252.0.0 0.3.255.255 262,144 262,142
/15 255.254.0.0 0.1.255.255 131,072 131,070
/16 255.255.0.0 0.0.255.255 65,536 65,534 Large network (old Class B)
/17 255.255.128.0 0.0.127.255 32,768 32,766
/18 255.255.192.0 0.0.63.255 16,384 16,382
/19 255.255.224.0 0.0.31.255 8,192 8,190
/20 255.255.240.0 0.0.15.255 4,096 4,094
/21 255.255.248.0 0.0.7.255 2,048 2,046
/22 255.255.252.0 0.0.3.255 1,024 1,022
/23 255.255.254.0 0.0.1.255 512 510
/24 255.255.255.0 0.0.0.255 256 254 Typical small LAN (old Class C)
/25 255.255.255.128 0.0.0.127 128 126
/26 255.255.255.192 0.0.0.63 64 62
/27 255.255.255.224 0.0.0.31 32 30
/28 255.255.255.240 0.0.0.15 16 14
/29 255.255.255.248 0.0.0.7 8 6
/30 255.255.255.252 0.0.0.3 4 2 Point-to-point link (classic)
/31 255.255.255.254 0.0.0.1 2 2 Point-to-point link (RFC 3021)
/32 255.255.255.255 0.0.0.0 1 1 Single host (loopback, host route)

IPv6 prefix reference

IPv6 doesn't reserve a network or broadcast address, so every address in a block is usable. A /64 is the standard size for a single network; the larger blocks below are what a site or an ISP is typically assigned.

Prefix Addresses per block Number of /64s Typical use
/128 1 A single host
/127 2 Point-to-point link
/64 2^64 1 One LAN - the standard subnet size
/56 2^72 256 A small site (home or branch)
/48 2^80 65,536 A larger site or organization
/32 2^96 4,294,967,296 An ISP or very large allocation

How to calculate a subnet mask by hand

  1. Write the prefix as that many 1s followed by 0s across 32 bits. A /26 is 26 ones, then 6 zeros.
  2. Group the bits into four octets and convert each to decimal. Those bits give 255.255.255.192 - that's the subnet mask.
  3. The host bits (the zeros) set the block size: 2 to the power of the number of host bits. Six host bits is 2^6 = 64 addresses.
  4. Subtract 2 for the network and broadcast addresses to get usable hosts: 64 - 2 = 62 (the exceptions are /31 and /32).

Worked example: 192.168.10.0/26 has a mask of 255.255.255.192, 64 addresses, 62 usable hosts (192.168.10.1 to 192.168.10.62), and a broadcast address of 192.168.10.63.

Common uses

  • Planning a home lab or office network and splitting it into VLANs.
  • Choosing CIDR blocks for a cloud network, like an AWS VPC or an Azure VNet.
  • Writing firewall rules or access lists that cover an exact range of addresses.
  • Sizing a point-to-point link and picking the right prefix for the number of devices.

Frequently asked questions

What is CIDR notation (the "/24" part)?

The number after the slash is how many bits at the front of the address are fixed for the network - the rest are free for hosts. So /24 locks the first 24 bits (255.255.255.0) and leaves 8 bits, or 256 addresses, for the block.

How many usable hosts does a subnet have?

For IPv4 it's the total addresses minus two - one for the network address and one for the broadcast - so a /24 has 256 - 2 = 254. The exceptions are /31 (2 usable, a point-to-point link) and /32 (a single host). IPv6 doesn't reserve those two, so every address in the block is usable.

What's the difference between the network and broadcast address?

The network address is the first in the block (all host bits 0) and names the subnet itself; the broadcast address is the last (all host bits 1) and reaches every host at once. Neither is assigned to a device, which is why they don't count as usable hosts on IPv4.

What is a wildcard mask, and how is it different from a subnet mask?

A wildcard mask is the subnet mask flipped - subtract each octet from 255. A /26 mask of 255.255.255.192 becomes a wildcard of 0.0.0.63. A subnet mask marks the network bits; a wildcard marks the host bits, which is why Cisco ACLs and OSPF use it to match a range.

How do I convert a subnet mask to CIDR notation (and back)?

Count the 1-bits in the mask written in binary - that count is the CIDR number. 255.255.255.0 is twenty-four 1s, so /24; 255.255.255.240 is /28; 255.255.255.192 is /26. The other way, /24 means the first 24 bits are 1s, which fills the first three octets: 255.255.255.0. The reference table above lists every mask and its prefix.

What subnet mask do I need for a given number of hosts?

Pick the smallest prefix whose usable-host count covers what you need, remembering IPv4 loses two addresses per subnet. About 500 hosts needs a /23 (510 usable); 100 hosts fits a /25 (126); 1000 hosts needs a /22 (1022). The rule is usable hosts = 2^(32 - prefix) - 2.

How many smaller subnets fit inside a larger one?

Every extra bit of prefix doubles the number of subnets, so the count is 2 raised to the difference in prefix length. A /16 holds 256 /24s (2^8); a /24 holds 8 /27s (2^3); a /22 holds 4 /24s. The same math runs in reverse when you aggregate routes.

How many addresses are in an IPv6 /64, and how do /56 and /48 compare?

A /64 holds 2^64 addresses - about 18.4 quintillion - and IPv6 reserves no network or broadcast address, so every one is usable. A /64 is the standard size for a single LAN. A /56 is 256 /64s and a /48 is 65,536 /64s, which is why ISPs hand those larger blocks to sites that need many subnets.

When would I use a /30, /31, or /32?

A /30 gives 2 usable hosts and was the classic choice for a router-to-router link. A /31 (RFC 3021) squeezes the same point-to-point link into just 2 addresses with no waste, and modern gear supports it. A /32 is a single host - one exact address - used for loopbacks, host routes, and firewall rules that target one machine.

Which IP ranges are private (RFC 1918)?

Three IPv4 blocks are reserved for private networks and never routed on the public internet: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. Home and office LANs almost always use one of these. The IPv6 equivalent is the unique-local range fc00::/7 (in practice fd00::/8).

How do I tell if two IP addresses are on the same subnet?

Apply the subnet mask to both addresses - keep only the network bits - and compare. If both give the same network address, they are on the same subnet and can talk directly; if not, traffic goes through a router. Enter either address with its prefix above and the tool shows the exact network and host range.