IPv4 · Local calculator

CIDR Calculator

CIDR writes an address block as a starting address and a count of fixed bits. Use it to interpret a route such as 172.20.16.0/20, even when the boundary falls inside an octet.

Inputs

Result

Network prefix
192.0.2.64/26
Prefix bits
26
Host bits
6
Address count
64
Subnet mask
255.255.255.192
Inclusive interval
192.0.2.64 – 192.0.2.127
Address bits Prefix 26 · 6 host bits

Binary address value 11000000000000000000001001001101. The first 26 bits belong to the prefix.

Clearing every host bit gives the aligned route. Each additional prefix bit halves the size of the block.

In this guide12 sections

Introduction

CIDR writes an address block as a starting address and a count of fixed bits. Use it to interpret a route such as 172.20.16.0/20, even when the boundary falls inside an octet.

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

CIDR stands for Classless Inter-domain Routing. The slash length counts bits from the most significant end. The canonical block identifier has zeros in every host-bit position. A prefix may describe an aggregate containing many subnets, so its address count alone does not establish a LAN host capacity.

  1. Enter the address with its slash length. For IPv4 the length is an integer from 0 through 32.
  2. Locate the octet containing the prefix boundary. Convert its fixed bits into a mask and clear the remaining bits of the input.
  3. Read the canonical prefix beside both boundaries. Use the canonical value when recording the block in a route inventory.

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

Normalize a /20 route from an interface record

  1. For 172.20.29.209/20, the first 16 bits fix 172.20. Another four fix the upper half of octet three. The mask is 255.255.240.0.
  2. The third octet 29 is 00011101. Keeping its leading 0001 gives 16 at the bottom and 31 at the top. The fourth octet can run from 0 to 255.
  3. The resulting route is 172.20.16.0/20. Its final address is 172.20.31.255. Count 16 values of the third octet times 256 values of the fourth to obtain 4,096.

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

CIDR Calculator reference
Prefix lengthUnfixed bitsAddresses per block
/0324,294,967,296
/20124,096
/248256
/3201

Reading the result

A higher slash length fixes more bits and yields a smaller block. The default route 0.0.0.0/0 matches every IPv4 destination at the prefix-comparison step. A more specific matching route takes precedence in longest-prefix matching.

Common mistakes

  • Reading /20 as twenty host bits. It leaves twelve host bits.
  • Dropping only the final octet when normalizing an address whose prefix boundary is in the third octet.

Frequently asked questions

Do 172.20.16.0/20 and 172.20.29.209/20 describe the same block?

Yes. Both have the same first 20 bits. The first spelling is the canonical network identifier. The second also preserves a particular address inside it.

How many /24 blocks fit inside one /20?

Four additional fixed bits distinguish 2^4, or 16, equal child blocks. In the example their third octets run from 16 through 31.

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