Subnet / CIDR calculator
Work out network, broadcast, usable host range and mask from any CIDR block.
Have feedback or an idea for this tool?
What is a subnet and CIDR block?
A subnet is a slice of an IP network, and CIDR notation writes it as an address followed by a prefix length, such as 192.168.1.0/24. The prefix says how many leading bits are fixed as the network, leaving the rest for hosts: a /24 fixes 24 bits and leaves 254 usable addresses, while a /22 leaves 1022. This calculator takes any IPv4 CIDR block and works out the network address, the broadcast address, the netmask and wildcard, the usable host range, and the total host count. Enter a block and read the results instantly. Use it to plan address space, to size a subnet before you create it, to set firewall or routing rules that reference a range, or to check that two networks do not overlap before you connect them.
Key facts
- The CIDR prefix is the number of leading bits fixed as the network part of an address, so a /24 fixes the first 24 bits and leaves 8 host bits.
- The number of usable hosts on an IPv4 subnet equals 2^(32 - prefix) - 2, subtracting the network address and the broadcast address.
- An IPv4 /24 network has 256 total addresses and 254 usable hosts, with a subnet mask of 255.255.255.0.
- A /30 subnet has 4 addresses and exactly 2 usable hosts (mask 255.255.255.252), which is the classic mask for a point-to-point link between two routers.
- RFC 1918 reserves three private IPv4 ranges that are not routed on the public internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.
What a subnet calculator works out
A subnet is a slice of an IP address space defined by a prefix length. Given an address and a CIDR prefix such as 192.168.1.0/24, the calculator derives five things engineers actually need: the subnet mask, the network address, the broadcast address, the range of usable host addresses and the count of usable hosts.
The prefix (the number after the slash) is how many leading bits are fixed as the network part. Everything to its right is the host part. A /24 fixes the first 24 bits, leaving 8 host bits; a /26 fixes 26 bits, leaving 6 host bits. More network bits means a smaller subnet.
Doing this by hand means converting octets to binary and masking. The calculator does the bit math for you and shows the binary breakdown so the result is easy to sanity-check.
CIDR notation and the subnet mask
CIDR (Classless Inter-Domain Routing) notation writes the mask as a prefix length instead of a dotted-decimal mask. The two are the same information in different form: /24 is 255.255.255.0, /25 is 255.255.255.128, /26 is 255.255.255.192, /30 is 255.255.255.252.
To convert a prefix to a mask, set that many high bits to 1 and the rest to 0, then group into four octets. For /26 that is 11111111.11111111.11111111.11000000, which is 255.255.255.192. The value 192 comes from 128 + 64, the two high bits of the last octet.
The network address is the IP with all host bits set to 0; the broadcast address is the same block with all host bits set to 1. Any address strictly between those two is assignable to a host.
How to compute usable hosts
For IPv4, the total addresses in a block is 2^(32 - prefix). Two of those are reserved on a normal subnet - the network address and the broadcast address - so the usable host count is 2^(32 - prefix) - 2.
Worked example: 192.168.1.0/24. Here 32 - 24 = 8 host bits, so 2^8 = 256 total addresses. Subtract 2 and you get 254 usable hosts. The mask is 255.255.255.0, the network address is 192.168.1.0, the broadcast is 192.168.1.255, and the usable host range runs from 192.168.1.1 to 192.168.1.254.
A quick reference: /24 = 256 addresses / 254 hosts, /25 = 128 / 126, /26 = 64 / 62, /27 = 32 / 30, /28 = 16 / 14, /29 = 8 / 6, /30 = 4 / 2. Each step up in prefix halves the block.
Special cases, IPv6 and private ranges
A /30 has 4 addresses and exactly 2 usable hosts, which is the classic mask for a point-to-point link between two routers. A /31 has only 2 addresses and by the old rule leaves 0 usable hosts, but RFC 3021 permits using both addresses on a point-to-point link, so many devices treat a /31 as 2 usable hosts with no broadcast.
IPv6 changes the arithmetic. There is no broadcast address and subnets are almost always /64, giving 2^64 addresses per subnet, so the network / broadcast subtraction does not apply the same way. This calculator reports the IPv6 network, the address range and the total address count for the prefix.
For lab and internal work, use the RFC 1918 private ranges: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. These are not routable on the public internet, which is why they are safe defaults for VPCs, home labs and VM networks.
Glossary
- CIDR
- CIDR (Classless Inter-Domain Routing) is the notation that writes a subnet as an address followed by a slash and a prefix length, such as 192.168.1.0/24. The prefix states how many leading bits are the network part.
- Subnet mask
- A subnet mask is a 32-bit value whose leading 1 bits mark the network part of an address and trailing 0 bits mark the host part. A /24 prefix corresponds to the mask 255.255.255.0.
- Network address
- The network address is the first address in a subnet, formed by setting all host bits to zero. It identifies the subnet itself and is not assigned to a host.
- Broadcast address
- The broadcast address is the last address in an IPv4 subnet, formed by setting all host bits to one. Traffic sent to it reaches every host on the subnet, so it is not assigned to an individual host.
- Usable host range
- The usable host range is the block of addresses between the network address and the broadcast address that can be assigned to devices. On an IPv4 subnet the count equals 2 raised to the number of host bits, minus 2.
- RFC 1918 private ranges
- RFC 1918 reserves three IPv4 ranges - 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 - for private networks. Addresses in these ranges are not routed on the public internet.
Questions, answered.
What does the CIDR number mean?+
The number after the slash, such as /24, is how many leading bits form the network part of the address. A larger prefix means fewer host bits and therefore a smaller subnet with fewer usable hosts.
How many usable hosts are in a /24?+
An IPv4 /24 has 256 total addresses and 254 usable hosts, because the network address (x.x.x.0) and the broadcast address (x.x.x.255) are reserved. The mask is 255.255.255.0.
How do I calculate usable hosts from a prefix?+
For IPv4 the formula is 2^(32 - prefix) - 2. The 2^(32 - prefix) part is the total addresses in the block, and you subtract 2 for the network and broadcast addresses. For example a /26 gives 2^6 - 2 = 62 usable hosts.
What is a /30 subnet used for?+
A /30 has 4 addresses and exactly 2 usable hosts (mask 255.255.255.252). It is the traditional choice for a point-to-point link between two routers, where you only need one address on each end.
Why does a /31 show zero or two usable hosts?+
A /31 has only 2 addresses. By the classic rule both are reserved as network and broadcast, leaving 0 usable hosts. RFC 3021 allows both addresses to be used on a point-to-point link with no broadcast, so modern devices often treat a /31 as 2 usable hosts.
How is IPv6 subnetting different?+
IPv6 has no broadcast address, and subnets are almost always /64, which holds 2^64 addresses. Because of that scale, the network and broadcast subtraction used for IPv4 does not apply the same way; the calculator instead reports the network, the address range and the total address count.
Which IP ranges are private?+
RFC 1918 reserves three private IPv4 ranges that are not routed on the public internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Use these for internal networks, VPCs, home labs and VM subnets.
Is my IP or subnet sent to a server?+
No. Every result is computed in your browser using the bit math above, so nothing you enter is sent anywhere or stored.
Cloud that speaks India.
These tools run on ServerCake infrastructure in India. When our cloud opens, you get VMs and managed databases priced in ₹, billed with GST, on India-resident infrastructure. Reserve your spot for early access.
Reserve your spotMore tools
Latency to Mumbai Soon
Measure your round-trip time to the ServerCake Mumbai region and compare it to distant clouds.
What's my IP Live
See your IPv4 / IPv6, ISP, ASN, city and country, plus the headers your browser sends. Enriched on our servers, never shared.
DNS lookup Live
Query A, AAAA, MX, TXT, NS, CNAME and SOA records for any domain.