Home Calculators Categories Category: Computing, Web & Digital Media

Subnet Calculator: IPv4, IPv6 & CIDR Range Workstation

Enter any IPv4 or IPv6 address and a prefix length (or a dotted-decimal netmask for IPv4) and this subnet calculator returns the network CIDR, first and last address, subnet mask, wildcard mask, directed broadcast, usable host range, and the full binary breakdown. Every result is computed in your browser with exact integer (BigInt) arithmetic, so even a 128-bit IPv6 /64 shows its precise address count with no rounding. Nothing is sent over the network.

Input
Load an authored example. Editing the address or prefix selects Custom.
Quick load
IPv4 and IPv6 have different address lengths. Your last inputs for each version are remembered.

Switch versions to calculate either address format.

Enter an address only. Put its prefix in the next field. No ports, brackets or zone identifiers.
IPv4
Use a prefix such as 24 or /24. IPv4 also accepts a contiguous mask such as 255.255.255.0. IPv6 accepts 0–128.

IPv4: 0–32, /0–/32, or a dotted subnet mask.

All calculations run in your browser. This tool does not scan a network or check whether an address is in use.

Visual
Prefix and address bits Enter a valid IP address and prefix to show the fixed and variable bits. Prefix bits Address bits Input address in binary · prefix / remaining bits
Output
Network CIDR
—

Enter an address and prefix.

—
Normalized input address
—
Total addresses
—
Host/address bits
—
First address
—
Last address
—
Subnet mask
—
Wildcard mask
—
Directed broadcast
—
First host / endpoint
—
Last host / endpoint
—
Conventional host slots

Subnet arithmetic does not confirm assignability, reachability or provider-specific reservations. IPv4 host slots exclude only the network and directed broadcast for /0–/30.

How to Use the Subnet Calculator

  1. Select the IP version. Choose IPv4 (32 bits) or IPv6 (128 bits). The calculator remembers your last inputs for each version when you switch.
  2. Enter an address. Use a bare address such as 192.168.1.10 or 2001: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.
  3. Enter a prefix or netmask.
    • IPv4: a CIDR prefix from 0 to 32 (24 or /24), or a contiguous dotted mask such as 255.255.255.0. Non-contiguous masks like 255.0.255.0 are rejected.
    • IPv6: a prefix from 0 to 128. Dotted masks do not exist in IPv6 and are rejected.
  4. Read the results. The headline value is the network CIDR. The grid below it lists every derived value.
  5. 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.
  6. 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 2h2^{h} addresses in the block, shown as a full decimal integer, never scientific notation.
Host / Address Bits h=32−ph = 32 - p for IPv4, h=128−ph = 128 - p 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 2h−22^{h} - 2 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 pp splits the address into two parts:

  • the first pp bits identify the network (the prefix, shared by every address in the subnet);
  • the remaining hh bits identify the host or interface within that network.
h=N−pwhere N=32 (IPv4) or N=128 (IPv6)h = N - p \quad\text{where } N = 32 \text{ (IPv4) or } N = 128 \text{ (IPv6)}

The number of addresses in the block is:

Total addresses=2h=2N−p\text{Total addresses} = 2^{h} = 2^{N-p}

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 h=8h = 8 and therefore 28=2562^{8} = 256 addresses. A /23 has h=9h = 9 and 29=5122^{9} = 512.

Calculating the Network Address, Broadcast, and Range

Given an address AA and a mask MM (a 32-bit value with pp leading ones), all boundary values come from bitwise operations:

Network=A  &  M\text{Network} = A \;\&\; M
Wildcard=¬M=255.255.255.255−M\text{Wildcard} = \lnot M = 255.255.255.255 - M
Broadcast=Network  ∣  Wildcard\text{Broadcast} = \text{Network} \;|\; \text{Wildcard}
First host=Network+1Last host=Broadcast−1\text{First host} = \text{Network} + 1 \qquad \text{Last host} = \text{Broadcast} - 1

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 232=4,294,967,2962^{32} = 4{,}294{,}967{,}296 addresses and is the default route.

Why Usable Hosts Are 2h−22^h - 2, 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.
Usable hosts=2h−2(h≥2)\text{Usable hosts} = 2^{h} - 2 \qquad (h \ge 2)

Two prefixes break this rule, and a good ip subnet calculator must handle them correctly:

  • /31 (RFC 3021). A /31 has only two addresses. Under the old rule it would have zero usable hosts, but RFC 3021 defines /31 for point-to-point links: both addresses are valid endpoints and there is no broadcast address. This saves half the addresses compared to a /30 on router-to-router links. For 192.0.2.5/31, the pair is 192.0.2.4 and 192.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.

Block size=256−248=8\text{Block size} = 256 - 248 = 8

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 211=2,0482^{11} = 2{,}048
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 256−192=64256 - 192 = 64. 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:

  1. Write the mask as /p and compute h=32−ph = 32 - p.
  2. Find the network address by zeroing the last hh bits (or by using the block-size method above).
  3. Add 2h−12^{h} - 1 to the network address to get the last address (the broadcast for /0–/30).
  4. For conventional subnets, the usable range is network + 1+,1 through last − 1-,1.

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 + 2h−1+,2^{h} - 1 and is described by the prefix itself, not by "usable host" arithmetic.

IPv6 Subnetting

The same prefix logic applies to IPv6 with N=128N = 128, 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. /127 is permitted on router-to-router links (RFC 6164), and /128 is 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 2 pnew−pold2^{,p_{\text{new}} - p_{\text{old}}}. A /48 contains 264−48=216=65,5362^{64-48} = 2^{16} = 65{,}536 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 bb bits from a block, you create:

Number of subnets=2b\text{Number of subnets} = 2^{b}

each with h−bh - b host bits. Moving from /24 to /27 borrows b=3b = 3 bits, producing 23=82^{3} = 8 subnets of 25=322^{5} = 32 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 nn hosts into a conventional IPv4 subnet, find the smallest hh satisfying:

2h−2≥n⟹h=⌈log⁡2(n+2)⌉2^{h} - 2 \ge n \quad\Longrightarrow\quad h = \lceil \log_{2}(n + 2) \rceil

Then the prefix is p=32−hp = 32 - h. For 100 hosts: log⁡2(102)≈6.67\log_{2}(102) \approx 6.67, so h=7h = 7 and p=25p = 25 (126 usable). For 500 hosts: log⁡2(502)≈8.97\log_{2}(502) \approx 8.97, so h=9h = 9 and p=23p = 23 (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 /31 and /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/26 is not a network address; the network is 10.0.0.64/26.
  • Confusing wildcard and subnet masks. 0.0.0.255 is a wildcard (matches any last octet); 255.255.255.0 is the netmask for the same /24.
  • Entering CIDR notation in the address field. Put 192.168.1.10 in the address field and 24 in 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.010 is 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 232−p2^{32-p} for IPv4. For non-octet prefixes, use the block-size method: 256−mask octet256 - \text{mask octet}.

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?

264=18,446,744,073,709,551,6162^{64} = 18{,}446{,}744{,}073{,}709{,}551{,}616 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.

Calculation Methodology Documented

Read the formula definitions, supported input ranges, and limitations before using this estimate.

Review Methodology
Debjeet Bhowmick
Author Debjeet Bhowmick AWS Certified Solutions Architect • Cloud & DevOps Consultant

AWS Certified Solutions Architect Professional and Senior Cloud & DevOps Consultant with over 14 years of hands-on expertise architecting resilient cloud infrastructure across AWS, GCP, and Azure. Specializes in infrastructure as code, continuous delivery automation, and telemetry across Terraform, Ansible, Docker, Kubernetes, ELK, Python, and SQL. Creator of OrangeCalc, delivering client-side high-precision computational tools.