Dynamic Routing for CCNA
Learn dynamic routing for CCNA: routing tables, route selection, RIP, OSPF, EIGRP, configuration, verification, convergence, and troubleshooting.
Dynamic routing allows routers to learn network paths from one another instead of relying entirely on manually configured static routes. This lesson explains how routing protocols exchange information, how a router chooses the best route, and how to configure and verify common IPv4 protocols at a CCNA level.
You should already understand IPv4 addressing and subnetting, CIDR and VLSM, router interfaces, Cisco IOS command modes, static routes, default routes, and basic routing-table output. For background, review computer networking concepts, the OSI reference model, and OSPF configuration.
Purpose of Dynamic Routing
A dynamic route is a route learned automatically through a routing protocol. Routers running the same protocol exchange routing information, calculate paths, and install selected routes in their routing tables.
This differs from other common route sources:
- Connected route: Created automatically when an operational router interface has an IPv4 address and mask.
- Static route: Entered manually by an administrator.
- Dynamic route: Learned from another router through a routing protocol such as RIP, OSPF, or EIGRP.
| Characteristic | Static Routing | Dynamic Routing |
|---|---|---|
| Network discovery | Manual | Automatic through advertisements |
| Response to a failed link | Requires manual changes or tracking features | Can detect the failure and select another path |
| Administration | Simple in very small networks but repetitive at scale | More initial configuration, less route-by-route maintenance |
| Resource use | Little control-plane processing | Uses CPU, memory, and bandwidth for protocol operation |
| Predictability | Highly predictable when correctly configured | Depends on protocol metrics, timers, and topology |
| Security exposure | No routing advertisements required | Requires controls such as passive interfaces and authentication |
Dynamic routing provides automatic network discovery, adaptation to topology changes, and reduced manual administration. Its trade-offs include protocol overhead, resource consumption, configuration complexity, convergence time, and the possibility of accepting incorrect or unauthorized routing information.
Convergence is the process by which all relevant routers learn about a topology change and agree on usable paths. A faster-converging protocol usually restores forwarding sooner, but may require more sophisticated processing and design.
Static routing remains preferable for stub networks, simple point-to-point links, backup routes, default routes toward a service provider, and situations requiring very strict path control. A small network does not automatically need a dynamic protocol.
Routing Table Fundamentals
A router's routing table, also called the routing information base or RIB, stores the best known routes. The router uses the selected route to build or update a forwarding table used by the data plane to forward packets.
A route entry commonly contains:
- Destination prefix: The target network, such as 10.20.0.0.
- Prefix length or mask: The size of the destination, such as /24 or 255.255.255.0.
- Next hop: The neighboring router address to which the packet should be sent.
- Exit interface: The local interface used to forward the packet.
- Route source: Connected, static, RIP, OSPF, EIGRP, and other possible sources.
- Metric: A protocol-specific value used to compare paths learned by the same protocol.
- Administrative distance: A trust value used to compare different route sources.
For example, an OSPF route might appear as follows:
O 10.30.0.0/24 [110/20] via 192.0.2.2, 00:04:12, GigabitEthernet0/0Here, O identifies OSPF, 10.30.0.0/24 is the destination prefix, 110 is the administrative distance, 20 is the OSPF metric, 192.0.2.2 is the next hop, and GigabitEthernet0/0 is the exit interface.
How a Router Selects a Route
- Longest-prefix match: The router first chooses the route with the most specific matching prefix. A / вп?
A /24 route is more specific than a /16 route, so a destination matching both uses the /24 route.
- Administrative distance: If multiple sources provide the same destination prefix and prefix length, the source with the lower administrative distance is preferred.
- Metric: If multiple paths come from the same protocol, that protocol compares its metric and selects the best path or paths.
The phrase gateway of last resort refers to a default route, usually written as 0.0.0.0/0. It matches destinations for which no more-specific route exists. A default route is used only after longest-prefix matching finds no more-specific entry.
| Route Source | Default Administrative Distance | Use in Route Selection |
|---|---|---|
| Connected | 0 | Preferred over all ordinary learned and static routes to the same prefix |
| Static | 1 | Normally preferred over dynamic protocols |
| EIGRP internal | 90 | Preferred over OSPF and RIP when the prefix is otherwise equal |
| OSPF | 110 | Preferred over RIP by default |
| RIP | 120 | Used when no lower-distance source wins |
| EIGRP external | 170 | Represents routes redistributed into EIGRP from another source |
Administrative distance is not a measure of path length or link quality. It expresses how much a router trusts a route source. A metric is different: it measures preference within one routing protocol.
How Routing Protocols Operate
Routing protocols use control-plane messages to exchange reachability information. The data plane then forwards user packets according to the installed forwarding entries.
Neighbors, Advertisements, and Updates
A neighbor is a router discovered through a routing protocol. Some protocols form a more formal adjacency, which is a protocol relationship that permits detailed information exchange.
Routers may send:
- Hello or discovery messages to find and maintain neighbors.
- Route advertisements describing reachable prefixes and path information.
- Triggered updates soon after a topology change.
- Periodic updates sent at regular intervals, as used prominently by RIP.
When a link fails, a router detects the failure through interface status, missed hello messages, or another protocol mechanism. It withdraws or invalidates affected routes, advertises the change, recalculates paths, and installs an alternate route if one is available. This sequence is part of reconvergence.
Protocol messages may use broadcast or multicast delivery depending on the protocol and network type. RIPv2 commonly uses IPv4 multicast 224.0.0.9. OSPF uses protocol-specific multicast addresses such as 224.0.0.5 and 224.0.0.6 on IPv4 networks. These control messages are not ordinary application traffic.
Dynamic Routing Protocol Categories
- Interior Gateway Protocols (IGPs): Used within one organization or autonomous system. RIP, OSPF, and EIGRP are examples.
- Exterior Gateway Protocols (EGPs): Used between autonomous systems. BGP is the important conceptual example.
- Distance-vector: Routers learn distance and direction, usually from neighboring routers. RIP is a classic example.
- Link-state: Routers build a topology database and calculate paths. OSPF is a link-state protocol.
- Path-vector: Routers exchange path attributes, including the sequence of autonomous systems. BGP is a path-vector protocol.
Classful routing does not carry subnet-mask information in its routing updates and therefore cannot properly support arbitrary VLSM or CIDR boundaries. Classless routing carries the prefix length or mask and supports VLSM, CIDR, and discontiguous subnet designs when other conditions are correct.
RIP and OSPF are open-standard protocols. EIGRP is associated with Cisco and its availability, feature set, and exam coverage can vary. BGP is standardized and is studied at a conceptual level in introductory routing courses.
| Protocol | Protocol Category | Standard Status | Metric | Convergence Characteristics | Typical CCNA Use |
|---|---|---|---|---|---|
| RIPv2 | Distance vector, IGP | Open standard | Hop count | Slow compared with OSPF and EIGRP | Learning protocol fundamentals and small labs |
| OSPF | Link state, IGP | Open standard | Cost | Generally faster and more scalable | Common enterprise interior routing protocol |
| EIGRP | Advanced distance vector, IGP | Vendor-associated; coverage varies | Composite bandwidth and delay metric | Fast, partial, bounded updates | Course-dependent IPv4 configuration and concepts |
| BGP | Path vector, EGP | Open standard | Path attributes | Policy-oriented rather than simple shortest-path convergence | Conceptual understanding of inter-autonomous-system routing |
RIP and RIPv2
RIP is a distance-vector protocol. Its metric is hop count: each router crossed adds one hop. A route with 1 hop is preferred to one with 3 hops. A hop count of 16 means unreachable, so 15 hops is the maximum usable distance.
RIP sends periodic updates and is known for slow convergence. It uses loop-prevention techniques, but these do not make it suitable for large modern enterprise networks.
RIPv1 and RIPv2
RIPv1 is classful. It does not include subnet masks in its updates, which limits VLSM and CIDR support and can cause incorrect summarization across classful network boundaries.
RIPv2 is classless. It carries subnet-mask information, supports VLSM and CIDR, uses multicast updates rather than the RIPv1 broadcast behavior, and includes authentication concepts. Cisco IOS may perform automatic summarization at classful network boundaries; no auto-summary is commonly used when discontiguous networks require their actual subnet prefixes to be advertised.
RIP Loop Prevention
| Mechanism | Purpose | Operational Effect |
|---|---|---|
| Split horizon | Prevents advertising a route back through the interface from which it was learned | Reduces simple two-router loops |
| Route poisoning | Marks a failed route as unreachable | Advertises an infinite metric, 16 in RIP |
| Poison reverse | Explicitly advertises a learned route back as unreachable | Strengthens split-horizon loop prevention in some situations |
| Hold-down timer | Prevents unstable or contradictory information from being accepted immediately | Allows the network time to stabilize |
| Invalid and flush timers | Control how long an unrefreshed route remains usable or in the routing process | Eventually removes stale routes |
Basic RIPv2 Configuration
On each router, advertise the classful network statements that contain the participating interfaces. RIPv2 then carries the correct subnet masks in updates.
configure terminal
router rip
version 2
no auto-summary
network 10.0.0.0
network 192.0.2.0
passive-interface GigabitEthernet0/1
end
show ip protocols
show ip route ripA passive interface still allows its connected network to be advertised, but it does not send RIP neighbor updates through that interface. This is useful for a user-facing LAN where no routing neighbor should exist.
In a three-router line, configure RIPv2 on every router and advertise each LAN and transit network. Confirm that remote LANs appear with route code R. If a redundant link is added, shut down a transit interface and observe route withdrawal and selection of the alternate path after convergence.
To remove RIP configuration, remove the routing process:
configure terminal
no router rip
endOSPF Single-Area Routing
OSPF, or Open Shortest Path First, is an open-standard link-state IGP. In a single-area design, routers commonly operate in Area 0, the OSPF backbone area.
OSPF routers discover neighbors with hello packets. After negotiating compatible parameters, routers form adjacencies and exchange link-state advertisements (LSAs). Each router stores the received information in a link-state database (LSDB). The router runs the shortest path first algorithm, also called SPF, and installs the best resulting routes in its routing table.
Router IDs and Areas
An OSPF router ID is a 32-bit identifier written like an IPv4 address. Configure it explicitly for predictable operation. If it is not configured, Cisco IOS selects an eligible address according to platform rules, often preferring the highest loopback address and then the highest active physical address.
A single-area CCNA lab places all participating interfaces in Area 0. Multi-area OSPF introduces additional design and summarization considerations and is beyond this basic workflow.
OSPF Cost
OSPF uses cost as its metric. Cost is derived from interface bandwidth and a reference bandwidth. If interface speeds are changed or mixed, check whether the reference bandwidth produces meaningful differences. Changing an interface's bandwidth value can change the preferred OSPF path, even though the physical link itself has not changed.
Basic OSPFv2 Configuration
configure terminal
router ospf 10
router-id 1.1.1.1
network 10.10.1.0 0.0.0.255 area 0
network 192.0.2.0 0.0.0.3 area 0
passive-interface GigabitEthernet0/1
end
show ip ospf neighbor
show ip ospf interface brief
show ip protocols
show ip route ospfA wildcard mask identifies which address bits must match and which may vary. It is the inverse of a subnet mask: 255.255.255.0 becomes 0.0.0.255, while a /30 mask becomes 0.0.0.3.
Use passive interfaces on LANs that should be advertised but should not form OSPF neighbor relationships. Do not make a transit interface passive if it must form an adjacency with another router.
OSPF Neighbor Adjacency Requirements
| Parameter to Compare | Expected Match or Condition | Symptom When Incorrect |
|---|---|---|
| Layer 1 and Layer 2 connectivity | Interfaces and the link must be operational | No hello packets or no neighbor |
| IP addressing and subnet mask | Interfaces must share the intended subnet | Neighbors fail to form |
| Area | Both interfaces use the same area | Area mismatch messages or no adjacency |
| Hello and dead intervals | Timers must match on the link | Adjacency does not form or repeatedly fails |
| Authentication | Method and credentials must match | Authentication mismatch |
| Passive-interface setting | Transit interfaces must not be passive | No hellos sent or received |
| Router ID | Each router needs a unique ID | Duplicate-ID instability or rejected relationships |
For a three-router Area 0 enterprise topology, assign explicit router IDs, activate OSPF on LAN and transit interfaces, make user-facing LANs passive, and verify that neighbors reach the FULL state. Learned OSPF routes appear with code O.
EIGRP Concepts and Configuration Context
EIGRP is commonly described as an advanced distance-vector protocol. It discovers neighbors, uses reliable transport for appropriate protocol messages, and sends partial, bounded updates rather than continuously sending the entire routing table.
EIGRP's composite metric primarily considers bandwidth and delay. The successor is the best next hop for a destination. A feasible successor is a backup path that satisfies the feasibility condition. The Diffusing Update Algorithm, or DUAL, helps EIGRP calculate loop-free paths and react to changes.
EIGRP supports classless routing, summarization, and passive interfaces. Its exact command availability and the amount tested vary by current CCNA objectives, so treat the following as course-scope IPv4 configuration context.
configure terminal
router eigrp 100
network 10.10.0.0 0.0.255.255
network 192.0.2.0 0.0.0.3
no auto-summary
passive-interface GigabitEthernet0/1
end
show ip eigrp neighbors
show ip eigrp topology
show ip route eigrpRoute Selection and Redistribution Awareness
When several sources advertise the same destination prefix, the router compares administrative distance. For example, a static route normally has an administrative distance of 1, while an OSPF route has 110. The static route is installed unless it is removed, given a higher distance, or otherwise made unusable.
Within one protocol, the protocol metric determines the preferred path. If two paths have the same qualifying metric, the router may install both as equal-cost multipath (ECMP) routes and distribute traffic according to platform behavior.
Longest-prefix matching still comes first. A /24 route is selected over a /16 summary even if the summary came from a different protocol, provided the /24 is present and usable.
Route redistribution imports routes from one routing source into another, such as injecting static or OSPF routes into EIGRP. It is an advanced topic because different metrics, route tags, administrative distances, and feedback paths can create routing loops or suboptimal paths. Avoid unnecessary redistribution in introductory designs.
Route Selection Example
Suppose a router has both a static route and an OSPF route to 10.40.0.0/16. The static route wins because its default administrative distance is lower. If the static route is removed or its distance is raised above 110, the OSPF route can become active.
Now suppose the router has 10.40.0.0/16 and 10.40.5.0/24. A packet destined for 10.40.5.10 uses the /24 route because it is more specific. A packet destined for 10.40.8.10 uses the /16 route.
Configuration Workflow
- Identify every participating router interface, LAN prefix, and transit network.
- Assign correct IPv4 addresses and masks.
- Confirm that interfaces are operational and that directly connected neighbors can be reached.
- Choose the protocol and enable it on the required routers.
- Advertise only the intended connected networks.
- Set explicit router IDs, passive interfaces, authentication, summarization, or other non-default settings as required.
- Verify neighbor formation and learned routing-table entries.
- Test end-to-end reachability with ping and inspect the path with traceroute.
- Save the working configuration.
copy running-config startup-configDo not begin by debugging advanced protocol behavior. First prove that the interfaces, addresses, masks, and basic connectivity are correct.
Verification Commands
| Command | Protocol or Function | What to Check |
|---|---|---|
show ip interface brief | Interfaces and addressing | Status, protocol state, and assigned IP addresses |
show ip route | Routing table | Route codes, prefixes, next hops, default route, and gateway of last resort |
show ip route <network> <mask> | Specific route lookup | Selected source, distance, metric, next hop, and interface |
show running-config | Configuration inspection | Network statements, router ID, passive interfaces, and addressing |
show ip protocols | RIP, OSPF, and EIGRP status | Enabled protocols, advertised networks, passive interfaces, timers, and settings |
show ip route rip | RIP | Routes learned through RIP, marked R |
show ip ospf neighbor | OSPF | Neighbor IDs, state, address, and interface |
show ip ospf interface brief | OSPF interfaces | Interfaces participating in OSPF and their areas and costs |
show ip ospf interface <interface-id> | OSPF interface detail | Hello/dead timers, area, network type, cost, and passive status |
show ip route ospf | OSPF | Routes learned through OSPF, marked O |
show ip eigrp neighbors | EIGRP | Neighbor relationships and uptime |
show ip eigrp topology | EIGRP | Successors, feasible successors, and topology information |
ping <destination-ip> | Reachability | Whether packets can reach the destination |
traceroute <destination-ip> | Forwarding path | Each routed hop and possible asymmetric or unexpected paths |
Common route codes include C for connected, L for local, S for static, R for RIP, O for OSPF, and D for EIGRP. Exact codes can vary for special route types, so read the legend at the top of the command output.
Troubleshooting Dynamic Routing
A Remote Network Does Not Appear
- Check interface state and addressing with
show ip interface brief. - Confirm the originating router has the network as a connected route.
- Use
show ip protocolsto verify that the network is advertised. - Check that transit interfaces are enabled for the protocol.
- Confirm that a passive interface is not blocking required neighbor communication.
- Use
show ip routeto determine whether another, more-preferred route source is installed instead.
OSPF Neighbors Do Not Form
Compare Layer 1 and Layer 2 connectivity, IP addresses and masks, area numbers, hello and dead timers, authentication settings, network type, passive-interface status, and router IDs. Use:
show ip ospf neighbor
show ip ospf interface GigabitEthernet0/0
show ip interface brief
show running-configA mismatch in area, subnet mask, timers, authentication, or passive status can prevent adjacency. A duplicate router ID can cause unstable behavior.
RIP Routes Are Missing or Have Incorrect Masks
Confirm that RIPv2 is enabled, the correct network statements are present, and automatic summarization is disabled when the topology is discontiguous. Check:
show ip protocols
show ip route rip
debug ip rip
undebug allUse debugging carefully because it can consume CPU and produce a large amount of output. Always disable debugging after collecting the needed evidence.
Traffic Uses an Unexpected Path
- Check for a more-specific prefix selected by longest-prefix match.
- Compare administrative distances when different route sources exist.
- Compare the protocol metric for equal-length prefixes.
- Check OSPF interface bandwidth and calculated cost.
- Look for a static default route that is forwarding traffic toward an unexpected gateway.
- Use
tracerouteto identify the actual forwarding path.
RIP Loops or Slow Convergence
Review split horizon, route poisoning, poison reverse, hold-down behavior, and invalid or flush timers. Also check for incorrect redistribution or injected static routes. RIP can take longer to stabilize because of its periodic update model and limited loop-prevention mechanisms.
Design and Operational Best Practices
- Use passive interfaces on LANs that should not form routing neighbors.
- Advertise only intended networks; avoid broad network statements that activate routing on untrusted interfaces.
- Document router IDs, OSPF areas, EIGRP autonomous system numbers, and summarization boundaries.
- Use routing-protocol authentication where supported and required.
- Prevent routing information from being exchanged across untrusted segments.
- Prefer a scalable protocol such as OSPF for larger enterprise internal networks when interoperability and convergence are important.
- Choose a protocol based on topology size, convergence requirements, interoperability, operational skill, and administrative policy.
- Avoid unnecessary redistribution, especially between multiple protocols, until metrics and loop prevention are fully designed.
Practice Scenarios
Three-Router RIPv2 Topology
Connect three routers in a line. Give each router one LAN and connect neighboring routers with point-to-point transit links. Enable RIPv2, advertise all LAN and transit networks, and disable automatic summarization. Verify that every router learns remote LAN prefixes with route code R. Add a redundant link, shut down one transit interface, and observe route withdrawal and alternate-path selection.
Single-Area OSPF Enterprise Topology
Use three routers in Area 0 with LAN and transit interfaces. Assign explicit router IDs, activate OSPF with network statements and wildcard masks, make user-facing LAN interfaces passive, and verify FULL neighbor relationships. Change an interface bandwidth value and observe how the OSPF path-cost preference changes.
Classless RIPv2 Design
Use variable-length subnets in a discontiguous addressing design. Compare the behavior expected from classful RIPv1 with RIPv2. Confirm that RIPv2 carries the correct subnet masks and that no auto-summary prevents inappropriate major-network summaries.
Key Takeaways
- Dynamic routing replaces many manual route entries with protocol-based discovery and calculation.
- The routing table records destination prefixes, route sources, distances, metrics, next hops, and exit interfaces.
- Longest-prefix match is evaluated before administrative distance and metric.
- RIP is simple but limited by hop count and relatively slow convergence.
- RIPv2 supports classless routing, VLSM, CIDR, multicast updates, and authentication concepts.
- OSPF forms neighbor adjacencies, exchanges LSAs, builds an LSDB, runs SPF, and installs cost-based routes.
- EIGRP uses neighbor relationships, partial bounded updates, DUAL, and a composite bandwidth-and-delay metric.
- Verification should begin with interfaces and addressing, then protocol state, neighbors, routes, and end-to-end forwarding.
- Passive interfaces, restricted advertisements, authentication, documentation, and careful protocol selection improve operational safety.