Technical utilities · Calculation notebook

IPv4 & IPv6 Subnet Calculator: Address Range: Worked Examples

Explain IPv4 and IPv6 subnet boundaries with bit masks and worked address ranges. Check exact counts, compressed IPv6 and special IPv4 /31 and /32 cases.

Why the calculation is structured this way

A prefix fixes leading bits and leaves width minus prefix host bits. IPv4 width is 32; IPv6 width is 128. Exact integer arithmetic is essential for large IPv6 boundaries and counts. Traditional IPv4 first/last reservations have /31 and /32 exceptions; IPv6 does not use IPv4-style broadcast.

A second scenario you can verify

IPv4 192.0.2.130/25 belongs to 192.0.2.128/25, whose raw range is .128 through .255 with 128 addresses and 126 traditional broadcast-subnet hosts. IPv6 2001:db8::5/126 belongs to 2001:db8::4/126 and contains four addresses, ::4 through ::7; there is no IPv4-style minus-two broadcast subtraction.

What changes the interpretation

A normalized network is not the original endpoint. Save both when auditing an address. Prefix math does not identify private allocation ownership, routing permissions, device capacity or firewall safety; those require operational context.

Audit network alignment and family-specific output meaning

Check the address family before reading a prefix. IPv4 uses four eight-bit octets and a prefix from zero to thirty-two. IPv6 uses 128 bits and a prefix from zero to 128. Compression in IPv6 text does not change that width. A slash value that is valid for one family can be invalid for the other, so the family is part of input validation.

For IPv4 192.0.2.77/28, four host bits give sixteen raw addresses. Clearing the low four bits yields network 192.0.2.64 and final address 192.0.2.79. Under the ordinary broadcast-subnet convention, the endpoint labels leave fourteen traditional host addresses. Moving the input to .78 stays within the same block; moving to .80 begins the next aligned block.

For IPv6 2001:db8::77/124, four host bits also give sixteen raw addresses. The containing block begins at hexadecimal ::70 and ends ::7f. The similar remaining-bit count does not justify an IPv4-style broadcast subtraction. An exact boundary check should compare full integer values, not alphabetic text order of compressed addresses.

The output does not assign an address or test connectivity. A host route, point-to-point link and conventional broadcast subnet can use different operational interpretations. Keep network label, original endpoint, prefix and raw count in an audit record. Large IPv6 values must remain exact across serialization; converting their count string to a floating-point number can lose low-order information.

Input reference and units

These values reproduce the model’s demonstration. Replace them with your own records or measurements; they are not recommended targets.

On a small screen, swipe horizontally to see all columns. With a keyboard, focus the table and use the arrow keys.

Parameters used by this calculator
ParameterDemonstration valueHow to enter it
IPv4 or IPv6 address192.168.1.10 Enter ipv4 or ipv6 address without adding a unit suffix. Scope: IPv4 uses /0–/32, with /31 point-to-point and /32 single-address host-count conventions. IPv6 uses /0–/128 and has no broadcast-address subtraction.
Prefix length (IPv4 0–32; IPv6 0–128)24 Enter prefix length (ipv4 0–32; ipv6 0–128) without adding a unit suffix. Scope: IPv4 uses /0–/32, with /31 point-to-point and /32 single-address host-count conventions. IPv6 uses /0–/128 and has no broadcast-address subtraction.

Subnet Calculator: calculation relationships

Calculate IPv4 or IPv6 network boundaries, mask, last address and exact address count. Compressed IPv6 and embedded IPv4 tails are accepted; IPv6 counts remain exact decimal strings. IPv4 uses /0–/32, with /31 point-to-point and /32 single-address host-count conventions. IPv6 uses /0–/128 and has no broadcast-address subtraction. A count does not establish device routability or subnet allocation policy. VLSM planning, zone identifiers, discovery and configuration are outside this tool.

The prefix fixes network bits and leaves 32−prefix host bits. A /30 has 2²=4 addresses; 192.0.2.6 belongs to the block 192.0.2.4–192.0.2.7 with mask 255.255.255.252. Under the traditional broadcast convention, two addresses are usable hosts. /31 point-to-point links and /32 addresses use the separately stated exceptions. IPv6 prefixes instead span 0–128. A /128 is one address; a /127 is two. Compressed input is expanded internally before applying the mask, then output follows longest-zero-run compression.

size = 2^(address bits−prefix); network = floor(address/size) × size; address bits = 32 or 128
  • address: IPv4 or IPv6 address. Enter ipv4 or ipv6 address without adding a unit suffix. Scope: IPv4 uses /0–/32, with /31 point-to-point and /32 single-address host-count conventions. IPv6 uses /0–/128 and has no broadcast-address subtraction.
  • prefix: Prefix length (IPv4 0–32; IPv6 0–128). Enter prefix length (ipv4 0–32; ipv6 0–128) without adding a unit suffix. Scope: IPv4 uses /0–/32, with /31 point-to-point and /32 single-address host-count conventions. IPv6 uses /0–/128 and has no broadcast-address subtraction.
  • Result units: stated beside each output
  • Calculation relationship: size = 2^(address bits−prefix); network = floor(address/size) × size; address bits = 32 or 128
  • Supported domain: see the limits below

Worked example

Subnet Calculator baseline input: IPv4 or IPv6 address: 192.168.1.10; Prefix length (IPv4 0–32; IPv6 0–128): 24. Output: Network = 192.168.1.0; Subnet mask = 255.255.255.0; Last address = 192.168.1.255; Address count = 256; Usable hosts (RFC 3021 for /31) = 254. Substitute these values into the displayed equation to reproduce the result.

Reproduce the default scenario

This reproduces the default inputs in the reference table above; it is not an additional independent example. Displayed rounding may differ from intermediate precision.

Network
192.168.1.0
Subnet mask
255.255.255.0
Last address
192.168.1.255
Address count
256
Usable hosts (RFC 3021 for /31)
254

Common questions and boundary checks

Can this handle IPv6?

Yes. It uses 128-bit prefix arithmetic and exact large address counts.

Why does my entered address normalize?

Host bits are cleared to identify the containing prefix.

Does IPv6 reserve a broadcast endpoint?

No IPv4-style broadcast endpoint is subtracted from the raw range.

Why do /31 and /32 differ from ordinary IPv4 host counts?

/31 has a point-to-point convention and /32 is a single-address range.

Does the result authorize an allocation?

No. It is range arithmetic, not an operational assignment.

Sources and content notes

Toolify describes the implemented algorithm and its assumptions. Sources below support the topic or applicable rules; they do not endorse this calculator. Examples are illustrative, and published rules take precedence over simplified estimates.

Report a formula, example or translation issue through our contact page. Include the tool name, inputs and expected result so it can be reproduced. Contact Toolify

From question to result

Continue with a related question

Explore all Technical utilities tools and guides