IPv4 Subnet Calculator – Free

This subnet calculator takes an IPv4 address in CIDR notation, such as 192.0.2.13/27, and returns the network address, mask, broadcast address and host counts.

How to use the Subnet calculator tool

  1. Type an address and prefix length into IPv4 address with CIDR prefix, for example 10.20.30.40/22.
  2. Select Calculate subnet. Select Example to calculate 192.0.2.13/27.
  3. Read the five result lines: Network, Mask, Broadcast, Total addresses and Usable hosts.
  4. Select Copy to paste the values into a firewall rule, routing table or cloud network form.

How the subnet calculator works

An IPv4 address is a 32-bit number written as four decimal octets. A CIDR prefix, defined in RFC 4632, says how many of the leading bits identify the network. The remaining bits number the hosts inside it. A /27 leaves 5 host bits, so the block holds 2^5 = 32 addresses.

The calculator converts the address to an integer and clears the host bits to get the network address. Setting all host bits gives the last address in the block, which is the broadcast address. The mask is the same split written in dotted form: ones for network bits, zeros for host bits. Usable hosts is the total minus two, because the network and broadcast addresses are not assigned to interfaces. The arithmetic runs in your browser.

Worked example: 192.0.2.13/27

The last octet, 13, is 00001101 in binary. The /27 mask covers the first three bits of that octet (224 is 11100000), and those bits are 000, so the network is 192.0.2.0. The block size is 32, so it ends at 192.0.2.31. Hosts can use 192.0.2.1 through 192.0.2.30.

192.0.2.13/27

Network: 192.0.2.0/27
Mask: 255.255.255.224
Broadcast: 192.0.2.31
Total addresses: 32
Usable hosts: 30

Common prefix lengths at a glance

Each extra prefix bit halves the block. These common sizes were produced with this tool.

  • /8: mask 255.0.0.0, 16,777,216 addresses.
  • /16: mask 255.255.0.0, 65,536 addresses.
  • /22: mask 255.255.252.0, 1,024 addresses.
  • /24: mask 255.255.255.0, 256 addresses, 254 usable.
  • /26: mask 255.255.255.192, 64 addresses, 62 usable.
  • /29: mask 255.255.255.248, 8 addresses, 6 usable.
  • /30: mask 255.255.255.252, 4 addresses, 2 usable.

Special cases: /31, /32 and /0

For /31 and /32 the tool labels the fourth line Last address, not Broadcast, and counts every address as usable. A /31 has two addresses and, under RFC 3021, both can be used on a point-to-point link with no broadcast address. A /32 is a single host route, common for loopback interfaces and firewall rules.

A prefix of /0 is accepted and describes the whole IPv4 space of 4,294,967,296 addresses, the form used for a default route.

Frequently asked questions

Can I enter a subnet mask like 255.255.255.0 in place of a prefix?

No. The input must be an address, a slash and a prefix from 0 to 32. Convert the mask by counting its one bits: 255.255.255.0 is /24 and 255.255.255.224 is /27. Anything else returns the message Enter an IPv4 CIDR block.

Does the subnet calculator support IPv6?

No. It reads four decimal octets only. IPv6 uses 128-bit addresses with the same prefix idea but has no broadcast address, so the output lines here would not apply.

How do I find the first and last usable host?

Add one to the network address and subtract one from the broadcast address. For 192.0.2.0/27 that gives 192.0.2.1 and 192.0.2.30. The tool prints the two boundary addresses and the host count, not the range itself.

Why are usable hosts two fewer than total addresses?

The lowest address names the network and the highest is the broadcast address, so neither is given to a device. Cloud providers often reserve more addresses per subnet. Check your platform's documentation, since the figure here follows the classic IPv4 rule only.

Does the address I type have to be the network address?

No. Any address inside the block works. The calculator masks off the host bits, so 192.0.2.13/27 and 192.0.2.0/27 return the same network. That helps when you need to know which subnet a given host belongs to.

Related tools