Introduction
CIDR notation packs a network address and its mask into a single compact string like `192.168.1.0/24`. This tool parses both IPv4 and IPv6 CIDR blocks, computes the network address, broadcast address, subnet mask, wildcard mask, usable host range, and host count. It also includes a range-to-CIDR divider that finds the optimal set of CIDR blocks covering an arbitrary IPv4 start-to-end range. Everything runs in your browser with no server round-trips.
What this tool does
- Parse IPv4 CIDR notation (e.g. `10.0.0.0/8`) and compute network address, broadcast, subnet mask, wildcard mask, usable host count, and first/last host addresses
- Parse IPv6 CIDR notation (e.g. `2001:db8::/32`) with full `::` expansion, computing the compressed and expanded forms, address count, and address range
- Display the binary representation of both the IP address and subnet mask for IPv4, with network and host bit counts
- Divide an arbitrary IPv4 start-to-end range into the minimal set of aligned CIDR blocks using a greedy alignment algorithm
- Auto-detect IPv4 vs IPv6 based on the presence of colons in the input, so you do not need to specify the version
- Handle edge cases including /31 and /32 (point-to-point and single-host) per RFC 3021
How this tool works
The tool detects IPv4 or IPv6 by checking for colons in the input. For IPv4, it converts the dotted-decimal address to a 32-bit unsigned integer by multiplying each octet by powers of 256. The prefix length (the number after the slash) determines the subnet mask: a left shift of `0xffffffff` by `32 - prefix` bits. The network address is the IP ANDed with the mask, and the broadcast is the network ORed with the bitwise NOT of the mask.
Host count follows RFC 3021 for /31 and /32. For prefixes shorter than /31, usable hosts equal `2^(32-prefix) - 2` (subtracting network and broadcast). For /31, both addresses are usable (point-to-point links). For /32, there is exactly one host.
For IPv6, the tool uses BigInt arithmetic since 128-bit values exceed JavaScript's 53-bit safe integer range. The `::` shorthand is expanded by splitting on the double colon, counting missing groups, and padding with zeros. The mask is constructed as a BigInt by shifting `1n << BigInt(prefix)` and masking. Address count is `2^(128-prefix)`, displayed as a decimal string since these numbers can be astronomically large.
The range divider works by iterating from the start IP to the end IP, finding the largest CIDR block at each position that is both aligned (the current address ANDed with the block mask equals the current address) and does not exceed the end address. This greedy approach produces the minimal set of CIDR blocks.
How CIDR notation works (RFC 4632, RFC 4291)
CIDR (Classless Inter-Domain Routing) is specified in RFC 4632, published in August 2006. It replaced the old classful addressing system (Class A, B, C) with a flexible prefix-length scheme. The notation `a.b.c.d/n` means the first `n` bits of the address form the network prefix, and the remaining `32 - n` bits identify hosts within that network.
Before CIDR, IPv4 addresses were divided into fixed classes: Class A used /8, Class B used /16, Class C used /24. This was wasteful. An organization needing 500 hosts had to take a Class B network (65,536 addresses) because a Class C (254 hosts) was too small. CIDR allows any prefix length from /0 to /32, so that same organization can use a /23 (510 hosts) instead.
IPv6 addressing is defined in RFC 4291. IPv6 uses 128-bit addresses with the same CIDR prefix notation, but prefixes range from /0 to /128. The `::` shorthand compresses consecutive zero groups, and the standard requires at least one zero group to be present for compression. A /64 is the standard subnet size for a single LAN, and a /48 is a typical site prefix allocation.
The subnet mask is a bitmask where the first `n` bits are 1 and the rest are 0. The wildcard mask (used in ACLs on Cisco devices) is the bitwise NOT of the subnet mask. For binary conversions and other number system operations, see the Binary to Text, Hex Encode/Decode, and Number System Converter tools.
How to use this tool
- Enter a CIDR block in the input field, e.g. `192.168.1.0/24` for IPv4 or `2001:db8::/32` for IPv6. The tool auto-detects the version
- The output panel shows the network address, broadcast (IPv4 only), subnet mask, wildcard mask, and host range
- For IPv4, check the binary representation section to see the address and mask in binary with network and host bit counts
- To divide an IPv4 range, enter start and end addresses in the Subnet Divider section and click Divide Range
- The divider outputs the minimal set of aligned CIDR blocks that cover the range, with host counts for each block
- Adjust the prefix length to see how the subnet boundaries change. A /24 gives 254 usable hosts, a /26 gives 62, a /28 gives 14
Real-world examples
Planning a VPC subnet in AWS
You need 4 subnets inside a 10.0.0.0/24 VPC. Enter `10.0.0.0/24` and the tool shows 254 usable hosts. To split it into 4 equal subnets, use /26 each: 10.0.0.0/26, 10.0.0.64/26, 10.0.0.128/26, 10.0.0.192/26. Each has 62 usable hosts. The tool confirms the network and broadcast addresses for each.
Dividing a non-aligned IP range
You need CIDR blocks for 10.0.5.10 through 10.0.5.200. Enter these in the Subnet Divider and click Divide Range. The tool outputs multiple blocks like `10.0.5.10/31`, `10.0.5.12/30`, `10.0.5.16/28`, `10.0.5.32/27`, `10.0.5.64/26`, `10.0.5.128/26`, and `10.0.5.192/29` because the range does not align to a single CIDR block.
IPv6 subnet sizing
Enter `2001:db8::/64` to see the standard LAN subnet size. The address count is 18,446,744,073,709,551,616 (2^64). The expanded form shows all 8 groups: `2001:0db8:0000:0000:0000:0000:0000:0000`. A /48 site prefix contains 2^80 addresses, which is more than enough for 65,536 /64 subnets.
Point-to-point /31 links
Enter `10.0.0.0/31` and the tool shows 2 usable hosts (10.0.0.0 and 10.0.0.1) with no broadcast address. This follows RFC 3021, which defines /31 prefixes for point-to-point links between routers, saving one address compared to the traditional /30 approach.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| /24 (IPv4) | 256 addresses, 254 usable hosts | Small office or home network |
| /16 (IPv4) | 65,536 addresses, 65,534 usable | Large enterprise subnet |
| /8 (IPv4) | 16,777,216 addresses | Major allocation, ISP block |
| /64 (IPv6) | 2^64 addresses, standard LAN | Single IPv6 subnet |
| /48 (IPv6) | 2^80 addresses, 65,536 /64s | Site prefix allocation |
| /31 (IPv4) | 2 addresses, no broadcast | Point-to-point router links (RFC 3021) |
Limitations or considerations
This tool does not validate whether an address falls within reserved or private ranges. It computes the mathematical subnet boundaries but does not check IANA assignments. For example, 10.0.0.0/8 is private (RFC 1918) and 127.0.0.0/8 is loopback, but the tool treats them identically to public ranges.
The range divider supports IPv4 only. IPv6 range division would produce extremely large block lists for non-aligned ranges and is not included.
The IPv6 binary representation shows all 128 bits with colons every 16 bits. This is useful for understanding the structure but is not a standard notation format.
The tool does not perform reverse DNS lookups, WHOIS queries, or geolocation. It is a pure calculator for subnet arithmetic.
Frequently asked questions
What is the difference between a subnet mask and CIDR notation?
They represent the same information. A subnet mask like 255.255.255.0 is the dotted-decimal form of a 24-bit prefix. CIDR notation writes this as /24. The mask has 24 ones followed by 8 zeros in binary. CIDR is more compact and is the standard in routing configurations.
How many usable hosts are in a /26?
A /26 has 32 addresses (2^6). Subtracting the network and broadcast addresses gives 30 usable hosts. For /31, both addresses are usable per RFC 3021. For /32, there is exactly one address (used for loopback or single-host routes).
Why does the IPv6 address count use BigInt?
IPv6 addresses are 128 bits. JavaScript numbers are 64-bit floats with only 53 bits of integer precision. A /64 subnet contains 2^64 addresses, which exceeds the maximum safe integer. The tool uses BigInt to handle these values accurately.
What does the wildcard mask do?
The wildcard mask is the bitwise NOT of the subnet mask. Where the subnet mask has 1s (network bits), the wildcard has 0s. Where the subnet mask has 0s (host bits), the wildcard has 1s. Cisco ACLs use wildcard masks instead of subnet masks. For 255.255.255.0, the wildcard is 0.0.0.255.
Can this tool help with firewall rules?
Yes. If you need to allow a range of IPs in a firewall rule, enter the start and end addresses in the Subnet Divider. The tool outputs the minimal CIDR block list, which you can paste directly into iptables, AWS security groups, or similar firewall configurations.
Conclusion
CIDR notation is the standard way to express IP subnet boundaries, and understanding the math behind it is a core skill for network engineers and cloud architects. This tool handles both IPv4 and IPv6, with a range divider for non-aligned blocks. For binary and hex conversions of individual addresses, see the Binary to Text and Hex Encode/Decode tools. For base conversions between decimal, binary, and other number systems, use the Number System Converter.