100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

CIDR Notation Explained

Understand CIDR notation, how prefix length maps to a subnet mask, and why it enables route aggregation — with interview Q&A.

mediumQ88 of 224 in Computer Networks Est. time: 5 minsLast updated:
Open Code Lab

Expected Interview Answer

CIDR (Classless Inter-Domain Routing) notation expresses an IP address’s network prefix length as a suffix like /24, meaning the first 24 bits identify the network and the remaining bits identify hosts within it — replacing the old rigid class A/B/C system with flexible, arbitrary-length network boundaries.

A CIDR block like 192.168.1.0/24 has a 24-bit network prefix, leaving 8 bits (256 addresses) for hosts, while 10.0.0.0/8 leaves 24 bits (over 16 million addresses) for hosts — the shorter the prefix, the larger the network. CIDR replaced the wasteful classful system (where every network was forced into a fixed A, B, or C size) with the ability to allocate exactly as many addresses as needed, and it also enabled route aggregation, where an ISP can advertise one summarized route for many smaller customer blocks instead of thousands of individual routes, dramatically reducing the size of internet routing tables. The prefix length directly maps to a subnet mask: /24 equals 255.255.255.0, /26 equals 255.255.255.192, and so on. Engineers use CIDR notation constantly for subnetting, firewall rules, and route summarization.

  • Replaces wasteful fixed class A/B/C allocations with flexible sizing
  • Enables route aggregation, shrinking global routing table size
  • Maps directly and predictably to a subnet mask
  • Underpins subnetting, firewall rules, and cloud VPC design

AI Mentor Explanation

CIDR notation is like specifying exactly how many overs a bowling side is allocated instead of forcing every match into a fixed 50-over format regardless of need — a shorter allocation like a /24-equivalent "10 overs" leaves more overs for other bowlers, while a longer block like /8's "40 overs" leaves little for anyone else. Before flexible allocation, every match was rigidly split the same wasteful way no matter the format being played. Being able to precisely size the allocation, then let a scorer group several small allocations under one summary line, mirrors how CIDR both sizes networks exactly and lets routes be aggregated.

Step-by-Step Explanation

  1. Step 1

    Read the prefix

    The number after the slash (e.g., /24) is the number of network bits in the address.

  2. Step 2

    Compute host bits

    Subtract the prefix from 32 (IPv4) to get host bits; 2^host_bits gives total addresses.

  3. Step 3

    Map to subnet mask

    /24 equals 255.255.255.0; /26 equals 255.255.255.192, and so on.

  4. Step 4

    Aggregate for routing

    Multiple contiguous smaller blocks can be summarized into one larger CIDR route to shrink routing tables.

What Interviewer Expects

  • Correctly reads a /prefix as the number of network bits
  • Can compute total and usable addresses from a given prefix length
  • Explains CIDR replaced the wasteful classful A/B/C system
  • Understands route aggregation/summarization as a key CIDR benefit

Common Mistakes

  • Confusing CIDR prefix length with the number of usable hosts directly
  • Forgetting to subtract network and broadcast addresses for usable host count
  • Thinking CIDR only applies to subnetting, not also to route aggregation
  • Mixing up /8 (huge network) and /30 (tiny network) significance

Best Answer (HR Friendly)

CIDR notation is the slash-number you see after an IP address, like /24, and it tells you how much of that address is the network part versus the part available for individual devices. It replaced an old rigid system that wasted huge blocks of addresses, letting network engineers carve out exactly the right sized chunk for any given need, from a tiny four-address block to a massive corporate network.

Code Example

Working with CIDR blocks
# Show subnet details for a CIDR block
ipcalc 192.168.1.0/24
# Netmask:   255.255.255.0 = 24
# HostMin:   192.168.1.1
# HostMax:   192.168.1.254
# Broadcast: 192.168.1.255

# Check if an IP falls within a CIDR range (Python)
python3 -c "import ipaddress; print(ipaddress.ip_address('192.168.1.42') in ipaddress.ip_network('192.168.1.0/24'))"
# True

Follow-up Questions

  • How do you calculate the number of usable hosts from a CIDR prefix?
  • What is route summarization/aggregation and why does CIDR enable it?
  • How does CIDR notation map to a traditional subnet mask?
  • What replaced the classful A/B/C addressing system, and why?

MCQ Practice

1. How many total addresses does a /24 CIDR block contain?

A /24 leaves 8 host bits, giving 2^8 = 256 total addresses.

2. What does a shorter CIDR prefix (e.g., /8 vs /24) indicate?

Fewer network bits leaves more host bits, meaning a larger address space.

3. What is the main routing benefit CIDR provides over classful addressing?

CIDR allows multiple smaller blocks to be summarized into one advertised route, reducing routing table size.

Flash Cards

What does /24 mean in CIDR?The first 24 bits are the network portion; 8 bits remain for hosts (256 addresses).

CIDR vs classful addressing?CIDR allows arbitrary prefix lengths; classful forced networks into fixed A/B/C sizes.

/24 subnet mask equivalent?255.255.255.0.

Key routing benefit of CIDR?Route aggregation — summarizing many small blocks into one advertised route.

1 / 4

Continue Learning