Computer Networks

CIDR

Classless addressing: a prefix and a length. Aggregation is the point.

Level: intermediate

What is it?

Classless Inter-Domain Routing (CIDR) represents an IP network using an address and prefix length, such as 203.0.113.0/24. It replaced rigid classful allocation and enables flexible subnetting and route aggregation.

Why does it matter?

CIDR allocates address space more efficiently and lets routing systems advertise aggregated prefixes instead of one route per small network. Incorrect prefix lengths can create overlaps or unexpected route selection.

Mental model

The prefix length specifies how many leading address bits identify the network. A route /24 is more specific than a route /16, so longest-prefix match normally prefers /24 when both match.

How it works

  • For IPv4, a /p prefix leaves 32-p host bits and covers 2^(32-p) total addresses when aligned.
  • Prefix boundaries must align to the block size; not every arbitrary address is the network address for a chosen prefix.
  • Longest-prefix match chooses the most specific matching route, independent of route metric details among less-specific prefixes.
  • Route aggregation summarizes adjacent prefixes when their bit patterns allow a correct supernet.
  • IPv6 uses the same prefix-length concept over 128-bit addresses.

Steps

  • Choose the prefix length that supplies enough addresses and room for growth.
  • Calculate the block size and align the network address to that boundary.
  • Derive the range and check it does not overlap existing prefixes.
  • Advertise the most specific necessary routes or aggregate compatible adjacent routes when safe.

Real-world usage

  • Subnet planning in enterprise, cloud VPCs, and home networks.
  • Understanding routing tables and IP address allocation.

Common mistakes

  • Using dotted-decimal octet intuition for all prefix lengths.
  • Aggregating unrelated prefixes and accidentally attracting traffic to the wrong route.
  • Confusing route specificity with shortest path or lowest metric.

Interview questions

What does /27 mean in IPv4?

The prefix has 27 network bits and 5 host bits, for 32 total addresses in an aligned /27 block.

Why is route aggregation useful?

It reduces the number of advertised routes when several adjacent prefixes can be represented by one valid supernet.

Prerequisites

Related concepts

Continue learning

Browse the full computer science library