How Routers Forward Packets
A router maintains a routing table containing known networks, the next-hop address or exit interface for each, and a metric indicating path preference. When a packet arrives, the router performs a longest prefix match — it selects the most specific matching route. A route to 192.168.1.0/24 is preferred over a default route (0.0.0.0/0) for traffic destined to 192.168.1.100.
Default route (0.0.0.0/0 or ::/0 for IPv6): matches any destination not covered by more specific routes. Used for internet traffic — 'send everything unknown to the ISP.' A router without a default route will drop traffic to unknown destinations.
Administrative distance (AD): a value that ranks routing information sources by trustworthiness. Lower AD = more trusted. Connected interface = 0. Static route = 1. EIGRP = 90. OSPF = 110. RIP = 120. External BGP = 20. If two routing protocols both have a route to the same destination, the one with lower AD wins and enters the routing table.
Static vs Dynamic Routing
Static routing: routes manually configured by an administrator. Advantages: predictable, no overhead, no routing protocol traffic. Disadvantages: does not adapt to topology changes — if a link fails, traffic is not automatically rerouted. Suitable for small networks or specific routes (default route, stub networks).
Dynamic routing: routers automatically exchange route information and update routing tables when topology changes. Three categories: Distance vector (RIP, EIGRP) — routers share routing tables with neighbors. Link state (OSPF, IS-IS) — routers share topology information and each router builds its own complete map. Path vector (BGP) — routers share path attributes, used for inter-AS internet routing.
Common Routing Protocols
RIP (Routing Information Protocol): distance-vector, uses hop count as metric (max 15 hops — 16 = unreachable), slow convergence (30s updates), suitable only for small networks. RIPv2 adds VLSM and MD5 authentication. RIPng for IPv6.
OSPF (Open Shortest Path First): link-state, uses cost (based on bandwidth) as metric, fast convergence, supports large networks, uses Dijkstra's algorithm, organized into areas (Area 0 = backbone). Standard protocol for enterprise routing. OSPFv3 for IPv6.
EIGRP (Enhanced Interior Gateway Routing Protocol): advanced distance-vector (Cisco proprietary, though now open), uses bandwidth and delay composite metric, very fast convergence via DUAL algorithm, supports VLSM. More efficient than OSPF in Cisco-only environments.
BGP (Border Gateway Protocol): path-vector, the routing protocol of the internet. Used between autonomous systems (ISPs, large enterprises). Uses AS path, local preference, and many attributes for path selection. Extremely scalable but complex. Not typically deployed in enterprise LANs.