Subnet Calculator

Enter an IPv4 address and a CIDR prefix to get the subnet mask, network and broadcast addresses, the first and last usable hosts, and the total and usable host counts.

Subnet Calculator

For example, /24 is the common home-network size.
How it works: The CIDR number says how many of the address's 32 bits belong to the network. The mask keeps those bits, the network address zeroes the rest, and the broadcast address sets them all to 1. Usable hosts exclude the network and broadcast addresses.

How the Subnet Calculator Works

The Subnet Calculator takes an IPv4 address and a CIDR prefix length, such as /24, and works out the network details for that subnet: the subnet mask, the network address, the broadcast address, the first and last usable host addresses, and how many total and usable addresses the subnet contains. Network administrators and students studying for networking qualifications use it to plan address space, split a network into smaller parts, and check whether a device belongs on a particular subnet.

The method is binary arithmetic on the 32 bits of an IPv4 address. The prefix length says how many of those bits belong to the network part: a /24 means the first 24 bits are the network and the last 8 bits are hosts. The subnet mask is those network bits set to one and the rest to zero, which for /24 is 255.255.255.0. The network address is the original address with all host bits cleared to zero. The broadcast address is the network address with all host bits set to one. The first usable host is the network address plus one, and the last usable host is the broadcast address minus one. Total addresses come from the host bits: Total addresses = 2^(32−N), where N is the prefix length, and usable addresses are two fewer, because the network and broadcast addresses themselves cannot be assigned to devices.

This calculator implements those rules for any prefix from /0 to /32, with results that include the two special cases. A /31 subnet has no usable hosts by the usual rule, but the calculator follows the point-to-point convention where both addresses are usable. A /32 is a single host address, so the network, broadcast, first host, and last host are all the same address. For a prefix length outside /0 to /32, or an address with parts outside 0 to 255, the calculator reports the input as invalid rather than guessing.

How to Use This Calculator

  1. Enter the IPv4 address in dotted decimal form, such as 192.168.1.10.
  2. Enter the CIDR prefix length, such as 24 for a /24 network, or enter the subnet mask directly if that option is available.
  3. Press Calculate to work out the subnet details.
  4. Read the subnet mask first, then the network and broadcast addresses.
  5. Note the first and last usable hosts, and the total and usable address counts, for your network plan.

Example

For a tested example, enter the address 192.168.1.10 with a /24 prefix. The subnet mask is 255.255.255.0. The network address is 192.168.1.0, and the broadcast address is 192.168.1.255. The first usable host is 192.168.1.1, and the last usable host is 192.168.1.254. The total number of addresses is 256, and the usable number is 254.

As a second example, enter the address 192.168.1.10 with a /30 prefix. The subnet mask is 255.255.255.252. The network address is 192.168.1.8, and the broadcast address is 192.168.1.11. The first usable host is 192.168.1.9, and the last usable host is 192.168.1.10. The total number of addresses is 4, and the usable number is 2.

Understanding Your Result

The network and broadcast addresses frame the subnet: every device on it must have an address between them, and neither of those two boundary addresses can be assigned to a device. The usable range between them is where hosts live, and the counts tell you at a glance whether the subnet fits your needs. If the usable count is smaller than the number of devices you must connect, choose a smaller prefix number, which makes the subnet bigger, or split your plan differently.

A few rules of thumb will keep your plan consistent:

  • A smaller prefix number means a larger subnet, because fewer bits are fixed as the network part and more bits are left for hosts.
  • The network address always ends in the host bits cleared to zero, so it is the lowest address in the subnet.
  • The broadcast address always ends in the host bits set to one, so it is the highest address in the subnet.
  • Always check that the first and last usable hosts are inside the network and broadcast bounds, because an address outside them belongs to a different subnet.

Subnet Calculator FAQs

What is CIDR notation?

CIDR notation writes an address and a prefix length together, such as 192.168.1.10/24, where the number after the slash says how many of the 32 bits are the network part. It replaces the older classful system and the need to write the full subnet mask every time.

Why are there two fewer usable addresses than total addresses?

Because the network address and the broadcast address are reserved: the network address identifies the subnet itself, and the broadcast address reaches every device on it. Neither can be assigned to a single host, so they are excluded from the usable count.

What is special about /31 and /32 subnets?

A /31 has only two addresses, and under the point-to-point convention both are usable as host addresses, since there is no need for a separate network and broadcast address on a link between two devices. A /32 is a single host route, so all the addresses reported are the same.

How do I choose the right prefix length?

Count the hosts you need, add two for the network and broadcast addresses, then find the smallest power of two that covers that total. That power tells you how many host bits you need, and 32 minus that number is the prefix length to use.

Can this calculator handle IPv6 addresses?

No, this calculator works with IPv4 addresses only, written as four numbers separated by dots. IPv6 uses a different address format and much larger subnets, so it needs a separate tool.

Related calculators: Conversion Calculator, Scientific Calculator, Password Generator.