Subnet calculator

What a prefix actually means: which addresses are in it, which are usable, and why a /31 behaves nothing like a /30. The binary is shown, because a subnet mask stops being mysterious the moment you look at the bits.

Address

The network

In binary

Split it further

Is an address in this network?

Type an address to check whether it falls inside the network above.

What this is actually doing

An IPv4 address is 32 bits. A prefix length says how many of those bits are fixed for the network and how many are left for hosts. A /24 fixes the first 24 and leaves 8, which is 2 to the 8, which is 256 addresses. Everything else on this page follows from that one idea.

The network address is the one with every host bit set to zero, and the broadcast address is the one with every host bit set to one. Neither can be given to a machine, which is why a /24 has 256 addresses but only 254 you can actually use. The exception is worth knowing: a /31 has no room to reserve anything, so under RFC 3021 both of its two addresses are usable, which is exactly what you want on a point-to-point link between two routers. A /32 is a single address, and it is both the network and the host.

The subnet mask is the same information written out in full, and it is the reason a mask like 255.240.0.0 looks arbitrary until you write it in binary. It is twelve ones followed by twenty zeros. A mask that is not a run of ones followed by a run of zeros is not a valid mask, and this tool will tell you so rather than silently accepting it.

IPv6 works the same way with 128 bits instead of 32, and two shorthands. A run of zero groups can be replaced by ::, once per address, and leading zeros in a group are dropped. So 2001:0db8:0000:0000:0000:0000:0000:0001 and 2001:db8::1 are the same address written two ways, which is a genuinely common source of confusion when you are comparing two things that look different.

Build it yourself

The same calculator with Python's ipaddress module, which does all of this properly, plus the bit arithmetic by hand for when you are on a machine without Python.

Read the lesson

Other utilities

Random passwords and Diceware passphrases, with an honest entropy figure.

Base64, Base64URL, hex, URL, ROT13, HTML entities and binary.

MD5, SHA-1 and the SHA-2 family, over text or a file, with a compare mode.

Read a token, check its claims, and actually verify the signature.

Octal and symbolic file permissions, including the special bits.