How to calculate an IP subnet
Network bits and host bits
An address has b bits and prefix length p. The subnet mask M sets its first p bits to one. Applying IP AND M gives the network address N. The number of addresses is 2 raised to b − p. IPv4 uses 32 bits and IPv6 uses 128.
Worked example
192.168.1.130/26 belongs to 192.168.1.128/26. Its 64 addresses run through 192.168.1.191. For an ordinary IPv4 subnet the first and last addresses are reserved, leaving 62 usable addresses.
IPv4 and IPv6 conventions
A /31 has two endpoints under the IPv4 point-to-point convention. A /32 is one address. IPv6 has no broadcast address. The IPv6 result shows the address range and total, without assuming a deployment’s assignment policy.
IETF RFC 4632 · IETF RFC 4291 · IETF RFC 3021 · IETF RFC 5952
After sizing a network, estimate transfer time or traffic with the Bandwidth Calculator.
Common questions
Can I use a dotted IPv4 subnet mask?
Yes. Enter the IPv4 address and a mask such as 255.255.255.192. The mask must have a contiguous run of ones followed by zeros.
Can I paste a compressed IPv6 address?
Yes. For example, enter 2001:db8::1/64. A single :: represents consecutive zero groups. The results include the expanded address.
What is the wildcard mask?
For IPv4 it is the bitwise inverse of the subnet mask. A /26 mask of 255.255.255.192 has wildcard 0.0.0.63.