Routing Table Basics
Last updated:
Every forwarding decision a router makes is a lookup in one table. Three rules decide the winner for a destination:
- Longest prefix match — a /28 route beats a /24, which beats a /16. Always evaluated first.
- Administrative distance (AD) — when two sources offer the same prefix, the more trusted source wins.
- Metric — when the same protocol offers the same prefix twice, its own metric breaks the tie.
Common administrative distances
| Route source | AD (Cisco defaults) |
|---|---|
| Connected interface | 0 |
| Static route | 1 |
| eBGP | 20 |
| OSPF | 110 |
| IS-IS | 115 |
| RIP | 120 |
| iBGP | 200 |
AD values are vendor-specific defaults (these are Cisco's) — the concept is universal: lower means more trusted.
Why longest prefix match comes first
AD compares route sources for the same prefix. 10.1.1.0/24 via OSPF and 10.1.1.128/25 via RIP aren't competing — a packet to 10.1.1.130 simply matches the more specific /25. AD would only referee if both offered the identical prefix.