IP information · Local calculator

Network Prefix Calculator

Normalize either IP family to its aligned prefix and inclusive endpoints using exact integer arithmetic. One prefix can describe an interface subnet, an allocation or an aggregate route. CIDR gives each the same mathematical notation. The routing decision depends on which matching prefix is most specific.

Inputs

Result

Network prefix
2001:db8:1::/64
First
2001:db8:1::
Last
2001:db8:1:0:ffff:ffff:ffff:ffff
Addresses
18446744073709551616
In this guide12 sections

Introduction

Normalize either IP family to its aligned prefix and inclusive endpoints using exact integer arithmetic. One prefix can describe an interface subnet, an allocation or an aggregate route. CIDR gives each the same mathematical notation. The routing decision depends on which matching prefix is most specific.

Formula and calculation

Address block from a prefix
addresses = 2^(width − prefix); last = network + addresses − 1

A prefix fixes the leading bits and leaves the remaining bits available to identify values in the block. The calculator aligns the network address by clearing those remaining bits.

width · bits: 32 for IPv4 or 128 for IPv6
address length
prefix · bits
number of leading network bits
network · address
first aligned address in the block

Method and concepts

In a width-W address family, prefix length p fixes the first p bits and leaves W − p bits free. The canonical network value has zeroes in all free positions. The covered interval begins at that value and contains 2^(W − p) addresses.

  1. Enter the quantities in the units or notation shown by the input labels.
  2. Calculate and compare the output with the worked example.

CIDR and route aggregation diagram

  1. 0.0.0.0/0 · default
  2. 198.51.100.0/23 · campus
  3. 198.51.101.128/25 · east wing
  4. 198.51.101.180 · destination
All three prefixes contain the destination. In the illustrated IPv4 forwarding table, the east-wing /25 wins the longest-prefix comparison.

Worked examples

Locate a /27 boundary

  1. Enter 192.0.2.99/27. Five bits vary, giving blocks of 32.
  2. The containing network starts at .96 and ends at .127, including both endpoints.

CIDR and route aggregation: Compare an aggregate with a more specific route

  1. The adjacent blocks 198.51.100.0/24 and 198.51.101.0/24 differ only in the last bit of octet three. Their /23 parent begins at the even third octet 100 and contains 512 addresses.
  2. A destination of 198.51.101.180 also matches 198.51.101.128/25 because 180 lies between 128 and 255. Forward using the /25 entry when both entries are installed in the selected table.
  3. For 198.51.101.44, the /25 fails because 44 is below 128. The /23 still matches. For 192.0.2.1, neither specific prefix matches and the displayed default applies.

Reference table

Network Prefix Calculator reference
DestinationLongest matchExample path
198.51.101.180198.51.101.128/25East wing
198.51.101.44198.51.100.0/23Campus
192.0.2.10.0.0.0/0Default

Reading the result

Several entries can match one destination. Among installed routes in the selected forwarding table, the longest matching prefix provides the most specific destination rule. A /0 covers all addresses and can supply a default path.

Common mistakes

  • Combining any adjacent /24 pair into a /23 without checking the even-octet starting boundary.
  • Selecting the shortest matching route because it covers the largest interval.

Frequently asked questions

Can a /0 serve as an aggregate?

Mathematically it covers the entire family. In an IPv4 forwarding table, 0.0.0.0/0 is commonly used as the default route.

What happens when a component is already inside another input prefix?

Including it again changes neither the union nor the minimal covering prefix. To count additional space accurately, count distinct addresses in the union.

What does the slash number in CIDR notation count?

It is the number of leading address bits fixed by the prefix. For example, /24 fixes 24 bits and leaves eight bits in an IPv4 address.

Can a CIDR prefix represent a single address?

Yes. IPv4 /32 and IPv6 /128 represent exactly one address value and are commonly used for host routes or narrow policy entries.

Does CIDR notation by itself say which addresses a site assigned to hosts?

No. It identifies a prefix range. It does not show leases, reservations, router interfaces, exclusions, or whether a destination is reachable.

Why does longest-prefix match matter?

When several routes match a destination, routers generally prefer the most specific matching prefix, subject to routing-table policy and route selection rules.

What makes a CIDR prefix aligned?

All host bits in the network address are zero. If a supplied address has host bits set, its containing prefix begins at the nearest lower boundary for that prefix length.

Can two adjacent prefixes be summarized as one route?

Only when they are equal-sized, adjacent, and their combined range aligns on the larger prefix boundary. Route policy and downstream reachability must also support the summary.

Does a more-specific route always win in every routing decision?

Longest-prefix match selects the most specific matching route in the forwarding table, but protocol preference, policy, and route installation decide which candidates enter that table.

Does CIDR describe the allocation authority?

No. CIDR is a notation and routing technique. Registration records and address-management documentation describe allocation and stewardship.

How is a dotted IPv4 subnet mask related to CIDR?

A contiguous mask has a run of one bits followed by zero bits. The number of leading ones is the CIDR prefix length, such as 255.255.255.0 for /24.

Can an IPv6 network use CIDR notation?

Yes. The slash count works for either family: IPv4 prefixes range from /0 to /32, and IPv6 prefixes from /0 to /128.

What is a supernet?

A supernet is a larger prefix that aggregates smaller adjacent networks. It can reduce routing table entries when the component routes share a valid aligned parent range.

Why can route aggregation hide a failure?

A summary can continue to advertise reachability for a broad block even when one component network is unavailable. Routing design must ensure that a summary is withdrawn or backed by a path that can deliver the traffic.

What does a /0 route mean?

It matches every destination in its address family and is used as a default route when no more specific route is available.

Further learning and references