Longest Prefix Match → Administrative Distance → Metric → ECMP → FIB (CEF)
When a router receives an IP packet it determines one best route using a fixed prioritized decision chain. The process runs in the control plane (RIB) and is then used in the data plane (FIB/CEF).
1. Longest Prefix Match (LPM)
The router picks the route with the most matching bits for the destination.
| Route | Prefix |
|---|---|
| 10.10.0.0/16 | less specific |
| 10.10.10.0/24 | more specific |
Destination 10.10.10.5 → ➡️ the /24 is chosen, even if the /16 has lower AD or metric.
📌 LPM beats EVERYTHING (including AD and metric).
2. Administrative Distance (AD)
If several routes have the same prefix length, the route with the lowest AD wins.
| Route type | AD |
|---|---|
| Connected | 0 |
| Static | 1 |
| eBGP | 20 |
| EIGRP (internal) | 90 |
| OSPF | 110 |
| RIP | 120 |
| iBGP | 200 |
Example: for 192.168.1.0/24 both OSPF (AD 110) and a static route (AD 1) exist → ➡️ the static route is installed in the RIB.
📌 AD is used only to choose between different route types.
3. Metrics
If the routes come from the same routing protocol, the one with the lowest metric wins: OSPF → lowest cost · EIGRP → lowest composite metric · RIP → lowest hop count.
Example (OSPF): cost 10 vs cost 20 → ➡️ cost 10 is chosen.
📌 Metrics are never compared across protocols.
4. ECMP (Equal-Cost Multi-Path)
If prefix, AD and metric are all identical → ➡️ multiple routes are installed in the RIB and FIB.
CEF load-balances: per-destination (default) or per-packet (rarely used).
Recursive routing
If the next-hop is not directly connected, the router performs a recursive lookup:
ip route 0.0.0.0 0.0.0.0 10.1.1.1
The router first finds how to reach 10.1.1.1, then uses that outgoing interface. 📌 Resolved before the route is installed into the FIB.
Overall Cisco decision order
Longest Prefix Match → Administrative Distance → Metric → ECMP → FIB (CEF)
CCNP exam pointers ⚠️
- LPM always wins
- AD decides between protocols
- Metric decides within a protocol
- ECMP requires identical values
- Forwarding uses the FIB, not the RIB
One-liner: The router selects the most specific route, then the lowest administrative distance, then the lowest metric, installs the result in the RIB, and programs the FIB for CEF forwarding.