What a subnet is
A subnet is a block of IP addresses that share the same leading bits. Devices inside the block talk to each other directly. Traffic for anywhere else goes through a router.
Every IP address has two parts. The network part names the block, and the host part names one device inside it. The prefix length says where the split falls. This calculator takes an address and a prefix and shows the block it belongs to: where it starts, where it ends, and how many devices it can hold. Nothing you type is sent anywhere.
Reading CIDR notation
CIDR notation writes an address, a slash, then the number of network bits. In 192.0.2.130/26 the first 26 bits are the network and the last 6 belong to hosts. Six host bits give 26, or 64, addresses. They run from 192.0.2.128 to 192.0.2.191.
The first address of a block is the network address. The last is the broadcast address, which reaches every host at once. Neither can be given to a device, so a /26 holds 62 hosts. A subnet mask says the same thing as the prefix in dotted form: /26 is 255.255.255.192. Each step longer in the prefix halves the block. Each step shorter doubles it.
Two sizes break the pattern. A /31 has two addresses and both are usable, which suits a link between two routers (RFC 3021). A /32 is a single address, used in routing tables and firewall rules.
Common IPv4 prefixes
| Prefix | Subnet mask | Usable hosts | Where you see it |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 | The largest private range, 10.0.0.0/8 |
| /12 | 255.240.0.0 | 1,048,574 | The private range 172.16.0.0/12 |
| /16 | 255.255.0.0 | 65,534 | The private range 192.168.0.0/16 |
| /20 | 255.255.240.0 | 4,094 | A large site, or sixteen /24 networks under one route |
| /22 | 255.255.252.0 | 1,022 | A busy office or guest Wi-Fi network |
| /23 | 255.255.254.0 | 510 | Two /24 networks joined together |
| /24 | 255.255.255.0 | 254 | Most home and small office networks |
| /25 | 255.255.255.128 | 126 | Half of a /24 |
| /26 | 255.255.255.192 | 62 | A quarter of a /24 |
| /27 | 255.255.255.224 | 30 | A small department or server group |
| /28 | 255.255.255.240 | 14 | A small server or management network |
| /29 | 255.255.255.248 | 6 | A small block of public addresses from a provider |
| /30 | 255.255.255.252 | 2 | A link between two routers |
| /31 | 255.255.255.254 | 2 | A point-to-point link with no broadcast address |
| /32 | 255.255.255.255 | 1 | One host, in routes and firewall rules |
Private ranges
RFC 1918 sets aside three IPv4 blocks for private networks. They are never routed on the public internet, so anyone may use them at home or at work behind a router that translates addresses.
10.0.0.0/8runs from 10.0.0.0 to 10.255.255.255, about 16.7 million addresses.172.16.0.0/12runs from 172.16.0.0 to 172.31.255.255, about 1 million addresses.192.168.0.0/16runs from 192.168.0.0 to 192.168.255.255, which is 65,536 addresses. Most home routers hand out a /24 from this block.
Two more ranges look private but are not yours to assign. Providers use 100.64.0.0/10 for carrier-grade NAT, and a device gives itself an address in 169.254.0.0/16 when no DHCP server answers. In IPv6 the private equivalent is the unique local range fc00::/7.
Why IPv6 subnets are /64
An IPv6 address is 128 bits long. By convention the first 64 bits are the network and the last 64 identify the interface. Stateless address autoconfiguration (SLAAC), which is how most devices get an IPv6 address, depends on that split. Put a longer prefix on a LAN and devices that rely on it can no longer configure themselves.
Running out of host addresses is never the concern. One /64 holds 264 addresses, about 18 quintillion. Planning in IPv6 means counting networks instead. A provider often delegates a /56 or a /48 to a customer, which is 256 or 65,536 separate /64 networks. The exceptions are a /127 on a link between two routers (RFC 6164) and a /128 for a single address. IPv6 also has no broadcast address. Multicast does that job. The IPv4 vs IPv6 guide covers the other differences.