Longest-Prefix Match
Problem
A router has: 10.0.0.0/8 → A 10.20.0.0/16 → B 10.20.30.0/24 → C A packet arrives for: 10.20.30.7
All three routes match.
Which one wins?
Solution — Longest-Prefix Match
The most specific matching prefix wins.
10.20.30.0/24 → C
because /24 describes a smaller, more specific set of addresses than /16 or /8.
Core idea: routers prefer the most specific known route to the destination.