CCNA online course

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.
CharacteristicStatic RoutingDynamic Routing
Network discoveryManualAutomatic through advertisements
Response to a failed linkRequires manual changes or tracking featuresCan detect the failure and select another path
AdministrationSimple in very small networks but repetitive at scaleMore initial configuration, less route-by-route maintenance
Resource useLittle control-plane processingUses CPU, memory, and bandwidth for protocol operation
PredictabilityHighly predictable when correctly configuredDepends on protocol metrics, timers, and topology
Security exposureNo routing advertisements requiredRequires 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/0

Here, 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

  1. 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.

  1. Administrative distance: If multiple sources provide the same destination prefix and prefix length, the source with the lower administrative distance is preferred.
  2. 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 SourceDefault Administrative DistanceUse in Route Selection
Connected0Preferred over all ordinary learned and static routes to the same prefix
Static1Normally preferred over dynamic protocols
EIGRP internal90Preferred over OSPF and RIP when the prefix is otherwise equal
OSPF110Preferred over RIP by default
RIP120Used when no lower-distance source wins
EIGRP external170Represents 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.

ProtocolProtocol CategoryStandard StatusMetricConvergence CharacteristicsTypical CCNA Use
RIPv2Distance vector, IGPOpen standardHop countSlow compared with OSPF and EIGRPLearning protocol fundamentals and small labs
OSPFLink state, IGPOpen standardCostGenerally faster and more scalableCommon enterprise interior routing protocol
EIGRPAdvanced distance vector, IGPVendor-associated; coverage variesComposite bandwidth and delay metricFast, partial, bounded updatesCourse-dependent IPv4 configuration and concepts
BGPPath vector, EGPOpen standardPath attributesPolicy-oriented rather than simple shortest-path convergenceConceptual 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

MechanismPurposeOperational Effect
Split horizonPrevents advertising a route back through the interface from which it was learnedReduces simple two-router loops
Route poisoningMarks a failed route as unreachableAdvertises an infinite metric, 16 in RIP
Poison reverseExplicitly advertises a learned route back as unreachableStrengthens split-horizon loop prevention in some situations
Hold-down timerPrevents unstable or contradictory information from being accepted immediatelyAllows the network time to stabilize
Invalid and flush timersControl how long an unrefreshed route remains usable or in the routing processEventually 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 rip

A 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
end

OSPF 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 ospf

A 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 CompareExpected Match or ConditionSymptom When Incorrect
Layer 1 and Layer 2 connectivityInterfaces and the link must be operationalNo hello packets or no neighbor
IP addressing and subnet maskInterfaces must share the intended subnetNeighbors fail to form
AreaBoth interfaces use the same areaArea mismatch messages or no adjacency
Hello and dead intervalsTimers must match on the linkAdjacency does not form or repeatedly fails
AuthenticationMethod and credentials must matchAuthentication mismatch
Passive-interface settingTransit interfaces must not be passiveNo hellos sent or received
Router IDEach router needs a unique IDDuplicate-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 eigrp

Route 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

  1. Identify every participating router interface, LAN prefix, and transit network.
  2. Assign correct IPv4 addresses and masks.
  3. Confirm that interfaces are operational and that directly connected neighbors can be reached.
  4. Choose the protocol and enable it on the required routers.
  5. Advertise only the intended connected networks.
  6. Set explicit router IDs, passive interfaces, authentication, summarization, or other non-default settings as required.
  7. Verify neighbor formation and learned routing-table entries.
  8. Test end-to-end reachability with ping and inspect the path with traceroute.
  9. Save the working configuration.
copy running-config startup-config

Do not begin by debugging advanced protocol behavior. First prove that the interfaces, addresses, masks, and basic connectivity are correct.

Verification Commands

CommandProtocol or FunctionWhat to Check
show ip interface briefInterfaces and addressingStatus, protocol state, and assigned IP addresses
show ip routeRouting tableRoute codes, prefixes, next hops, default route, and gateway of last resort
show ip route <network> <mask>Specific route lookupSelected source, distance, metric, next hop, and interface
show running-configConfiguration inspectionNetwork statements, router ID, passive interfaces, and addressing
show ip protocolsRIP, OSPF, and EIGRP statusEnabled protocols, advertised networks, passive interfaces, timers, and settings
show ip route ripRIPRoutes learned through RIP, marked R
show ip ospf neighborOSPFNeighbor IDs, state, address, and interface
show ip ospf interface briefOSPF interfacesInterfaces participating in OSPF and their areas and costs
show ip ospf interface <interface-id>OSPF interface detailHello/dead timers, area, network type, cost, and passive status
show ip route ospfOSPFRoutes learned through OSPF, marked O
show ip eigrp neighborsEIGRPNeighbor relationships and uptime
show ip eigrp topologyEIGRPSuccessors, feasible successors, and topology information
ping <destination-ip>ReachabilityWhether packets can reach the destination
traceroute <destination-ip>Forwarding pathEach 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 protocols to 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 route to 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-config

A 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 all

Use 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 traceroute to 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.