PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/System Design/Databricks

Implement CIDR firewall matcher

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of IP networking and prefix-based access control, specifically CIDR notation, longest-prefix match semantics, and data-structure skills for efficient prefix and range queries.

  • medium
  • Databricks
  • System Design
  • Software Engineer

Implement CIDR firewall matcher

Company: Databricks

Role: Software Engineer

Category: System Design

Difficulty: medium

Interview Round: Technical Screen

##### Question Design and implement a firewall rule matcher that evaluates a single IPv4 address against a list of CIDR rules (each tagged accept/deny). Explain and code the data structures and algorithms you would use. Follow-up: extend the solution to handle matching an incoming CIDR range against the rule set and discuss efficient data structures for range intersection checks.

Quick Answer: This question evaluates understanding of IP networking and prefix-based access control, specifically CIDR notation, longest-prefix match semantics, and data-structure skills for efficient prefix and range queries.

Related Interview Questions

  • Design a Book Price Aggregator - Databricks (medium)
  • Design a stock order manager - Databricks (medium)
  • Design an Online Bookstore - Databricks (hard)
  • Design a Hierarchical File System - Databricks (hard)
  • Design a Visa-like payment processing system - Databricks (hard)
Databricks logo
Databricks
Aug 4, 2025, 10:55 AM
Software Engineer
Technical Screen
System Design
29
0

Firewall Rule Matcher for IPv4 CIDR Rules

Context and Assumptions

You are to design and implement a firewall rule matcher that decides whether to accept or deny traffic for IPv4 addresses based on a list of CIDR-prefix rules. Each rule is tagged accept or deny. Assume:

  • IPv4 (32-bit addresses).
  • Precedence: longest-prefix match wins (typical for CIDR-based routing). For ties (same prefix length), earlier rule definition wins. If nothing matches, default is deny.
  • Rules can overlap (e.g., 10.0.0.0/8 accept and 10.0.0.0/16 deny).

Tasks

  1. Design and implement a matcher that evaluates a single IPv4 address against a list of CIDR rules (accept/deny). Explain the data structures and algorithms used.
  2. Follow-up: extend the solution to handle evaluating an incoming CIDR range against the rule set. Discuss and propose efficient data structures for range intersection checks.

Inputs/Outputs

  • Input (single-IP case): list of rules like [("10.0.0.0/8", accept), ("10.0.0.0/16", deny), ...] and a query IP (e.g., "10.1.2.3").
  • Output: accept or deny according to precedence.
  • Follow-up input: an incoming CIDR (e.g., "10.1.0.0/17").
  • Follow-up output: either a single decision if uniform over the range, or a decomposition into subranges with decisions; and a discussion of efficient data structures for range intersection.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Databricks•More Software Engineer•Databricks Software Engineer•Databricks System Design•Software Engineer System Design
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.