What's changed: Initial version
2.1Routing fundamentals
Covers how a routing table is consulted, when to choose static routing versus dynamic routing, the longest-match rule for resolving multiple matching routes, the default route as the catch-all exit, metric as a route's cost measure, and administrative distance (AD) for comparing routes learned from different sources.
For a network designer, deciding "which path to forward a packet along" is itself a trade-off among availability, cost, and operational burden. A small inter-site link may be adequately served by static routing, while a large network whose paths change frequently cannot recover from failures fast enough without dynamic routing. This section builds on the routing-table lookup logic—how a router actually decides where to forward a packet next—to develop the design judgment of when to choose static versus dynamic routing.
2.1.1The routing table and longest match
- A routing table records, for each destination network, which interface or next hop to forward through. A router matches a packet's destination IP address against this table to decide where to forward it.
- When a destination matches multiple route entries, longest match applies: the route with the longest (most specific) subnet mask wins. For example, if a destination matches both
10.0.0.0/8and10.1.1.0/24, the/24route is chosen. - The default route (
0.0.0.0/0) is the shortest-mask (most general) route, used as the final exit for packets that match no other entry. It is typically configured as the internet-facing exit or at a stub site that holds no other route information.
2.1.2Static routing versus dynamic routing
- Static routing is where an administrator manually configures routes. It is simple to configure, places little processing load on the router, and yields predictable paths (also reassuring from a security standpoint, since routes never change on their own), but it cannot automatically reroute around a link failure, and the configuration/maintenance burden grows roughly exponentially as the number of sites increases.
- Dynamic routing is where routers automatically exchange and learn route information via a routing protocol. It automatically switches to a detour route when a link fails (convergence), but it requires protocol design and parameter tuning, and places a higher processing and bandwidth load on routers.
2.1.3Metric and administrative distance (AD)
- A metric is the yardstick used within a single protocol to compare the merit of multiple routes (hop count for RIP, bandwidth-based cost for OSPF). A smaller value indicates a more preferred route.
- Administrative distance (AD) is the trust-level metric used to compare routes learned from different sources (a static route versus routes from multiple dynamic routing protocols). A smaller value indicates greater trust (e.g., directly connected 0, static route 1, OSPF 110, RIP 120). When multiple protocols learn a route to the same destination, only the route with the smallest AD is installed in the routing table.
The three most-tested points: "longest match = the route with the longest mask wins", "metric = comparison within the same protocol", and "AD = comparison across different sources". A common mistake is conflating metric and AD—always distinguish the axis: metric is intra-protocol, AD is inter-protocol.
A network designer at a company is planning routes connecting the head office to three branches (A, B, and C). Branch C has no planned expansion and only a single link—it is a small stub site—so simply configuring a static default route (0.0.0.0/0) to the head office is enough: there is no alternate path to fail over to, so introducing dynamic routing would only add operational burden without any benefit. Branches A and B, however, are connected by two redundant links, and the requirement is to automatically detour if one fails, so introducing dynamic routing (e.g., OSPF) to automatically converge onto the surviving link on failure is the appropriate design. Now consider the head-office router holding both a static route (AD=1) and an OSPF-learned route to the same destination (AD=110) at the same time. Because the static route has the smaller AD (higher trust), it is preferred even if OSPF has actually learned a valid detour route—a design mistake in which the router never falls back to the OSPF detour on failure, because the static route always wins. To avoid this, the backup static route's AD should be deliberately set higher than OSPF's (e.g., as a floating static route with AD=200), so that the OSPF route is preferred in normal operation and the static route is used only as a fallback once OSPF loses its route information. Routing design therefore comes down to three judgment axes: how often paths change, whether redundancy is required, and which source should be trusted when multiple sources conflict.
| Route source | Default AD | Comparison axis |
|---|---|---|
| Directly connected | 0 | Highest priority (not compared by metric) |
| Static route | 1 | Explicit administrator trust |
| OSPF | 110 | Compared across dynamic protocols |
| RIP | 120 | Compared across dynamic protocols |
Trap: "The route with the smaller metric and the route with the smaller AD always refer to the same route" is wrong—AD decides which source to trust when multiple sources (static, OSPF, RIP, etc.) offer a route to the same destination, while metric decides the best route within the source that was chosen; these are separate layers of decision-making. Also wrong: "introducing dynamic routing is always preferable to static routing"—for a stub site where paths almost never change, static routing is the more rational choice, with lower operational burden and a smaller attack surface.
2.1.4Section summary
- Longest match prefers the route with the longest mask; when nothing matches, the default route (
0.0.0.0/0) is used - Static routing suits small, stable sites; dynamic routing suits sites requiring redundancy and automatic failover
- Metric compares routes within the same protocol; AD compares trust across different sources (a smaller value wins)
Sign in to track progress — Log in.
Quick check
(just a quick review)Q1. A router's routing table contains both a route via `10.0.0.0/8` and a route via `10.1.1.0/24`. For a packet destined to `10.1.1.5`, which route is used, and what is the correct justification?
Q2. You are designing a network connecting a head office to three branches. Branch C has no planned expansion and only a single link to the head office. Which routing design is most appropriate for branch C?
Q3. A router simultaneously holds a static route (AD=1) and an OSPF-learned route (AD=110) to the same destination network. Given that the OSPF route could actually serve as a valid detour, which problem is most likely to arise from this configuration?

