FREE TOOL

IPv4 subnet calculator

Enter an IPv4 address and a prefix length or subnet mask. The calculator returns the network address, broadcast address, usable host range, and host count, and it shows the binary working for each step. The calculation runs in this page, and the page does not send what you type to a server. No account is required.

Address and prefix

This calculator runs in your browser and needs JavaScript turned on. The boxes stay locked until the page script loads, so the page cannot send anything you enter. If they stay locked, the script did not load. Turn on JavaScript or reload the page to use the calculator.

For example 192.168.10.77. Pasting 192.168.10.77/26 fills both boxes.

For example 26, /26, or 255.255.255.192.

How the calculator finds each value

An IPv4 address is 32 bits. The prefix length says how many of those bits, counted from the left, identify the network. The remaining bits identify a host on that network. A /26 prefix leaves 6 host bits, so the subnet holds 26, or 64, addresses.

The subnet mask writes the prefix as 32 bits, with ones for the network part and zeros for the host part. A bitwise AND of the address and the mask clears the host bits and leaves the network address. Setting every host bit to 1 gives the last address in the subnet, which is the directed broadcast address on an ordinary subnet. The usable host range is every address between those two.

To practice, work out the network and broadcast addresses for 192.168.10.77/26 on paper first. Then calculate it here and compare your bits with each step.

Why /31 and /32 are different

On an ordinary subnet the first address identifies the network and the last is the broadcast address, so neither is assigned to a host. That is why a /30 holds four addresses but only two usable hosts. RFC 3021 allows a /31 on a point-to-point link, where only two devices exist and no broadcast address is needed, so both addresses are usable. A /32 contains one address. It is used for loopback interfaces and host routes, and the calculator reports it as one usable address.

When the address has host bits set

If you enter 192.168.10.77/26, the address is a host inside 192.168.10.64/26 rather than the network address. The calculator still returns the whole subnet and states which address you entered. Use the network address from the result wherever a configuration asks for the network rather than a host.

What this calculator does not do

The calculator works on one IPv4 subnet at a time. It does not plan several subnets from a larger block, summarize routes, or handle IPv6.

It also does not check whether a device will accept an address. A /31 works only where the platform and link support RFC 3021, and some blocks, such as 127.0.0.0/8 for loopback and 224.0.0.0/4 for multicast, have reserved uses that this calculator does not flag.

Sources: RFC 4632, Classless Inter-domain Routing; RFC 3021, 31-bit prefixes on point-to-point links; RFC 6890, special-purpose IP address registries, for 127.0.0.0/8; RFC 5771, IPv4 multicast address assignments, for 224.0.0.0/4.