IP Subnet Calculator
How many usable hosts are in a /24 subnet?
A /24 has 256 addresses (2 to the power of 8) and 254 usable hosts, because the first address is the network address and the last is the broadcast address. Its subnet mask is 255.255.255.0.
A subnet is a block of IP addresses defined by a starting address and a prefix length, written in CIDR notation such as 192.168.1.0/24. The prefix says how many of the 32 bits in an IPv4 address identify the network; the rest number the hosts. A /24 leaves 8 host bits, which gives 256 addresses, 254 of them usable by devices once the network and broadcast addresses are set aside.
Enter any IPv4 address and a prefix from /0 to /32 and this calculator returns the network address, broadcast address, first and last usable host, subnet mask, wildcard mask, total addresses and usable host count. It also shows the address class, whether the address is in a private range, and the address and mask in binary so you can see exactly which bits belong to the network.
Enter your details
How to Use the IP Subnet Calculator
- 1
Enter an IP address
Type any IPv4 address in dotted-decimal form, such as 192.168.1.100. It does not need to be the network address; the calculator works out which subnet the address belongs to.
- 2
Set the CIDR prefix
Type a prefix from 0 to 32 in the CIDR Notation box, or tap one of the common prefixes from /8 to /30. If you have a dotted mask instead, find its prefix in the table below (255.255.255.0 is /24).
- 3
Read the address range
The top panel shows the network address with its prefix, the broadcast address and the first and last usable host addresses. Results update as you type.
- 4
Check the details
Below that are the subnet mask, wildcard mask, usable hosts and total addresses, then the class, whether the address is private or public, and the address and mask in binary.
How subnet math works
An IPv4 address is a 32-bit number, written as four 8-bit octets. The subnet mask has a 1 in every network bit and a 0 in every host bit, so a /26 mask is twenty-six 1s followed by six 0s: 11111111.11111111.11111111.11000000, or 255.255.255.192.
Every result the calculator shows comes from bitwise operations on those 32 bits. AND the address with the mask and you clear the host bits, which gives the network address. OR the network address with the wildcard mask (the mask with every bit flipped) and you set all the host bits, which gives the broadcast address. The usable hosts are everything in between.
In a normal subnet the first address identifies the network and the last is the broadcast address, so neither can be assigned to a device, which is where the "minus 2" comes from. The two smallest prefixes are the exception. A /31 has only two addresses and is used for point-to-point links between two routers, where RFC 3021 allows both to be used as hosts. A /32 is a single address, used for loopbacks and host routes. The calculator counts both addresses of a /31 and the single address of a /32 as usable.
Total addresses = 2^(32 − prefix)
Usable hosts = 2^(32 − prefix) − 2 (all addresses for /31 and /32)
Network address = IP AND subnet mask
Wildcard mask = NOT subnet mask (255.255.255.255 − mask, octet by octet)
Broadcast address = network address OR wildcard maskWorked example: 192.168.1.100/26
The same approach scales to bigger blocks. For 10.20.30.40/20 the mask is 255.255.240.0, so the block size in the third octet is 256 − 240 = 16. Blocks start at 0, 16, 32 and so on, and 30 falls in the one starting at 16: network 10.20.16.0, broadcast 10.20.31.255, 4,096 addresses and 4,094 usable hosts.
- Prefix /26 leaves 32 − 26 = 6 host bits, so the block holds 2^6 = 64 addresses.
- Subnet mask: 26 ones is 255.255.255.192. Wildcard mask: 255 − 192 = 63, so 0.0.0.63.
- The last octet, 100, is 01100100 in binary. ANDed with the mask octet 11000000 it becomes 01000000, which is 64. Network address: 192.168.1.64.
- Broadcast: 64 OR 63 = 127, so 192.168.1.127.
- Usable hosts: 192.168.1.65 to 192.168.1.126, which is 64 − 2 = 62 addresses.
- A quicker way to the same answer: a /26 splits each /24 into blocks of 64 starting at .0, .64, .128 and .192. The address .100 falls in the block that starts at .64.
CIDR to subnet mask table (/8 to /32)
Each step down in prefix length doubles the size of the block. Usable hosts follow the same rule the calculator uses: total minus 2, except /31 and /32.
| CIDR | Subnet mask | Wildcard mask | Total addresses | Usable hosts |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
Private ranges and address classes
RFC 1918 reserves three ranges for private networks: 10.0.0.0/8, 172.16.0.0/12 (172.16.0.0 to 172.31.255.255) and 192.168.0.0/16. Addresses in those ranges are not routed on the public internet, which is why home routers hand out 192.168.x.x addresses and use NAT to share one public address. The calculator labels an address Private only when it falls in one of those three ranges; everything else, including loopback (127.0.0.0/8), link-local (169.254.0.0/16) and carrier-grade NAT space (100.64.0.0/10), is labeled Public.
The class shown is the historical classful category, based only on the first octet: Class A for 0 to 127, Class B for 128 to 191, Class C for 192 to 223, Class D (multicast) for 224 to 239 and Class E (reserved) for 240 to 255. Classes have not governed routing since CIDR replaced them in 1993, so the prefix you enter, not the class, decides the subnet. The class is shown because certification exams and older documentation still refer to it.
Choosing a subnet size
Once you know how big each subnet is, the bandwidth calculator estimates how long transfers between them take at a given link speed.
- Count the devices, then add room to grow. A subnet is hard to resize once addresses are handed out, so size for the number of devices you expect in a few years, not today.
- Remember the gateway. The router interface takes one usable address, usually the first or last in the range, so a /29 with 6 usable hosts leaves 5 for devices.
- Use /30 or /31 for router-to-router links. A /30 gives exactly 2 usable hosts; a /31 does the same without wasting the network and broadcast addresses, where both ends support it.
- A /24 is the usual default for a home or small office LAN: 254 hosts, and the subnet boundary falls neatly on the last octet.
- Larger flat subnets mean more broadcast traffic. Rather than one /20 with thousands of devices, split it into several /24s or /23s by floor, department or device type.
- Cloud networks reserve extra addresses. AWS, for example, reserves five addresses in every VPC subnet rather than two, so a /24 there gives 251 usable addresses. Check your provider before sizing to the last address.
Features
- Subnet mask calculations
- CIDR notation support
- Host range calculation
- IPv4 network and broadcast addresses
Frequently Asked Questions
How many usable hosts are in a /24?
254. A /24 has 8 host bits, which gives 2 to the power of 8 = 256 addresses. The first is the network address and the last is the broadcast address, leaving 254 for devices. The subnet mask is 255.255.255.0.
How do I calculate the number of hosts in a subnet?
Subtract the prefix length from 32 to get the number of host bits, raise 2 to that power for the total addresses, then subtract 2 for the network and broadcast addresses. A /27 has 5 host bits: 2 to the 5th is 32 addresses, and 30 usable hosts.
What subnet mask is /26?
255.255.255.192. A /26 has 26 network bits, which fills the first three octets (24 bits) and the top 2 bits of the last octet, worth 128 + 64 = 192. It holds 64 addresses and 62 usable hosts, and its wildcard mask is 0.0.0.63.
What is a wildcard mask?
The inverse of the subnet mask: every 1 becomes a 0 and every 0 a 1. For 255.255.255.0 the wildcard is 0.0.0.255. Cisco access control lists and OSPF network statements use wildcard masks to say which bits of an address must match, which is why the calculator shows it alongside the subnet mask.
Why are two addresses unusable in a subnet?
The first address, with all host bits set to 0, identifies the network itself, and the last, with all host bits set to 1, is the broadcast address that reaches every device on the subnet. Neither can be assigned to a single device. The exceptions are /31 point-to-point links, where both addresses are usable, and /32, which is one address.
How do I find the network address of an IP?
AND the IP address with the subnet mask, bit by bit. For 192.168.1.100 with mask 255.255.255.192, the last octet is 100 AND 192 = 64, so the network address is 192.168.1.64. Enter the IP and prefix above and the calculator does this for you.
Does this calculator work with IPv6?
No. It handles IPv4 addresses only, with prefixes from /0 to /32. IPv6 uses 128-bit addresses and different conventions, such as /64 for almost every LAN and no broadcast address.
Sources and review
Prepared by the Codezyra editorial team. The figures and rules on this page were checked against these official sources:
- RFC 4632: Classless Inter-domain Routing (CIDR)
- RFC 1918: Address Allocation for Private Internets
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links
This is general information, not personal tax, legal or medical advice.
Last reviewed