17 Dynamic Routing
This chapter reorients the reader from Layer 2 to Layer 3 by comparing static and dynamic routing and explaining how routers learn and maintain routes. Dynamic routing protocols let routers advertise networks to one another and automatically build resilient, scalable routing tables, adapting in seconds to link or node failures and reducing the operational burden that static routing incurs as networks grow. While static routes still offer precision and control—and can be combined with dynamic routing—dynamic protocols provide the agility and reach needed in modern topologies.
The text categorizes routing protocols by scope and algorithm. Interior gateway protocols operate within a single autonomous system, while exterior gateway protocols operate between ASes. IGPs include distance-vector protocols (RIP, EIGRP) that select paths using neighbor-learned metrics without a full network map, and link-state protocols (OSPF, IS-IS) that flood link information so each router builds a common connectivity map (LSDB) and computes shortest paths, trading higher CPU and memory for faster, more reliable convergence. BGP, the de facto EGP, uses path-vector logic driven by AS-level attributes to choose interdomain routes. Although the CCNA emphasizes OSPF, familiarity with the fundamental behaviors of all major protocols is expected.
Route selection is presented in two contexts: populating the routing table and forwarding packets. For routing table population, a router compares metric values to choose among routes learned by the same protocol, and uses administrative distance to break ties across different protocols; equal-cost routes from the same protocol can be installed for ECMP load balancing. Floating static routes raise AD to act as controlled backups to dynamically learned paths. For packet forwarding, only the most specific matching route (longest prefix) is used, regardless of AD or metric. The chapter closes with practical OSPF activation using the network command and wildcard masks: the command matches interface addresses to enable OSPF on selected interfaces and advertise their connected prefixes. Best practice is to target interfaces precisely with a 0.0.0.0 wildcard to avoid unintended activation, while recognizing flexible alternatives for labs or broader matches.
R1, R2, and R3 use a routing protocol to share routing information with each other. Each router will use this information to build its routing table.
The static route on R1 is unable to adapt to a change in the network. 1) A hardware failure causes the R2–R3 link to go down. 2) R2 removes its route to 192.168.30.0/24 because it can no longer reach the next hop. 3) R1, unaware of the hardware failure, leaves its route to 192.168.30.0/24 via R2 in its routing table, despite the existence of an alternate path.
Dynamic routing allows routers to adapt to changes in the network by automatically calculating new routes. 1) A hardware failure causes the R2–R3 link to go down. 2) R2 removes its route to 192.168.30.0/24 via R3 and adds a new route with R1 as the next hop. 3) R1 removes its route via R2 and adds a new route with R4 as the next hop.
Configuring static routes to every destination on each router, even in a fairly small network like this, is not practical; it would be both time-consuming and prone to human error.
IGPs are used to exchange routing information with routers in the same autonomous system (AS) (connected with solid lines). EGPs are used to exchange routing information with routers in a different AS (connected with dotted lines).
The five routing protocols in common use today. IGPs can be categorized as distance-vector or link-state. The two distance-vector IGPs are RIP and EIGRP. The two link-state IGPs are OSPF and IS-IS. The only exterior gateway protocol in use today, BGP, uses a path-vector algorithm.
Routers share routing information with a distance-vector routing protocol. R1 learns of LAN A from both R2 and R5, but inserts the route via R5 into its routing table due to the lower metric value.
R1 learns of LAN A from R2 and R5, and selects a route based on that information. R1 is unaware of the details of the network beyond R2 and R5.
R1 builds a connectivity map of the network, and uses it to calculate a route to LAN A.
R1’s path to Enterprise B passes through ISP A, ISP B, and then arrives at Enterprise B. Path-vector logic is AS-to-AS, rather than router-to-router.
R1 inserts the best route to 192.168.3.0/24 into its routing table. 1) R1 calculates the possible routes to 192.168.3.0/24. The route via R3 has a metric of 2, and the route via R2 has a metric of 4. 2) R1 selects the route via R3 because of its lower metric, and inserts the route into its routing table.
R1 uses AD to select which route enters the routing table. 1) R1 learns two routes to 10.0.0.0/24: via EIGRP (metric 3584) and via OSPF (metric 4). 2) EIGRP’s AD (90) is lower than OSPF’s (110), so R1 inserts the EIGRP route into its routing table. The metric values are irrelevant in this case.
An example of ECMP routing. 1) R1 learns two routes to 10.0.0.0/24 via OSPF with the same metric: one from R2 and one from R4. 2) R1 inserts both routes into its routing table; it will load-balance traffic using the two routes.
A floating static route is less preferred than an OSPF route to the same destination.
The four routes in the example overlap. 203.0.113.0/24 includes 203.0.113.0–.255, 203.0.113.0/25 includes 203.0.113.0–.127, 203.0.113.0/26 includes 203.0.113.0–.63, and 203.0.113.0/27 includes 203.0.113.0–.31. However, IOS considers them routes to different destinations, and will insert all four routes into the routing table.
Activating OSPF on a router’s interfaces with the network command. The command uses a wildcard mask, which looks like an inverted netmask.
A /30 netmask (255.255.255.252) and its equivalent wildcard mask (0.0.0.3). The “1” bits in the netmask are “0” in the wildcard mask, and vice versa.
Activating OSPF on R1’s interfaces with two network commands. The first command activates OSPF on R1’s G0/0 and G0/1 interfaces, and the second activates OSPF on G0/2.
Summary
- Dynamic routing is a process by which routers share information about the network with each other, allowing them to build their routing tables automatically. They do this by using a routing protocol.
- Dynamic routing provides several advantages over static routing, such as adaptability and scalability.
- Static routing also has advantages over dynamic routing, such as predictability and control. Fortunately, both can be used at the same time.
- Routing protocols can be divided into two main categories: interior gateway protocols (IGP) and exterior gateway protocols (EGP).
- IGPs are used to exchange routing information within a single autonomous system (AS), and EGPs are used to exchange routing information between autonomous systems.
- IGPs can be categorized by the type of algorithm they use to share routing information and calculate routes: distance-vector or link-state.
- The two distance-vector IGPs are Routing Information Protocol (RIP) and Enhanced Interior Gateway Routing Protocol (EIGRP).
- The two link-state IGPs are Intermediate System to Intermediate System (IS-IS) and Open Shortest Path First (OSPF).
- Distance-vector routing is also called routing by rumor. The router doesn’t have a complete map of the network; it only knows what its neighbors tell it.
- Routers using a link-state routing protocol build a “connectivity map” of the network, and use that map to calculate routes to each destination.
- The only EGP in common use today is Border Gateway Protocol (BGP). It uses a path-vector algorithm, which calculates routes using AS-to-AS logic, rather than router-to-router; it’s designed for larger-scale routing.
- The term route selection has two main meanings, regarding routing table population and packet forwarding.
- With regard to routing table population, route selection is the process of selecting which routers will enter the routing table. The router will use AD and metric to select which routes enter the routing table.
- With regard to packet forwarding, route selection is the process of selecting the best route in the routing table to forward a packet on. The router will select the most specific matching route in the routing table to forward the packet.
- Only the best route to each destination will be added to the routing table, and therefore be a candidate for packet forwarding. Routes that do not enter the routing table cannot be used to forward packets.
- Metric is a measure of the efficiency of a route. It is used to select among routes to the same destination (same network address and prefix length), learned via the same routing protocol.
- Each IGP uses a different metric. RIP uses hop count, EIGRP uses a metric based on bandwidth and delay (and other parameters), and OSPF uses a cost based on the bandwidth of each link.
- Because each protocol uses a different metric, metric cannot be used to compare routes learned via different routing protocols.
- Administrative distance (AD) is a value that indicates how preferred a routing protocol is. A lower AD value is preferred, and means that IOS considers the protocol more trustworthy — more likely to select good routes.
- AD is used to select among routes to the same destination, learned via different routing protocols.
- The default AD values are: Connected = 0, Static = 1, eBGP = 20, EIGRP = 90, OSPF = 110, IS-IS = 115, RIP = 120, iBGP = 200, unusable = 255.
- If multiple routes to the same destination are learned via the same routing protocol and have the same metric, they will all be inserted into the routing table, and the router will load-balance traffic over the routes. This is called equal-cost multi-path (ECMP) routing.
- A floating static route is a static route configured with an AD greater than the default of 1 for the purpose of making it less preferred. The command syntax is ip route destination-network netmask next-hop ad.
- Even if multiple routes have the same destination network address, their destinations are considered different if they have different prefix lengths. They will all be inserted into the routing table (i.e. 192.168.0.0/16, 192.168.0.0/17, and 192.1680.0/18).
- The network command is used by RIP, EIGRP, and OSPF to activate the protocol on the router’s interfaces. It is configured in router config mode.
- To enter router config mode for OSPF, use the command router ospf process-id. The syntax of the OSPF network command is network ip-address wildcard-mask area area-id.
- The network command tells the router to do the following:
- Look for interfaces with an IP address in the specified range
- Activate the routing protocol on those interfaces
- Advertise the network prefix of the interface(s) to neighbors
- A wildcard mask is a series of 32 bits that indicates which bits have to match between two IP addresses. A “0” bit in the wildcard mask means the bits have to match, and a “1” bit in the wildcard mask means the bits don’t have to match.
- A wildcard mask looks like an inverted netmask, but serves a different purpose. A netmask indicates the network and host portions of an IP address, and a wildcard mask is used to specify a range of IP addresses (not necessarily in the same subnet).
- All “1” bits of a netmask are “0” in the equivalent wildcard mask, and vice versa. For example, a /24 netmask is 255.255.255.0, and the equivalent wildcard mask is 0.0.0.255.
- If the appropriate bits match between the IP address in the network command and an interface’s IP address, OSPF will be activated on the interface.
- The network command is flexible. The IP address and wildcard mask of the command don’t have to be the same as the IP address and netmask of the interface. If the correct bits match between the network command’s IP address and the interface’s IP address, OSFP will be activated on the interface.
- It is recommended to specify the interface’s exact IP address and use a /32 wildcard mask (0.0.0.0) in the network command to ensure that OSPF is activated only on the intended interface.
- A shortcut to activate OSPF on all interfaces is to use network 0.0.0.0 255.255.255.255 area 0, because this matches all possible IP addresses. This is a handy shortcut in a simulated lab, but it is not recommended in a real network.
- The IP address and wildcard mask in the network command do not determine which prefixes the router advertises. They determine which interfaces OSPF is activated on, and then the router advertises those interface’s prefixes.
FAQ
What advantages does dynamic routing have over static routing?
Dynamic routing automatically discovers and updates routes, making the network adaptable to failures and topology changes, and scalable as the network grows. Static routing offers control and predictability but does not react to changes unless an administrator updates routes manually. Many networks use a mix of both.What is the difference between IGPs and EGPs?
Interior Gateway Protocols (IGPs) operate within a single autonomous system (one organization). Examples: RIP, EIGRP, OSPF, IS-IS. Exterior Gateway Protocols (EGPs) exchange routes between autonomous systems. The de facto EGP is BGP, which uses path-vector logic based on AS-to-AS paths.How do distance-vector, link-state, and path-vector routing protocols differ?
- Distance-vector (RIP, EIGRP): Routers share reachability and a metric with neighbors; each router does not build a full network map. Lower metric is preferred.- Link-state (OSPF, IS-IS): All routers flood link information, build the same topology map (LSDB), and compute best paths from it.
- Path-vector (BGP): Routing decisions are made based on sequences of autonomous systems and other attributes.
When multiple routes exist to the same destination, how does a router choose which one enters the routing table?
Two comparisons are made, in this order: (1) Administrative Distance (AD) if routes come from different sources/protocols—the lower AD wins; (2) Metric if routes come from the same protocol—the lower metric wins. Only routes to the exact same destination prefix are compared.What is a routing metric, and how do common IGPs calculate it?
A metric measures the efficiency/cost of a path within a routing protocol. Examples: RIP uses hop count; OSPF uses cost derived from link bandwidth (sum across the path); EIGRP uses a composite formula (by default bandwidth and delay). Lower metric values are preferred within the same protocol.What is Administrative Distance (AD), and what are common default values?
AD ranks the trustworthiness of route sources so different protocols can be compared. Lower is preferred. Common defaults: connected 0, static 1, eBGP 20, EIGRP 90, OSPF 110, IS-IS 115, RIP 120, iBGP 200, and 255 means unusable.What is ECMP and when is it used?
Equal-Cost Multi-Path (ECMP) is used when multiple routes to the same destination are learned via the same protocol and have identical metrics. All such routes enter the table and traffic is load-balanced across them. By default, up to four equal-cost paths are used.What is a floating static route and why would I use one?
A floating static route is a static route configured with an AD higher than the primary dynamic route so it stays out of the table until the primary fails. It provides a controlled backup path and is useful when the backup next hop is not part of the dynamic routing domain. Configure it by specifying a higher AD on the static route than the dynamic protocol’s AD.What’s the difference between routing table population and packet forwarding?
- Routing table population: The router decides which learned routes to install; uses AD to compare different protocols and metric to compare routes within the same protocol.- Packet forwarding: The router selects the most specific matching route (longest prefix match) in the table; AD and metric don’t matter at this stage.
Acing the CCNA Exam, Volume 1 ebook for free