Subnet and IPv6 calculator
Type an address as your tools print it (192.168.1.42/24, 192.168.1.42 255.255.255.0, or 2a00:23c4:5f1a:8b00::1c3e/64) and get everything derived from it. Runs entirely in your browser.
IPv4 subnet calculator
a.b.c.d/nn, a.b.c.d nn, a.b.c.d 255.255.255.0, or a.b.c.d alone (assumes /32). Also accepts a bare mask like 255.255.240.0 to convert it.IPv6 calculator
%12, %eth0) is ignored. Prefix defaults to /64.Mask and prefix length reference
| CIDR | Mask | Wildcard | Hex | Addresses | Usable hosts |
|---|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 0xff000000 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 0xff800000 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 0xffc00000 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 0xffe00000 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 0xfff00000 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 0xfff80000 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 0xfffc0000 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 0xfffe0000 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 0xffff0000 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 0xffff8000 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 0xffffc000 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 0xffffe000 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 0xfffff000 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 0xfffff800 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 0xfffffc00 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 0xfffffe00 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 0xffffff00 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 0xffffff80 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 0xffffffc0 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 0xffffffe0 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 0xfffffff0 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 0xfffffff8 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 0xfffffffc | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 0xfffffffe | 2 | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 0xffffffff | 1 | 1 |
/31 has two usable addresses on point-to-point links (RFC 3021) and /32 is a single host; every other prefix loses the network and broadcast addresses.
How the calculation works
An IPv4 address and its mask are both 32-bit numbers. The network address is the bitwise AND of the two; the broadcast address is the network OR the inverted mask (the wildcard). Everything between them is the host range. The prefix length is simply the count of 1-bits in the mask, which is why 255.255.255.0 and /24 are the same thing. The binary view below the results shows the boundary: green bits are the network part, yellow bits are the host part.
IPv6 works the same way with 128 bits, but the mask is always written as a prefix length, and there is no broadcast address; the all-zero host part is the subnet-router anycast address, and hosts are otherwise free to use any interface identifier.