Skip to content
Technologynetworking

IP Subnet Calculator

IPv4 subnet arithmetic, network, broadcast, mask and usable range. Handles the /31 and /32 special cases, which most subnet calculators get wrong.

Also called: ip subnet mask calculator, network address calculator.

Network address
192.168.1.128

192.168.1.128/26. Usable range 192.168.1.129 to 192.168.1.190, broadcast 192.168.1.191. 62 usable addresses out of 64.

Subnet mask
255.255.255.192
Broadcast address
192.168.1.191
First usable host
192.168.1.129
Last usable host
192.168.1.190
Total addresses
64
Usable hosts
62
Method and background

How this is calculated

The network address is the IP bitwise-ANDed with the mask; the broadcast is the IP ORed with the inverted mask. The minus two removes those two addresses from the usable count. Except on a /31, where RFC 3021 defines a point-to-point link with no broadcast and both addresses usable, and on a /32, which is a single host route.

addresses = 2^(32-prefix); usable = addresses - 2
p
Prefix length

Full derivation: Subnetting, and the two addresses you cannot use

Worked examples

Each of these is asserted on every build. If a change to the engine ever moved one of these answers, the build would fail before the page could print it.

a /26 inside a private range

IPv4 address
192.168.1.130
Prefix length (/n)
26

Network address192.168.1.128

DRV-019: 2^6 - 2, verified by hand against the mask

Open this example

a /31 has two usable addresses, not zero

IPv4 address
10.0.0.4
Prefix length (/n)
31

Network address10.0.0.4

RFC 3021 point-to-point exception

Open this example

an invalid address is rejected

IPv4 address
999.1.1.1
Prefix length (/n)
24

Network addressNot a valid IPv4 address.

degenerate case: the engine declines rather than computing on garbage

Open this example

Frequently asked questions

How many usable hosts are in a /24?
254. A /24 has 256 addresses, and the first is the network address and the last is the broadcast address, so neither can be assigned to a host. The subtraction of two catches people out on small subnets in particular: a /30 has four addresses and two usable ones.
What is a /31 for?
Point-to-point links. RFC 3021 allows a /31 to use both of its two addresses, because a link with exactly two ends needs no broadcast address. It is the one case where the minus-two rule does not apply.