The formula
Number of addresses = 2^(32 − prefix) for IPv4, 2^(128 − prefix) for IPv6
Usable IPv4 hosts = addresses − 2 (network and broadcast), except /31 (2) and /32 (1)
Network address = IP AND mask; broadcast = network OR wildcard
Wildcard mask = 255.255.255.255 − subnet mask
Prefix to mask: /24 = 255.255.255.0, /26 = 255.255.255.192, /28 = 255.255.255.240
Worked example
- 192.168.10.37/26:
- A /26 has 2^6 = 64 addresses, so the mask is 255.255.255.192 and the wildcard 0.0.0.63.
- 37 falls in the block 0–63, so the network is 192.168.10.0 and the broadcast 192.168.10.63.
- Usable hosts are 192.168.10.1 to 192.168.10.62: 62 hosts.
- Split into /28s, it becomes four subnets of 14 hosts: .0, .16, .32 and .48.
What subnetting does
Subnetting divides an IP network into smaller networks. Each subnet has a network address, a range of host addresses and, in IPv4, a broadcast address. Splitting networks improves security, by isolating departments, guests and devices such as cameras; limits broadcast traffic; and makes better use of address space. The prefix length in CIDR notation, such as /24, says how many leading bits identify the network. The remaining bits identify hosts, so a smaller prefix means a bigger network.
Reading CIDR notation
Classless Inter-Domain Routing (CIDR) replaced the old class A, B and C system in 1993. In 10.0.0.0/8, the first 8 bits are the network, leaving 24 bits and about 16.7 million addresses. A /24, the classic home or office network, has 256 addresses and 254 usable hosts. Each step up the prefix halves the size: /25 has 128 addresses, /26 has 64, /27 has 32, /28 has 16, /29 has 8 and /30 has 4. A /31 is used for point-to-point links, where both addresses are usable, and a /32 refers to a single host.
Subnet masks and wildcard masks
A subnet mask is the prefix written as a dotted IP address, with 1 bits for the network part: /24 is 255.255.255.0 and /26 is 255.255.255.192. Devices find their network by ANDing their IP address with the mask. A wildcard mask is the inverse of the subnet mask and is used in Cisco access control lists and OSPF configuration: the wildcard for /26 is 0.0.0.63. The calculator shows both, plus the mask in binary so you can see exactly where the network bits end.
Private and special address ranges
Three IPv4 ranges are reserved for private networks by RFC 1918: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. These aren't routed on the public internet and are used behind NAT in homes and businesses. Other special ranges include 127.0.0.0/8 for loopback, 169.254.0.0/16 for link-local addresses when DHCP fails, and 100.64.0.0/10 for carrier-grade NAT. The calculator identifies which kind of address you've entered.
IPv6 subnetting
IPv6 addresses are 128 bits long, written as eight groups of hexadecimal digits, with consecutive zero groups shortened to ::. Subnetting works the same way, but the numbers are vastly larger. Standard LAN subnets are /64, which is required for stateless address autoconfiguration (SLAAC), and contain 18 quintillion addresses. Internet providers typically give homes a /56 or /48, allowing 256 or 65,536 /64 subnets. IPv6 has no broadcast address; it uses multicast instead.
Quick reference: common IPv4 prefixes
/30: 4 addresses, 2 hosts (255.255.255.252), traditional point-to-point links. /29: 8 addresses, 6 hosts (.248), small business static IP blocks. /28: 16 addresses, 14 hosts (.240). /27: 32, 30 hosts (.224). /26: 64, 62 hosts (.192). /25: 128, 126 hosts (.128). /24: 256, 254 hosts. /23: 512, 510 hosts (255.255.254.0). /22: 1,024, 1,022 hosts (255.255.252.0). /16: 65,536 addresses (255.255.0.0).
Planning a network
Start with the number of hosts each segment needs, add room for growth, and choose the smallest subnet that fits: a 50-device office needs at least a /26, and room to grow suggests a /25. Keep subnets aligned on their natural boundaries, and document your address plan. Use the split option to carve a larger block into equal subnets. For bandwidth planning, see the data transfer time calculator, and for storage on the network, the RAID calculator.