Free tool · Developer tools
Subnet calculator
Enter an IPv4 address with a prefix or mask and get the network, broadcast, host range, usable hosts, masks and binary view, then split it into equal subnets.
- Free
- No sign-up
- Runs in your browser
192.168.1.0/24256 addresses, 254 usable hosts
- Class C
- Private (RFC 1918)
- Your address is inside 192.168.1.0/24
- Network address
- 192.168.1.0
- Broadcast address
- 192.168.1.255
- First usable host
- 192.168.1.1
- Last usable host
- 192.168.1.254
- Usable hosts
- 254
- Total addresses
- 256
- Subnet mask
- 255.255.255.0
- Wildcard mask
- 0.0.0.255
Bright bits are the 24 network bits, dim bits are the 8 host bits.
Split into 4 subnets of /26
| Subnet | Usable hosts | Broadcast |
|---|---|---|
| 192.168.1.0/26broadcast 192.168.1.63 | 192.168.1.1 192.168.1.62 | 192.168.1.63 |
| 192.168.1.64/26broadcast 192.168.1.127 | 192.168.1.65 192.168.1.126 | 192.168.1.127 |
| 192.168.1.128/26broadcast 192.168.1.191 | 192.168.1.129 192.168.1.190 | 192.168.1.191 |
| 192.168.1.192/26broadcast 192.168.1.255 | 192.168.1.193 192.168.1.254 | 192.168.1.255 |
How to use the Subnet Calculator
- Type an address and a prefix or mask in IP address with prefix or mask, such as 192.168.1.10/24 or 192.168.1.10 255.255.255.0.
- Use Change the prefix to try /8 to /30 on the same address.
- Read the network, broadcast, first and last usable host, usable hosts, subnet mask and wildcard mask, and the binary view.
- Set Split into equal subnets to a power of 2 to get a table of smaller subnets, then press Copy summary or Copy subnet list.
How do I calculate a subnet mask from CIDR?
The number after the slash is how many bits at the left of the 32-bit mask are 1. Everything after them is 0. A /24 has 24 ones, so the mask is 255.255.255.0. Each of the four numbers in the mask holds 8 bits, so a prefix that is a multiple of 8 gives 255 in the full numbers and 0 in the rest.
For other prefixes, count the extra bits in the first partial number. A /26 is 24 full bits plus 2 more. Two bits set at the left of an 8-bit number are 128 + 64 = 192, so the mask is 255.255.255.192. A /20 is 16 full bits plus 4: 128 + 64 + 32 + 16 = 240, so the mask is 255.255.240.0. The tool does this for every prefix from /0 to /32, and it accepts a dotted mask too. A mask such as 255.0.255.0 is rejected, because its 1 bits must come first in one block.
The slash notation is called CIDR, and RFC 4632 defines it as an address followed by a slash and the number of leading bits that form the network part. The same RFC notes that /8, /16 and /24 match the sizes of the old class A, B and C networks.
| Prefix | Subnet mask | Wildcard mask | Total addresses | Usable hosts |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /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 |
How many usable hosts are in a /24?
A /24 has 254 usable hosts. The formula is 2 to the power of the host bits, minus 2. A /24 leaves 32 - 24 = 8 host bits, so 2^8 = 256 addresses, and 256 - 2 = 254 can go on devices. Two addresses are not for devices: the first one, with all host bits 0, names the subnet itself (the network address), and the last one, with all host bits 1, reaches every host on it (the broadcast address).
For the default example 192.168.1.10/24 the tool shows network 192.168.1.0, broadcast 192.168.1.255, first host 192.168.1.1 and last host 192.168.1.254. The address you typed is only one host inside that range. The same arithmetic gives 65,534 hosts in a /16, 62 in a /26 and 2 in a /30.
Two prefixes break the rule. A /32 is a single address, so the tool shows 1 usable host. A /31 has two addresses, and RFC 3021 says that on a point-to-point link both are used as host addresses, with no network or broadcast address. The tool shows 2 usable hosts for a /31 and notes it. A /30 spends four addresses on such a link for two hosts, which is the saving RFC 3021 describes.
What is the difference between a subnet mask and a wildcard mask?
A wildcard mask is the subnet mask turned inside out. The mask has 1 bits for the network and 0 bits for the hosts. The wildcard has 0 bits for the network and 1 bits for the hosts. To get it, subtract each number of the mask from 255: 255.255.255.0 becomes 0.0.0.255, and 255.255.255.192 becomes 0.0.0.63.
The wildcard is also the host part of the broadcast address, which is a quick check: the broadcast address is the network address with the wildcard added to it. Some network devices take the wildcard form in rules instead of the mask, so read the documentation of the device you configure. The tool shows both for any prefix so there is nothing to convert by hand.
How do I split a network into subnets?
Borrow bits from the host part. Each extra bit in the prefix doubles the number of subnets and halves the size of each. To split into 4, borrow 2 bits, so a /24 becomes four /26 blocks of 64 addresses and 62 usable hosts each. The number of equal subnets must be a power of 2: 2, 4, 8, 16 and so on. The tool rejects 3 or 5 and says why.
Splitting 192.168.1.0/24 into 4 gives the table below. Each block starts at the address right after the previous block's broadcast address, and the blocks do not overlap. To plan from a need instead, pick the smallest power of 2 that covers the number of subnets, then check that the usable hosts per subnet are enough. If not, borrow fewer bits. This tool cuts equal blocks only. Subnets of different sizes, called variable length masks, need one split per size.
| Subnet | Usable hosts | Broadcast |
|---|---|---|
| 192.168.1.0/26 | 192.168.1.1 - 192.168.1.62 | 192.168.1.63 |
| 192.168.1.64/26 | 192.168.1.65 - 192.168.1.126 | 192.168.1.127 |
| 192.168.1.128/26 | 192.168.1.129 - 192.168.1.190 | 192.168.1.191 |
| 192.168.1.192/26 | 192.168.1.193 - 192.168.1.254 | 192.168.1.255 |
Is my IP address private or public, and what is its class?
RFC 1918 reserves three blocks 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. An organization can use them without asking a registry, and packets with private addresses should not be forwarded across links between organizations. The tool labels an address private when it falls in one of them. It also names the loopback block 127.0.0.0/8, the link-local block 169.254.0.0/16, the shared address space 100.64.0.0/10 and the documentation blocks, from the IANA special-purpose registry. Anything outside those blocks shows as public.
The class comes from the first number. Class A starts with a 0 bit (0 to 127), class B with 10 (128 to 191) and class C with 110 (192 to 223), as RFC 791 describes. Class D (224 to 239) is multicast and class E is reserved, from RFC 1112. Classes no longer decide the mask, since RFC 4632 deprecated class-based assignment in favor of prefixes, so treat the class as history.
Prefixes in IPv6 work the same way over 128 bits. Type 2001:db8::/32 and the tool shows the network in the short form, the first and last address and the count: 79,228,162,514,264,337,593,543,950,336 addresses, which is 2^96, and 4,294,967,296 /64 blocks inside. IPv6 has no broadcast address, so every address in the prefix is counted. Addresses are written in the short form of RFC 5952: no leading zeros, lowercase, and the longest run of zero groups as ::.
Use it with
- Number Base Converter: binary, octal, decimal, hex.
- Chmod Calculator: unix permission calculator.
- Cron Expression Generator: build and explain cron schedules.
Questions
How do I calculate a subnet mask from a CIDR prefix?
Set the first N bits of a 32-bit number to 1 and the rest to 0, then write it as four numbers. A /24 is 255.255.255.0 and a /26 is 255.255.255.192.
How many usable hosts are in a /24?
254. A /24 has 256 addresses, and the network address and the broadcast address are not for devices, so 256 - 2 = 254.
What is the difference between a subnet mask and a wildcard mask?
The wildcard mask is the subnet mask with every bit flipped. The mask 255.255.255.0 has the wildcard 0.0.0.255. The mask has 1s for the network part, the wildcard has 1s for the host part.
How do I split a network into subnets?
Borrow bits from the host part. Each bit doubles the number of subnets and halves their size. A /24 split into 4 gives four /26 subnets: 192.168.1.0/26, 192.168.1.64/26, 192.168.1.128/26, 192.168.1.192/26.
What are the usable hosts of a /31 and a /32?
A /31 has two addresses, and RFC 3021 says both are host addresses on a point-to-point link, so there is no network or broadcast address. A /32 is one address, shown as 1 usable host.
Is my IP address sent anywhere?
No. The numbers are worked out in your browser and nothing you type leaves your device.
Sources
- RFC 1918: Address Allocation for Private Internets (IETF), read
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links (IETF), read
- RFC 4632: Classless Inter-domain Routing (CIDR) (IETF), read
- RFC 791: Internet Protocol, section 3.2 (IETF), read
- RFC 1112: Host Extensions for IP Multicasting (IETF), read
- IANA IPv4 Special-Purpose Address Registry, read
- RFC 4291: IP Version 6 Addressing Architecture (IETF), read
- RFC 5952: A Recommendation for IPv6 Address Text Representation (IETF), read
The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.