Reading show ip route output
The `show ip route` command displays the IP routing table. Each line represents a known route. The format is: Code, then network/prefix, then administrative distance/metric in brackets, then via next-hop or outgoing interface.
Example: `O 10.1.2.0/24 [110/20] via 192.168.1.1, 00:05:23, GigabitEthernet0/0` — O = OSPF route, 10.1.2.0/24 = destination network, [110/20] = AD 110 / metric 20, via 192.168.1.1 = next-hop IP, 00:05:23 = time since learned, GigabitEthernet0/0 = outgoing interface.
Common route codes: C = connected (directly attached network), L = local (the router's own interface IP as a /32 host route), S = static, O = OSPF, D = EIGRP, R = RIP, B = BGP, i = IS-IS, * = default route candidate. A route with `*` is a candidate for the default route when no more specific match exists.
Administrative distance
Administrative distance (AD) is the trustworthiness rating of a routing information source. Lower AD is more trusted. When two routing sources provide a route to the same destination, the route with the lowest AD wins and is installed in the routing table.
Key AD values to memorize: Connected = 0 (most trusted), Static = 1, EIGRP summary = 5, External BGP = 20, Internal EIGRP = 90, OSPF = 110, IS-IS = 115, RIP = 120, External EIGRP = 170, Internal BGP = 200. A directly connected route (AD 0) always beats any dynamic routing protocol's version of the same network.
AD is only used to choose between routes to the same destination from different sources. Once a source is chosen, the metric within that protocol determines the best path if multiple routes from the same protocol cover the same network.
Metrics and longest prefix match
Metric measures the cost of reaching a destination within a single routing protocol. Each protocol uses a different metric: RIP uses hop count (maximum 15); OSPF uses cumulative cost based on interface bandwidth (reference bandwidth / interface bandwidth); EIGRP uses a composite metric based on bandwidth and delay; BGP uses AS path length and various policy attributes.
When the same routing protocol has two paths to the same network, the path with the lower metric wins. Equal-cost load balancing occurs when two paths have the same metric — both are installed in the routing table and traffic is distributed across them.
Longest prefix match is how the router selects which route to use for a specific packet. The router compares the destination IP against all routing table entries and selects the entry with the longest matching prefix (most specific). A /28 route beats a /24 route beats a /0 default route, even if the /0 has better AD or metric. Specificity always wins over AD and metric.
Connected, static, and default routes
Connected routes (C) appear automatically when an interface is configured with an IP address and is in an up/up state. The router knows it can directly reach that subnet without any routing protocol. Connected routes have AD 0.
Local routes (L) are /32 host routes for the router's own interface IP addresses. They're used to efficiently identify traffic destined for the router itself (to a router's interface) rather than traffic transiting the router.
Static routes (S) are manually configured: `ip route <network> <mask> <next-hop or interface>`. A static route with a next-hop IP is a recursive static route — the router must look up the next-hop IP in the routing table. A static route with an outgoing interface is a directly connected static route. Floating static routes use a higher-than-normal AD (e.g., AD 5 for a backup to OSPF) so they only appear if the dynamic route is removed.
The default route (S* or O* etc.) matches any destination when no more specific route exists: `ip route 0.0.0.0 0.0.0.0 <next-hop>`. It appears in the routing table as 0.0.0.0/0.