How to Use the Subnet Calculator
- Select the IP version. Choose
IPv4 (32 bits)orIPv6 (128 bits). The calculator remembers your last inputs for each version when you switch. - Enter an address. Use a bare address such as
192.168.1.10or2001:db8:abcd:12::1. Do not include a port, a/prefix, brackets, or a zone ID in this field. IPv4 octets must be 0–255 without leading zeros. IPv6 accepts full, compressed (::), and IPv4-mapped forms. - Enter a prefix or netmask.
- IPv4: a CIDR prefix from
0to32(24or/24), or a contiguous dotted mask such as255.255.255.0. Non-contiguous masks like255.0.255.0are rejected. - IPv6: a prefix from
0to128. Dotted masks do not exist in IPv6 and are rejected.
- IPv4: a CIDR prefix from
- Read the results. The headline value is the network CIDR. The grid below it lists every derived value.
- Inspect the bit diagram. The visualizer shows prefix bits versus host bits, with the full binary address grouped by octet (IPv4) or hextet (IPv6). Use the zoom and pan controls for 128-bit addresses.
- Copy or print. Copy a structured plaintext summary to the clipboard, or print a clean technical cut-sheet (or save it as PDF).
Presets are included for the three most common cases: IPv4 LAN /24 (192.168.1.10/24), IPv4 point-to-point /31 (192.0.2.5/31), and IPv6 example /64 (2001:db8:abcd:12::1/64).
What Each Result Means
| Result | Meaning |
|---|---|
| Network CIDR | The network address plus prefix length, e.g. 192.168.1.0/24. This is the canonical identifier of the subnet containing your address. |
| Normalized Input Address | Your address in canonical form (RFC 5952 for IPv6: lowercase, leading zeros removed, longest zero run compressed). |
| Total Addresses | Exactly addresses in the block, shown as a full decimal integer, never scientific notation. |
| Host / Address Bits | for IPv4, for IPv6. |
| First / Last Address | The numerically lowest and highest addresses in the block. |
| Subnet Mask | Contiguous dotted-decimal mask (IPv4 only). |
| Wildcard Mask | Bitwise inverse of the subnet mask (IPv4 only), used in OSPF network statements and Cisco-style ACLs. |
| Directed Broadcast | Highest address in an IPv4 /0–/30. Shown as "None" for /31 and /32, and "Not applicable" for IPv6. |
| First / Last Host (Endpoint) | Conventional usable range for IPv4. See the /31 and /32 rules below. "Not applicable" for IPv6. |
| Conventional Host Slots | for IPv4 /0–/30, 2 for /31, 1 for /32. |
| Binary Input Address | The full 32-bit or 128-bit binary form, zero-padded. |
Subnetting Fundamentals: Network Bits and Host Bits
An IPv4 address is a 32-bit integer, normally written as four 8-bit octets. An IPv6 address is a 128-bit integer, written as eight 16-bit hextets. A prefix length splits the address into two parts:
- the first bits identify the network (the prefix, shared by every address in the subnet);
- the remaining bits identify the host or interface within that network.
The number of addresses in the block is:
This is why a subnet bit calculator reduces to powers of two: every host bit you add doubles the block, and every bit you borrow for the network halves it. A /24 has and therefore addresses. A /23 has and .
Calculating the Network Address, Broadcast, and Range
Given an address and a mask (a 32-bit value with leading ones), all boundary values come from bitwise operations:
These formulas hold for IPv4 prefixes /0 through /30. The same AND operation finds the network of an IPv6 address; IPv6 simply has no broadcast address.
Netmask Calculator: Converting Between Subnet Masks and CIDR
A valid IPv4 netmask is a run of contiguous 1-bits followed by contiguous 0-bits. To convert a dotted mask to a CIDR prefix, count the 1-bits.
Example: 255.255.255.192
255 255 255 192
11111111.11111111.11111111.11000000
8 + 8 + 8 + 2 = 26 → /26
Going the other way, a prefix of /20 means 20 leading ones: 11111111.11111111.11110000.00000000, which is 255.255.240.0.
Only nine octet values can appear in a valid mask:
| Octet bits set | Decimal value | Binary |
|---|---|---|
| 0 | 0 | 00000000 |
| 1 | 128 | 10000000 |
| 2 | 192 | 11000000 |
| 3 | 224 | 11100000 |
| 4 | 240 | 11110000 |
| 5 | 248 | 11111000 |
| 6 | 252 | 11111100 |
| 7 | 254 | 11111110 |
| 8 | 255 | 11111111 |
A mask like 255.0.255.0 is non-contiguous. Classless addressing (RFC 4632) requires contiguous masks, and the calculator rejects anything else.
IPv4 CIDR Cheat Sheet (/8 to /32)
CIDR (Classless Inter-Domain Routing, defined in RFC 4632) replaced the old Class A/B/C scheme. A prefix can be any length from /0 to /32. The table lists total addresses and conventional usable hosts for each prefix.
| CIDR | Subnet Mask | Wildcard Mask | Host Bits | Total Addresses | Usable Hosts |
|---|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 24 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 23 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 22 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 21 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 20 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 19 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 18 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 17 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 16 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 15 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 14 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 13 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 12 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 11 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 10 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 9 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 8 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 7 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 6 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 5 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 4 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 3 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 2 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 1 | 2 | 2 (RFC 3021) |
| /32 | 255.255.255.255 | 0.0.0.0 | 0 | 1 | 1 (host route) |
/0 (0.0.0.0/0) covers the entire IPv4 space of addresses and is the default route.
Why Usable Hosts Are , and Where /31 and /32 Differ
In a conventional IPv4 subnet from /0 to /30, two addresses are reserved by convention:
- the network address (all host bits
0) identifies the subnet itself; - the directed broadcast address (all host bits
1) reaches every host on the subnet.
Two prefixes break this rule, and a good ip subnet calculator must handle them correctly:
/31(RFC 3021). A/31has only two addresses. Under the old rule it would have zero usable hosts, but RFC 3021 defines/31for point-to-point links: both addresses are valid endpoints and there is no broadcast address. This saves half the addresses compared to a/30on router-to-router links. For192.0.2.5/31, the pair is192.0.2.4and192.0.2.5, both usable./32. A single address. It is used for loopbacks, host routes, and firewall or ACL entries that match exactly one device. First and last address are identical, and there is no broadcast.
Many older devices still assume /30 for point-to-point links, so confirm /31 support on both ends before deploying it.
Worked Examples
Example 1: A Typical LAN, 192.168.1.10/24
| Value | Result |
|---|---|
| Network CIDR | 192.168.1.0/24 |
| Subnet mask | 255.255.255.0 |
| Wildcard mask | 0.0.0.255 |
| Total addresses | 256 |
| Directed broadcast | 192.168.1.255 |
| Host range | 192.168.1.1 – 192.168.1.254 |
| Usable hosts | 254 |
| Binary address | 11000000.10101000.00000001.00001010 |
The first 24 bits (11000000.10101000.00000001) are the network portion. The last 8 bits (00001010, decimal 10) are the host portion.
Example 2: A Non-Octet Boundary, 10.20.37.200/21
When the prefix does not fall on an octet boundary, use the block size method. The interesting octet is the one where the mask is neither 0 nor 255. For /21 the mask is 255.255.248.0, so the third octet is interesting.
Subnets in the third octet start at multiples of 8: 0, 8, 16, 24, 32, 40, ... The address has third octet 37, which lies in the block starting at 32.
| Value | Result |
|---|---|
| Network CIDR | 10.20.32.0/21 |
| Subnet mask | 255.255.248.0 |
| Wildcard mask | 0.0.7.255 |
| Total addresses | |
| Directed broadcast | 10.20.39.255 |
| Host range | 10.20.32.1 – 10.20.39.254 |
| Usable hosts | 2,046 |
Example 3: A Point-to-Point Link, 192.0.2.5/31
| Value | Result |
|---|---|
| Network CIDR | 192.0.2.4/31 |
| Subnet mask | 255.255.255.254 |
| Total addresses | 2 |
| Directed broadcast | None |
| First / last endpoint | 192.0.2.4 / 192.0.2.5 |
| Conventional host slots | 2 |
Example 4: A Small Subnet, 172.16.5.130/26
Mask 255.255.255.192, block size . Fourth-octet blocks start at 0, 64, 128, 192. Since 130 falls in the block starting at 128:
| Value | Result |
|---|---|
| Network CIDR | 172.16.5.128/26 |
| Directed broadcast | 172.16.5.191 |
| Host range | 172.16.5.129 – 172.16.5.190 |
| Usable hosts | 62 |
Example 5: An IPv6 /64, 2001:db8:abcd:12::1/64
| Value | Result |
|---|---|
| Network CIDR | 2001:db8:abcd:12::/64 |
| Host bits | 64 |
| Total addresses | 18,446,744,073,709,551,616 |
| First address | 2001:db8:abcd:12:: |
| Last address | 2001:db8:abcd:12:ffff:ffff:ffff:ffff |
| Broadcast / host range | Not applicable |
How to Find an IP Range from a Subnet
To get the ip range from subnet notation, follow these steps:
- Write the mask as
/pand compute . - Find the network address by zeroing the last bits (or by using the block-size method above).
- Add to the network address to get the last address (the broadcast for
/0–/30). - For conventional subnets, the usable range is network through last .
For /31, the range is both addresses. For /32, the range is the single address. For IPv6, the block runs from the network address to network and is described by the prefix itself, not by "usable host" arithmetic.
IPv6 Subnetting
The same prefix logic applies to IPv6 with , but the practice differs in important ways (RFC 4291):
- No broadcast. IPv6 uses multicast and anycast instead. There is no directed broadcast address, which is why the calculator reports "Not applicable".
- No "minus 2" host rule. Boundary addresses are mathematical. The all-zeros address in a subnet is reserved as the Subnet-Router anycast address, but IPv6 does not define a usable-host range by subtracting two.
- The /64 boundary. For global unicast addresses, the interface identifier is 64 bits, so LAN subnets are
/64. Stateless address autoconfiguration (SLAAC) depends on this. Do not subnet a LAN smaller than/64. - Point-to-point exceptions.
/127is permitted on router-to-router links (RFC 6164), and/128is used for loopbacks. - No masks. IPv6 uses prefix length only, never dotted masks.
IPv6 Prefix Reference
| Prefix | Host Bits | Total Addresses | Typical Use |
|---|---|---|---|
| /32 | 96 | 79,228,162,514,264,337,593,543,950,336 | Typical ISP / LIR allocation |
| /48 | 80 | 1,208,925,819,614,629,174,706,176 | Site assignment (holds 65,536 /64 subnets) |
| /56 | 72 | 4,722,366,482,869,645,213,696 | Small site or residential (holds 256 /64 subnets) |
| /64 | 64 | 18,446,744,073,709,551,616 | Single LAN segment |
| /127 | 1 | 2 | Router point-to-point link |
| /128 | 0 | 1 | Single host or loopback |
Splitting a larger prefix into smaller ones follows . A /48 contains subnets of size /64.
IPv6 Text Representation (RFC 5952)
The calculator normalizes every IPv6 input to the canonical form from RFC 5952:
- hexadecimal digits are lowercase;
- leading zeros in each hextet are removed;
- the longest run of consecutive all-zero hextets (length two or more) is replaced with
::, and if there is a tie the first run is compressed; - a single zero hextet is not compressed.
So 2001:0DB8:ABCD:0012:0000:0000:0000:0001 becomes 2001:db8:abcd:12::1.
Subnet Bit Calculator: Borrowing Bits and Splitting Networks
Subnetting a block means borrowing host bits to make network bits. If you borrow bits from a block, you create:
each with host bits. Moving from /24 to /27 borrows bits, producing subnets of addresses each (30 usable).
| Borrowed Bits | New Prefix (from /24) | Subnets | Addresses per Subnet | Usable Hosts |
|---|---|---|---|---|
| 1 | /25 | 2 | 128 | 126 |
| 2 | /26 | 4 | 64 | 62 |
| 3 | /27 | 8 | 32 | 30 |
| 4 | /28 | 16 | 16 | 14 |
| 5 | /29 | 32 | 8 | 6 |
| 6 | /30 | 64 | 4 | 2 |
Choosing a Prefix for a Host Count
To fit hosts into a conventional IPv4 subnet, find the smallest satisfying:
Then the prefix is . For 100 hosts: , so and (126 usable). For 500 hosts: , so and (510 usable).
VLSM Example
Variable Length Subnet Masking allocates different prefix sizes from one parent block. Allocate largest first to keep blocks aligned. Plan for 192.168.10.0/24 with these requirements:
| Segment | Hosts Needed | Prefix | Network | Usable Range | Broadcast |
|---|---|---|---|---|---|
| Users | 100 | /25 | 192.168.10.0/25 |
.1 – .126 |
192.168.10.127 |
| Servers | 50 | /26 | 192.168.10.128/26 |
.129 – .190 |
192.168.10.191 |
| Voice | 20 | /27 | 192.168.10.192/27 |
.193 – .222 |
192.168.10.223 |
| WAN link | 2 | /30 | 192.168.10.224/30 |
.225 – .226 |
192.168.10.227 |
The remaining space (192.168.10.228 – 192.168.10.255) is free for growth. Paste any network address from the table into the calculator to verify its boundaries.
Special-Purpose and Private IPv4 Ranges
| Range | CIDR | Purpose | Reference |
|---|---|---|---|
| 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 |
Private use | RFC 1918 |
| 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 |
Private use | RFC 1918 |
| 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 |
Private use | RFC 1918 |
| 100.64.0.0 – 100.127.255.255 | 100.64.0.0/10 |
Carrier-grade NAT shared space | RFC 6598 |
| 127.0.0.0 – 127.255.255.255 | 127.0.0.0/8 |
Loopback | RFC 1122 |
| 169.254.0.0 – 169.254.255.255 | 169.254.0.0/16 |
Link-local (APIPA) | RFC 3927 |
| 192.0.2.0 – 192.0.2.255 | 192.0.2.0/24 |
Documentation (TEST-NET-1) | RFC 5737 |
| 198.51.100.0 – 198.51.100.255 | 198.51.100.0/24 |
Documentation (TEST-NET-2) | RFC 5737 |
| 203.0.113.0 – 203.0.113.255 | 203.0.113.0/24 |
Documentation (TEST-NET-3) | RFC 5737 |
For IPv6, 2001:db8::/32 is reserved for documentation (RFC 3849), fc00::/7 for unique local addresses (RFC 4193), and fe80::/10 for link-local.
Common Subnetting Mistakes
- Applying "minus 2" to
/31and/32. Both are valid with RFC 3021 and host-route semantics, and the calculator reports them accordingly. - Misaligned subnets. A subnet must start on a multiple of its block size.
10.0.0.100/26is not a network address; the network is10.0.0.64/26. - Confusing wildcard and subnet masks.
0.0.0.255is a wildcard (matches any last octet);255.255.255.0is the netmask for the same/24. - Entering CIDR notation in the address field. Put
192.168.1.10in the address field and24in the prefix field. Include no slash, port, or brackets in the address. - Subnetting IPv6 LANs smaller than /64. This breaks SLAAC and some neighbor discovery behaviour.
- Leading zeros.
192.168.001.010is rejected: some systems read leading-zero octets as octal, so the calculator requires unambiguous decimal.
Limitations and Standards
This is a pure mathematical subnet calculator. It follows:
- RFC 4632 – CIDR addressing and prefix notation
- RFC 3021 – 31-bit prefixes on IPv4 point-to-point links
- RFC 4291 – IPv6 addressing architecture (no broadcast; multicast and anycast)
- RFC 5952 – Recommended IPv6 text representation
It does not scan networks, perform DNS lookups, check public reachability, or call any external API. It also does not subtract cloud-provider reservations. AWS and Azure reserve five addresses in every subnet and Google Cloud reserves four in each primary range, so subtract those from the conventional host count when sizing cloud subnets and confirm current figures in your provider's documentation.
Frequently Asked Questions
What is a subnet calculator?
A subnet calculator takes an IP address and a prefix length or netmask and computes the network block it belongs to: the network address, first and last address, mask, wildcard mask, broadcast address, and number of usable hosts.
How do I calculate a subnet manually?
Convert the address and mask to binary, AND them to get the network address, then OR the network with the wildcard mask to get the broadcast. Total addresses are for IPv4. For non-octet prefixes, use the block-size method: .
What is the difference between a netmask and a CIDR prefix?
They describe the same thing in two notations. 255.255.255.0 and /24 both mean 24 leading network bits. CIDR notation is shorter and is the only form IPv6 uses.
How many usable hosts are in a /24?
A /24 has 256 total addresses and 254 conventional usable hosts, since the network address (.0) and broadcast address (.255) are reserved.
Why does a /31 have two usable addresses?
RFC 3021 allows /31 prefixes on point-to-point links. With only two devices on the link, a network and broadcast address are unnecessary, so both addresses are usable endpoints.
What is a wildcard mask?
A wildcard mask is the bitwise inverse of the subnet mask. A /24 has netmask 255.255.255.0 and wildcard 0.0.0.255. Routing protocols such as OSPF and many access-list syntaxes use wildcards to match address ranges.
Does IPv6 have a broadcast address or subnet mask?
No. IPv6 replaced broadcast with multicast and anycast (RFC 4291) and uses prefix length instead of dotted masks.
How many addresses are in an IPv6 /64?
addresses. The calculator shows this exact integer using BigInt arithmetic.
What is the difference between a CIDR calculator and a subnet calculator?
In practice they are the same tool. "CIDR calculator" emphasizes slash notation and block sizing, while "subnet calculator" emphasizes the resulting network boundaries and host ranges. This page provides both.
Can I enter a netmask instead of a prefix?
For IPv4, yes: enter a contiguous dotted mask such as 255.255.254.0 in the prefix field and it is converted to /23. For IPv6, enter a prefix from 0 to 128.
Is my data sent to a server?
No. All calculations run locally in your browser. No address is transmitted, stored, or scanned.
Read the formula definitions, supported input ranges, and limitations before using this estimate.