π Subnet
Subnet Calculator
Turn any IPv4 address and prefix into a full subnet report: network and broadcast addresses, dotted netmask and wildcard, usable host range, host totals and a binary breakdown. Press Calculate.
How a subnet is calculated
Every IPv4 address is 32 bits. A CIDR prefix such as /24 says how many of those bits are the network part; the remaining bits identify hosts inside that network. This calculator converts the address to a 32-bit integer and applies bitwise operations, which is exactly what routers do.
The masks
- Netmask β 1s for network bits, 0s for host bits, e.g. /24 = 255.255.255.0.
- Wildcard β the inverse of the netmask, used in Cisco ACLs, e.g. /24 = 0.0.0.255.
- Network address β address AND netmask, the first address in the block.
- Broadcast address β address OR wildcard, the last address in the block.
Usable hosts
For normal subnets (/1 to /30) the network and broadcast addresses are reserved, so usable hosts are 2(32βprefix) β 2. Two special cases follow modern practice: /31 is a point-to-point link with 2 usable addresses (RFC 3021), and /32 is a single-host route with 1.
Address classes and scopes
- Classes: A (1β126), B (128β191), C (192β223), D multicast (224β239), E reserved (240β255).
- Private ranges: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.
- Also flagged: loopback 127/8, link-local 169.254/16, carrier-grade NAT 100.64/10, multicast 224/4 and reserved 240/4.
Worked example
192.168.1.0/24 contains 256 addresses, of which 254 are usable hosts. 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.
Everyday uses
- Planning an office or home network
- Writing firewall and routing rules
- Splitting a range into VLANs
- Troubleshooting an addressing mistake
- Checking overlap before merging networks
Frequently asked questions
More worked examples
- A /24 subnet holds 256 addresses, of which 254 are usable for hosts.
- A /27 holds 32 addresses and 30 usable hosts.
- A /30 is the classic point-to-point link size, with four addresses and two usable.
- A /26 has the mask 255.255.255.192 and allows 62 usable hosts.
CIDR cheat sheet
| Prefix | Mask and usable hosts |
|---|---|
| /24 | 255.255.255.0, 254 hosts |
| /25 | 255.255.255.128, 126 hosts |
| /26 | 255.255.255.192, 62 hosts |
| /27 | 255.255.255.224, 30 hosts |
| /28 | 255.255.255.240, 14 hosts |
| /29 | 255.255.255.248, 6 hosts |
| /30 | 255.255.255.252, 2 hosts |
Common mistakes to avoid
- Subtracting two from the address count out of habit. On a modern point-to-point link a /31 can use both addresses, under the rule in RFC 3021.
- Assuming a /24 always begins at .0. The subnet boundary depends on the address, so a /24 can start at .64 or .192.
- Confusing the subnet mask with the default gateway, which is a host address inside the subnet.
- Forgetting that the network address and the broadcast address are reserved in ordinary subnets, which is where the minus two comes from.
Further questions
Sources and standards
The private IPv4 ranges are defined in RFC 1918, and an IPv4 subnet mask is simply a count of leading one bits in a 32-bit address. The page applies those definitions directly and shows the network and broadcast addresses a mask produces.