CompoundPage

Subnet Calculator

The subnet calculator gives the network, broadcast, mask and usable host range for an IPv4 address and prefix, including /31 point-to-point links (RFC 3021) and single-host /32s.

0 to 32. A /24 is a 255.255.255.0 mask.

Network192.168.1.0/24

Network address The address with every host bit set to zero.
192.168.1.0/24
Netmask 24 one-bits followed by 8 zero-bits.
255.255.255.0
Wildcard mask
0.0.0.255
Broadcast address Every host bit set to one, so not usable as a host address.
192.168.1.255
Usable host range
192.168.1.1 - 192.168.1.254
Usable hosts 2^8 addresses, less the network and the broadcast.
254
Total addresses
256
Scope A reserved range, so not routable on the public internet.
private (RFC 1918, 192.168/16)
Binary netmask
11111111 11111111 11111111 00000000

How the Subnet Calculator works

An IPv4 address is 32 bits, written as four decimal bytes because that is easier to say out loud than a ten-digit number. A subnet splits those 32 bits into a network part and a host part, and the prefix length (the number after the slash) is how many leading bits belong to the network. A /24 gives 24 bits to the network and 8 to hosts, which is where the familiar 254-usable-address block comes from.

Everything else follows mechanically. The netmask is the prefix written out as bits: 24 ones then 8 zeros, which reads as 255.255.255.0. The network address is the entered address with every host bit forced to zero, which is why 192.168.1.37/24 and 192.168.1.200/24 describe the same network: the host part is masked away. The broadcast address is every host bit forced to one. Those two are reserved, which is the origin of the "two to the host bits, minus two" rule for usable addresses.

That rule has two exceptions, the /31 and the /32, where every address is usable.

Whether an address is routable on the public internet depends on which reserved block it falls in, and the scope names that block: the RFC 1918 private ranges, loopback, link-local for when DHCP fails, or carrier-grade NAT, which an ISP uses when it has run out of public addresses.

Subnet Calculator FAQ

How many usable hosts are in a /24?

254. A /24 has 8 host bits, so 256 addresses, less one for the network address and one for the broadcast. The same arithmetic gives 126 for a /25, 62 for a /26, 30 for a /27, 14 for a /28, 6 for a /29 and 2 for a /30.

How many usable addresses does a /31 have?

Two, not zero. RFC 3021 defines a /31 as having no network or broadcast address, so both of its addresses are assignable. It exists for point-to-point links, where the alternative was spending a /30 (four addresses) to connect two router interfaces.

What is a /32?

A single address. It is used for loopback interfaces, for host routes, and anywhere a configuration needs to name exactly one machine. Its usable count is 1: there is no network or broadcast address to subtract.

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

They are inverses of each other and carry the same information. 255.255.255.0 and 0.0.0.255 describe the same /24. Netmasks are used nearly everywhere; wildcard masks are what Cisco access lists and OSPF network statements expect, and passing one where the other is wanted is a classic misconfiguration.

Is 255.0.255.0 a valid subnet mask?

No. A netmask must be a run of ones followed by a run of zeros with nothing interleaved, because the prefix length is defined as a count of leading bits. Non-contiguous masks were permitted in some very old equipment and are not valid under CIDR.

Which address ranges are private?

10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16, defined by RFC 1918. Note the middle one: the private block is 172.16 through 172.31, so 172.32.0.1 is a public address despite looking like it should not be. Also reserved are 127/8 for loopback, 169.254/16 for link-local and 100.64/10 for carrier-grade NAT.

Related calculators

Embed this calculator
<div id="compoundpage-subnet-calculator"></div>
<script src="https://compoundpage.com/embed/subnet-calculator.js" async></script>

The same calculation as JSON