Every IPv4 network is described by an address and a prefix length — 192.168.1.130/26, for example. From those two numbers come everything an administrator needs: which subnet the address belongs to, where that subnet starts and ends, which addresses can be given to hosts, and what mask to type into a router or firewall. This calculator does the bit arithmetic and shows it in binary so you can see why the boundaries fall where they do.
How to use the subnet calculator
- Type an IP address. You can also paste CIDR notation such as 10.20.30.40/22, or an address followed by a dotted mask such as 172.16.5.4 255.255.240.0 — the prefix in the field then wins over the menu.
- Otherwise, pick the prefix length / subnet mask from the list; each option shows the dotted mask and host count.
- Read the network, broadcast, host range, mask and wildcard on the tape, along with the address type (private, public, loopback …) and the reverse-DNS zone for octet-aligned prefixes.
- Optionally choose List smaller subnets to break the network into equal subnets, for example a /20 into sixteen /24s.
Subnet formulas
An IPv4 address is a 32-bit number. A /p prefix means the first p bits identify the network and the remaining 32 − p bits identify hosts.
Two cases break the “minus 2” rule: a /31 has two usable addresses on point-to-point links (RFC 3021), and a /32 is a single host.
Worked example
Find the subnet for 192.168.1.130/26.
Mask: 26 ones = 11111111.11111111.11111111.11000000 = 255.255.255.192. The last octet has 2 network bits and 6 host bits, so each subnet spans 2⁶ = 64 addresses.
Network: 130 in binary is 10000010. AND with 11000000 gives 10000000 = 128, so the network is 192.168.1.128.
Broadcast: set the 6 host bits to 1: 10111111 = 191, so 192.168.1.191.
Hosts: 192.168.1.129 through 192.168.1.190 — 64 − 2 = 62 usable addresses. Wildcard mask 0.0.0.63.
A quicker mental method: the “block size” is 256 minus the interesting mask octet (256 − 192 = 64). Subnets start at multiples of 64 — 0, 64, 128, 192 — and 130 falls in the block that starts at 128.
Common prefixes
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /24 | 255.255.255.0 | 256 | 254 |
| /26 | 255.255.255.192 | 64 | 62 |
| /28 | 255.255.255.240 | 16 | 14 |
| /30 | 255.255.255.252 | 4 | 2 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point) |
| /32 | 255.255.255.255 | 1 | 1 |
Planning tips
- Size for growth. A subnet cannot easily be widened later without renumbering. If a VLAN will hold 100 devices today, a /25 (126 hosts) is tight; a /24 leaves room.
- Align on boundaries. A /22 must start at a third octet divisible by 4 (0, 4, 8 …). The calculator always reports the aligned network that contains your address.
- Reserve addresses for gateways, printers and DHCP exclusions; a common habit is to give the router the first usable address.
- Cloud networks reserve extra addresses. Major cloud providers hold back several addresses in every subnet, so a /28 there may offer only 11 usable hosts.
The tool understands the IANA special-purpose ranges, so it flags loopback (127.0.0.0/8), link-local (169.254.0.0/16), carrier-grade NAT (100.64.0.0/10), documentation ranges such as 192.0.2.0/24, multicast and reserved space.
To see your own public address, use what is my IP address. For AND, OR and shifts on arbitrary numbers, try the bitwise calculator, and to convert an address octet between decimal, binary and hex, the number base converter.
Frequently asked questions
How many usable hosts are in a /24?
254. A /24 has 2⁸ = 256 addresses; the first is the network address and the last is the broadcast address, leaving 254 for hosts. In general a prefix /p gives 2^(32 − p) − 2 usable hosts for p up to 30.
What is a wildcard mask?
The bitwise inverse of the subnet mask: 255.255.255.0 becomes 0.0.0.255. Cisco access lists and OSPF network statements use wildcard masks, where a 0 bit means "must match" and a 1 bit means "don't care".
Why does a /31 have two usable addresses?
RFC 3021 allows /31 subnets on point-to-point links, where a broadcast address is pointless. Both addresses are assigned to the two ends of the link, saving address space compared with a /30.
Which IPv4 addresses are private?
The RFC 1918 ranges 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. They are free to use inside any network but are not routed on the public internet; NAT translates them to a public address. 100.64.0.0/10 is a separate shared range used by carriers for large-scale NAT.
How do I pick a prefix for a given number of hosts?
Find the smallest power of 2 that is at least the host count plus 2, then subtract its exponent from 32. For 50 hosts: 52 → 64 = 2⁶, so use a /26, which offers 62 usable addresses.