Network mathematics · Offline reference

Network Prefix Reference

A slash length specifies how many address bits are fixed. Use this reference to translate a routing prefix into a bit boundary and count the address patterns beneath it in either IP family.

Inputs

Result

Address count
256
Network mask
255.255.255.0
Bits after prefix
8
Address bits Prefix 24 · 8 host bits

Binary address value 11111111111111111111111100000000. The first 24 bits belong to the prefix.

In this guide12 sections

Introduction

A slash length specifies how many address bits are fixed. Use this reference to translate a routing prefix into a bit boundary and count the address patterns beneath it in either IP family.

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

Let W be the address width and P the prefix length. The first P bits are fixed and the remaining W − P bits vary independently. A prefix therefore covers 2^(W − P) addresses. Increasing P by one splits an aligned block into two equal children.

  1. Choose IPv4 for a 32-bit address or IPv6 for a 128-bit address. Select a prefix length within that width.
  2. Read the address count as the size of a whole block. To count child networks, subtract the parent prefix length from the child prefix length and raise two to the difference.

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

Compare an IPv4 /26 and an IPv6 /60

  1. For IPv4 /26, six positions vary. The count is 2⁶ = 64, and the final mask octet is 11000000, or 192.
  2. For IPv6 /60, 68 positions vary. Extending the prefix by four bits to /64 yields 2⁴ = 16 child prefixes.
  3. For 2001:db8:0:1200::/60, those children run from 2001:db8:0:1200::/64 through 2001:db8:0:120f::/64. Only the final digit of the fourth group changes.

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 Reference reference
Family and prefixVariable bitsBlock size
IPv4 /248256 addresses
IPv4 /3112 addresses
IPv6 /64642⁶⁴ addresses
IPv6 /12801 address

Reading the result

A count of addresses and a count of subnets answer different planning questions. Site plans commonly budget IPv6 /64 prefixes. Counting individual addresses in the entire delegation gives a much larger number that cannot substitute for that budget.

Common mistakes

  • Applying a 32-bit width to IPv6 changes the exponent by 96.
  • Subtracting two from every address count misstates IPv4 point-to-point and single-address prefixes. IPv6 has no broadcast address.

Frequently asked questions

What does /0 cover?

Zero bits are fixed, so every address in that IP family matches. An IPv4 /0 contains 2³² addresses and an IPv6 /0 contains 2¹²⁸.

Why does /32 have different meanings?

An IPv4 /32 fixes the entire address. An IPv6 /32 leaves 96 variable bits. The family supplies the width that gives the slash length meaning.

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