Plan an Atomic Host Firewall Update Using IP Set Swaps
Last updated: November 29, 2026
Quick Overview
Write a function that, given the IP sets currently programmed on a Linux host and the desired sets from new policy, emits an ipset restore script that updates changed sets atomically without ever leaving a rule pointing at a half-filled set, and explain why this matters for live traffic.
Illumio
November 29, 20260
0
0 solved
Write a function that, given the IP sets currently programmed on a Linux host and the desired sets from new policy, emits an ipset restore script that updates changed sets atomically without ever leaving a rule pointing at a half-filled set, and explain why this matters for live traffic.
Illumio's agent enforces policy with the host's native firewall, so on Linux it programs iptables or nftables rules backed by IP sets. The interviewer checks that you understand why editing sets in place causes transient drops, how swap gives atomicity, and the ordering constraints between sets and rules.
What the Interviewer Expects
- Explains that flushing and refilling a live set briefly drops or allows wrong traffic
- Builds a temporary set and uses swap for an atomic exchange
- Skips unchanged sets to avoid churn on hosts with large policy
- Creates new sets before rules reference them and destroys old ones only after rules stop referencing them
- Mentions conntrack and already established connections
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you apply the iptables rule changes themselves atomically?
- What happens to established connections that the new policy no longer allows?
- How would you do the same on Windows with the Windows Filtering Platform?
- How would you verify the host matches the desired state after applying?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Input: current and desired maps from set name to member IPs, plus a version number for unique temporary names. Output: lines for ipset restore and the list of sets that are no longer needed. Unc...
High-Level Design
For each changed set, create name_vN, add all members, swap it with the live name, then destroy the temporary (which now holds the old members). swap is atomic in the kernel, so packets see eith...