Subnetting splits an IP network into smaller blocks. The prefix length (the number after the slash in CIDR notation such as 192.168.86.42/24) says how many leading bits identify the network; the remaining bits number the hosts inside it. A /24 leaves 8 host bits, so the block holds 2⁸ = 256 addresses, of which 254 can be given to devices because the first is the network address and the last is the broadcast address.
Enter an address and choose a prefix (or tick a class to limit the choice to classful sizes). The calculator applies a bitwise AND with the mask to find the network address, fills the host bits with ones for the broadcast address, and lists the usable range, the dotted subnet mask and the wildcard mask used by router access lists. It also tells you whether the address is private (RFC 1918), loopback, link-local, carrier-grade NAT, multicast or public, and gives the reverse-DNS name, the integer value and the IPv4-mapped and 6to4 IPv6 forms.
Switch to IPv6 to see the network prefix, the first and last address and how many /64 subnets (the standard size for one LAN) fit in a delegated prefix such as /48 or /56.
How to use the IP Subnet Calculator
- IP version
- IPv4 address
- Network class (limits the prefix)
- Prefix length (/n): /24 = 255.255.255.0, /16 = 255.255.0.0, /8 = 255.0.0.0
- IPv6 address
- IPv6 prefix length (/n)
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
The address is converted to a 32-bit (or 128-bit) integer. The block size is 2^(host bits); the network address is the integer rounded down to a multiple of the block size, and the last address adds the block size minus one. /31 point-to-point links (RFC 3021) and /32 host routes are handled as special cases.
Worked example
192.168.86.42/24: the mask is 255.255.255.0. ANDing gives the network 192.168.86.0; filling the 8 host bits with ones gives the broadcast 192.168.86.255. Usable hosts run from 192.168.86.1 to 192.168.86.254, 254 addresses. The address is private (RFC 1918), its integer value is 3,232,257,578 and its reverse-DNS name is 42.86.168.192.in-addr.arpa.
IPv4 subnet cheat sheet
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /30 | 255.255.255.252 | 4 | 2 |
| /29 | 255.255.255.248 | 8 | 6 |
| /28 | 255.255.255.240 | 16 | 14 |
| /27 | 255.255.255.224 | 32 | 30 |
| /26 | 255.255.255.192 | 64 | 62 |
| /25 | 255.255.255.128 | 128 | 126 |
| /24 | 255.255.255.0 | 256 | 254 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
Formula
Addresses = 2³² − prefix) · Usable hosts = addresses − 2 (/31 → 2, /32 → 1) · Network = IP AND mask · Broadcast = network + addresses − 1 · Wildcard = NOT mask
Worked example
Inputs: IP version: IPv4; IPv4 address: 192.168.86.42; Network class (limits the prefix): Any / CIDR; Prefix length (/n): 24.
Results: Usable hosts = 254; CIDR notation = 192.168.86.0/24; Network address = 192.168.86.0; Broadcast address = 192.168.86.255; First usable host = 192.168.86.1; Last usable host = 192.168.86.254.
Key terms
- CIDR
- Classless Inter-Domain Routing, writing a network as address/prefix length.
- Subnet mask
- 32 bits with ones for the network part, e.g. 255.255.255.0.
- Broadcast address
- The last address in an IPv4 subnet, reaching every host on it.
- Wildcard mask
- The bitwise inverse of the subnet mask.
- Prefix length
- Number of leading network bits.
Frequently asked questions
What mask is /24?
255.255.255.0, with 256 addresses and 254 usable hosts.
Why subtract two?
The first address names the network and the last is the broadcast address, so neither can be assigned to a device.
How many hosts does a /26 have?
2⁶ = 64 addresses, 62 usable hosts; mask 255.255.255.192.
What is a wildcard mask?
The inverse of the subnet mask (0.0.0.255 for /24), used in Cisco ACLs and OSPF.
Can a /31 be used?
Yes, RFC 3021 allows /31 on point-to-point links, giving 2 usable addresses with no broadcast.
Which ranges are private?
10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 (RFC 1918). 100.64.0.0/10 is shared carrier-grade NAT space.
What prefix should an IPv6 LAN use?
/64. A home connection usually receives a /56 (256 LANs) or /48 (65,536 LANs).