Subnet calculator

Type an IPv4 address with a prefix, like 192.168.1.10/24, or with a subnet mask, like 10.0.0.5 255.255.0.0.

Network
–
Usable hosts
–
Host range
–

How to use the subnet calculator

  1. Type an address into IP address / prefix or mask, either as CIDR (192.168.1.10/24) or with a dotted mask after a space (10.0.0.5 255.255.0.0). An address with no prefix is treated as a single host, /32.
  2. Read the Network, number of Usable hosts and Host range at the top of the results.
  3. Check the table for the subnet and wildcard masks, network and broadcast addresses, IP class, address type, and the address in binary, hex and as an integer.
  4. To divide the block, pick a longer prefix in Split into. Each option shows how many subnets it makes, and the list shows each subnet's first host, last host and broadcast address.

How it works

An IPv4 address is a 32-bit number, written as four 8-bit octets. The prefix says how many leading bits identify the network. The network address has all host bits set to 0 and the broadcast address has them all set to 1; the addresses in between are usable hosts. So a /24 has 28 = 256 addresses and 254 usable hosts.

In general a /n block has 232−n addresses. The subnet mask is the same prefix written as an address: n one-bits followed by zeros. To find the network, a router ANDs the address with the mask.

Worked example

Take 203.0.113.77/27. A /27 mask is 27 ones, so the last octet of the mask is 11100000 = 224, giving 255.255.255.224. Only the last octet changes:

Address   77   01001101
Mask     224   11100000
AND           ---------
Network   64   01000000   -> 203.0.113.64
Broadcast 95   01011111   -> 203.0.113.95 (host bits all 1)

The calculator shows network 203.0.113.64/27, usable hosts 203.0.113.65 to 203.0.113.94 (30 hosts out of 32 addresses), wildcard mask 0.0.0.31, and the address type Documentation (TEST-NET-3), because 203.0.113.0/24 is reserved for examples like this one.

CIDR prefix cheat sheet

PrefixSubnet maskAddressesUsable hosts
/32255.255.255.25511
/31255.255.255.25422 (point-to-point links)
/30255.255.255.25242
/29255.255.255.24886
/28255.255.255.2401614
/27255.255.255.2243230
/26255.255.255.1926462
/25255.255.255.128128126
/24255.255.255.0256254
/16255.255.0.065,53665,534
/8255.0.0.016,777,21616,777,214

/31 and /32

A /32 is a single address, used for host routes, loopback interfaces and firewall rules that match one IP. A /31 has two addresses and, under RFC 3021, both are usable on point-to-point links, because a link between two routers needs no network or broadcast address. The calculator follows this, so both show no broadcast address and count every address as usable.

Subnetting a network

Splitting a block means borrowing host bits for the network. Each extra prefix bit doubles the number of subnets and halves their size. Choosing /26 in Split into for 192.168.1.0/24 gives four subnets of 62 hosts each:

SubnetFirst hostLast hostBroadcast
192.168.1.0/26192.168.1.1192.168.1.62192.168.1.63
192.168.1.64/26192.168.1.65192.168.1.126192.168.1.127
192.168.1.128/26192.168.1.129192.168.1.190192.168.1.191
192.168.1.192/26192.168.1.193192.168.1.254192.168.1.255

To size a subnet, add two to the hosts you need (for network and broadcast) and round up to a power of two. Fifty hosts need 64 addresses, which is a /26. Very large splits list the first 1,024 subnets.

Private address ranges

10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are reserved for private networks (RFC 1918) and are not routed on the internet. The calculator also flags loopback, link-local, carrier-grade NAT and documentation ranges.

Note that 172.16.0.0/12 runs from 172.16.0.0 to 172.31.255.255, so 172.32.0.1 is a public address. The carrier-grade NAT range, 100.64.0.0/10 (RFC 6598), is shared ISP space and should not be used inside your own network either.

Cloud networks

AWS, Azure and Google Cloud reserve some addresses in every subnet (AWS and Azure reserve 5), so usable hosts in a cloud VPC subnet are a few fewer than shown here.

Common mistakes

Key terms

CIDR
Classless Inter-Domain Routing: writing an IP block as an address plus a prefix length, such as 192.168.1.0/24. The prefix is the number of leading bits that identify the network, and it replaced the fixed class A, B and C sizes in 1993.
Subnet mask
A 32-bit value with ones for the network part of an IPv4 address and zeros for the host part, written like an address: 255.255.255.0 is the same as /24. ANDing an address with its mask gives the network address.
Network address
The first address in an IPv4 subnet, with all host bits set to 0, such as 192.168.1.0 in 192.168.1.0/24. It identifies the subnet in routing tables and is not normally assigned to a device.
Broadcast address
The last address in an IPv4 subnet, with all host bits set to 1, such as 192.168.1.255 in 192.168.1.0/24. Packets sent to it are delivered to every host on that subnet. /31 and /32 subnets have none.
Wildcard mask
The bitwise inverse of a subnet mask, such as 0.0.0.255 for a /24. A 0 bit means the address bit must match and a 1 bit means it can be anything. Cisco access lists and OSPF configuration use wildcard masks.
Private IP address
An IPv4 address from the ranges RFC 1918 reserves for internal networks: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. They are not routed on the public internet, so devices using them reach it through NAT.
Subnetting
Dividing one IP block into smaller blocks by lengthening the prefix. Each extra bit doubles the number of subnets and halves their size, so a /24 splits into two /25s, four /26s or eight /27s.
IP address class
The pre-1993 system that fixed network sizes by an address's first octet: class A (0 to 127), B (128 to 191) and C (192 to 223), with D for multicast and E reserved. CIDR replaced it, but the terms are still used informally.

Frequently asked questions

How many hosts are in a /24?
256 addresses, of which 254 are usable: the first is the network address and the last is the broadcast address.
How do I convert a subnet mask to CIDR?
Count the 1 bits in the mask. 255.255.255.0 is 24 ones, so /24. Type the IP and mask separated by a space and the calculator does it for you.
What is a wildcard mask?
The inverse of the subnet mask (0.0.0.255 for a /24). Cisco ACLs and OSPF use it.
Does it support IPv6?
Not yet; this calculator is for IPv4. IPv6 uses the same prefix idea with 128-bit addresses, but has no broadcast address, and ordinary LAN subnets are normally a /64.
How do I calculate the number of usable hosts?
Subtract the prefix from 32, raise 2 to that power, then subtract 2 for the network and broadcast addresses. A /27 has 2 to the power 5, or 32, addresses and 30 usable hosts. The exceptions are /31, where both addresses are usable on point-to-point links, and /32, a single host.
What is the difference between the network and broadcast address?
The network address is the first address in the block, with every host bit set to 0, and it names the subnet itself. The broadcast address is the last, with every host bit set to 1, and a packet sent there reaches every host on the subnet. Neither is normally assigned to a device.
Is 172.20.0.0 a private IP address?
Yes. The RFC 1918 private block 172.16.0.0/12 covers every address from 172.16.0.0 to 172.31.255.255, so anything starting 172.16 to 172.31 is private. Addresses such as 172.15.x.x or 172.32.x.x are public. Type any address here and the Address type row tells you which range it belongs to.
Why does a /31 have no broadcast address?
RFC 3021 lets point-to-point links between two routers use a /31, because only two devices share the link and no broadcast is needed. That saves two addresses per link compared with a /30. The calculator therefore shows both addresses as usable hosts and no broadcast address.