CCNA online course

Routing Tables Explained for CCNA

Learn how Cisco routers use IPv4 and IPv6 routing tables, longest prefix match, administrative distance, metrics, static and dynamic routes, default routes, and troubleshooting commands.

A routing table is the database a Layer 3 device uses to decide where to send packets whose destinations are not local. It contains destination prefixes and path information such as a next hop and outgoing interface.

Routers maintain separate routing information for IPv4 and IPv6. A route in the IPv4 table does not automatically create an IPv6 route, and an IPv6 route does not provide IPv4 reachability.

What a Routing Table Does

When a router receives a packet, it examines the destination IP address and searches for a matching route. The selected route identifies the next forwarding step. The packet may be sent directly to a connected destination or to another router called the next hop.

The routing table is different from two related structures:

  • Routing table, or RIB: The control-plane database containing learned and configured routes, including alternatives that may not currently be selected.
  • Forwarding information base, or FIB: An optimized forwarding structure derived from the routing information. Cisco Express Forwarding commonly uses the FIB to make packet-forwarding decisions efficiently.
  • ARP or IPv6 Neighbor Discovery table: A Layer 2 resolution table that maps a local next-hop IP address to a MAC address on IPv4, or resolves an IPv6 neighbor using Neighbor Discovery. It does not decide which network route should be used.

Route Entry Anatomy

A route entry normally describes a destination network and how to reach it. The exact display varies by IOS release and route type.

FieldMeaningExample value
Destination prefixNetwork address and prefix length10.20.30.0/24
Route code/sourceHow the route was learnedO for OSPF
Administrative distancePreference between different route sources110
MetricPath-quality value used by a routing protocol20
Next hopNeighbor router or destination address to which the packet is sent next192.0.2.2
Exit interfaceLocal interface used for transmissionGigabitEthernet0/0
Age or update timeHow long ago the route was learned or refreshed, when IOS provides it00:12:41
Default indicatorMarks a candidate default route or gateway of last resortS*

Cisco IOS Route Codes

A route code is a marker showing the route source. It identifies how IOS learned the route; it does not by itself prove that the route is the one currently selected for forwarding.

Route codeRoute sourceHow the route is learnedCCNA relevance
CConnectedCreated from an active Layer 3 interface and its subnetFundamental local reachability
LLocalHost route to the router's own interface addressImportant IOS IPv4 and IPv6 entry
SStaticConfigured manually by an administratorPredictable paths and small networks
S*Default staticStatic route for 0.0.0.0/0Common edge-router default
RRIPLearned through Routing Information ProtocolRecognition and administrative distance
OOSPFLearned through Open Shortest Path FirstCommon CCNA link-state protocol
DEIGRP internalLearned as an internal EIGRP routeRecognition and preference
EXEIGRP externalRedistributed or externally learned EIGRP routeRecognize its different preference
BBGPLearned through Border Gateway ProtocolBasic route-source recognition
iIS-ISLearned through Intermediate System to Intermediate SystemRecognition-level knowledge

Connected and Local Routes

When an interface has a valid Layer 3 address, is administratively enabled, and is operationally up, IOS installs a connected route for the interface's subnet. For example, an active interface addressed as 192.0.2.1/24 creates reachability for 192.0.2.0/24.

IOS also installs a local route, normally a /32 host route, for the interface's own IPv4 address, such as 192.0.2.1/32. This lets the router identify traffic addressed specifically to itself. IPv6 uses the same concepts: an active interface creates a connected IPv6 prefix route and a local route for its interface address, commonly represented as a /128 host route.

R1# show ip route connected
R1# show ipv6 route connected
R1# show ip interface brief
R1# show ipv6 interface brief

If the interface is shut down, has a physical or data-link failure, or lacks a valid address, the connected route may disappear. A connected route is therefore dependent on interface state, not merely on a saved configuration line.

Static Routes

A static route is manually configured. It can specify a next-hop IP address, an exit interface, or both.

ip route 192.0.2.0 255.255.255.0 10.0.0.2
ip route 192.0.2.0 255.255.255.0 GigabitEthernet0/0
ip route 192.0.2.0 255.255.255.0 10.0.0.2 200
ipv6 route 2001:db8:20::/64 2001:db8:10::2
ipv6 route 2001:db8:20::/64 GigabitEthernet0/0 2001:db8:10::2
  • Next-hop-only: IOS resolves the next-hop address and determines how to reach it.
  • Exit-interface-only: IOS sends the packet through the named interface. This can be useful on point-to-point links, but on multiaccess Ethernet it may cause repeated Layer 2 resolution or ambiguity.
  • Fully specified: The route includes both the exit interface and next-hop address. This can make forwarding intent explicit and is useful on some network types.

A next-hop-only static route uses recursive lookup. If the route says to use 10.0.0.2, the router must perform another lookup to find a connected or learned route for 10.0.0.2. If no usable route reaches that next hop, the static route is unresolved and cannot provide forwarding.

Default and Floating Static Routes

An IPv4 default route is 0.0.0.0/0; an IPv6 default route is ::/0. These are the least-specific routes and match any destination for which no more-specific route exists.

ip route 0.0.0.0 0.0.0.0 203.0.113.1
ipv6 route ::/0 2001:db8:ff::1
ip route 192.0.2.0 255.255.255.0 10.0.0.2 200

The last example is a floating static route. Its administrative distance of 200 makes it less preferred than normal connected, static, OSPF, or many other primary routes. It becomes usable when the preferred route disappears or becomes less preferred.

Dynamic Routing Protocol Routes

Dynamic routing protocols exchange reachability information and calculate paths. Eligible results can be installed in the routing table. Distance-vector protocols generally learn destinations through neighboring routers and compare route information, while link-state protocols build a topology database and calculate paths through that topology.

A protocol may know several paths to a destination. The routing table normally installs the best eligible path, or multiple paths when equal-cost multipath, or ECMP, is supported and the paths meet the protocol's conditions. The protocol's own database can retain additional alternatives.

How Routes Are Selected

Route selection is easiest to remember as a sequence. Longest prefix match comes first. Administrative distance is not used to make a less-specific route beat a more-specific route.

Decision stageComparison madeWinning conditionExample
1. Prefix matchWhich routes contain the destination address?Most-specific, longest matching prefix/24 beats /16
2. Administrative distanceDifferent sources advertise the same prefixLowest distanceStatic 1 beats OSPF 110
3. MetricRoutes from the same protocol/sourceBest protocol-specific metric, usually lowestOSPF cost 10 beats cost 30
4. MultipathRemaining equal best pathsInstall or use multiple qualifying pathsECMP load sharing

Longest Prefix Match

The prefix length tells how many leading bits must match. A longer prefix is more specific. Consider these IPv4 routes:

10.0.0.0/8
10.10.0.0/16
10.10.20.0/24
0.0.0.0/0
  • 10.10.20.45 matches all four routes, so the /24 wins.
  • 10.10.8.45 matches /8, /16, and the default route, so the /16 wins.
  • 10.80.1.5 matches /8 and the default route, so the /8 wins.
  • 192.0.2.9 matches only the default route, so 0.0.0.0/0 wins.

Even if the /8 route came from a source with a lower administrative distance, a matching /24 is still selected first because specificity precedes administrative distance. IPv6 follows the same rule: a matching /64 beats a matching /48, and both beat ::/0.

Administrative Distance

Administrative distance, or AD, is a trust or preference ranking between route sources for the same destination. Lower values are preferred.

Route sourceDefault administrative distanceSelection implication
Connected0Preferred over other sources for the same prefix
Static1Normally preferred over dynamic sources
eBGP20Preferred over most interior protocols by default
EIGRP internal90Preferred over OSPF and RIP for the same prefix
OSPF110Common interior route preference
RIP120Less preferred than OSPF by default
EIGRP external170Less preferred than internal EIGRP and OSPF
iBGP200Low preference compared with most listed sources
Unknown or unusable255Never considered usable

For example, if 192.0.2.0/24 is learned through static routing, OSPF, and RIP, the default distances are 1, 110, and 120. The static route is selected. A custom distance can change this behavior and is the basis of floating static backups.

Metrics

A metric is a route-quality value used primarily to compare paths learned from the same routing protocol. Common ideas include RIP hop count, OSPF cost, and the EIGRP composite metric. BGP uses path attributes such as local preference, AS-path length, and other policy values rather than one simple interior-style cost.

Lower metrics are generally preferred, but protocol-specific rules determine the actual comparison. Do not confuse a metric with administrative distance: AD compares different sources, while a metric compares paths within a source.

Default Routes and Gateway of Last Resort

A default route is used only when no more-specific route matches. In Cisco IOS, the phrase gateway of last resort describes the configured or learned default forwarding path. It is a router concept, not the same as a default gateway configured on a host. A host sends off-subnet traffic to its default gateway; a router may use a gateway of last resort after searching its own table.

R1# show ip route
Gateway of last resort is 203.0.113.1 to network 0.0.0.0

R1# show ip route 0.0.0.0 0.0.0.0
R1# show ipv6 route ::/0

Packet Lookup and Forwarding Workflow

  1. The router receives a frame on an interface and removes the incoming Layer 2 header.
  2. It reads the packet's destination IP address and searches the appropriate IPv4 or IPv6 forwarding information.
  3. It applies longest prefix match, then route-source preference and protocol metric where competing routes have the same prefix.
  4. It determines the next hop and exit interface. A recursive lookup may be required.
  5. It resolves the local next hop: IPv4 uses ARP, while IPv6 uses Neighbor Discovery.
  6. It builds a new Layer 2 frame and transmits it through the selected interface.
  7. For a forwarded packet, IPv4 TTL or IPv6 Hop Limit is decremented. The router recalculates the IPv4 header checksum as required.

If no route and no default route match, the router drops the packet. A route can also exist but fail to forward if its next hop cannot be resolved or its exit interface is unavailable.

Reading Cisco IOS Routing Output

R1# show ip route
C    192.168.10.0/24 is directly connected, GigabitEthernet0/0
L    192.168.10.1/32 is directly connected, GigabitEthernet0/0
C    10.0.0.0/30 is directly connected, GigabitEthernet0/1
L    10.0.0.1/32 is directly connected, GigabitEthernet0/1
S    172.16.20.0/24 [1/0] via 10.0.0.2, 00:08:12, GigabitEthernet0/1
S*   0.0.0.0/0 [1/0] via 10.0.0.2, 00:08:12, GigabitEthernet0/1

In [1/0], the first number is administrative distance and the second is the metric. The next-hop address follows via; the elapsed time shows route age or update timing when available; the final value is the exit interface. The connected entries exist because the interfaces are active. The local entries identify the router's own interface addresses. The static entry reaches the remote LAN through 10.0.0.2. The asterisk marks a candidate default route.

R1# show ip route 172.16.20.0 255.255.255.0
R1# show ip route 172.16.20.10
R1# show ip route static
R1# show ip route connected
R1# show ipv6 route
R1# show ipv6 route 2001:db8:20::/64
R1# show ipv6 route static

Use a destination-specific command to verify the actual matching route, rather than assuming that the route source you expected is selected.

TaskIPv4 commandIPv6 command
Display all routesshow ip routeshow ipv6 route
Inspect a prefixshow ip route 192.0.2.0 255.255.255.0show ipv6 route 2001:db8:20::/64
Filter by sourceshow ip route staticshow ipv6 route static
Check interface stateshow ip interface briefshow ipv6 interface brief
Check Layer 2 resolutionshow arpshow ipv6 neighbors

Route Changes, Aging, and Summarization

Routes can be installed when an interface comes up, a static command is configured, or a routing protocol learns a valid advertisement. A route may be replaced when a better route becomes available, withdrawn after a failure, or aged out when protocol updates stop arriving.

When an interface goes down, its connected route is removed and dependent recursive routes may become unusable. Dynamic protocols then converge: routers exchange new information and update forwarding after a topology change. Convergence is the process of reaching a consistent view of the network.

Route summarization represents several smaller networks with one broader aggregate. It can reduce table size and update traffic, but a summary is less specific than its component routes. A more-specific route can therefore override the summary.

Practical Selection Examples

Basic IPv4 Table

Suppose R1 has 192.168.10.1/24 on GigabitEthernet0/0 and 10.0.0.1/30 on GigabitEthernet0/1. It also has a static route to 172.16.20.0/24 through 10.0.0.2. The table contains connected routes for both directly attached subnets, local host routes for 192.168.10.1/32 and 10.0.0.1/32, and the static remote-LAN route. A packet for 172.16.20.50 is sent to 10.0.0.2 through GigabitEthernet0/1 after ARP resolves that next hop.

Administrative Distance and a Backup

If 172.16.20.0/24 is learned through OSPF, its default AD is 110. A normal static route with AD 1 replaces it. To keep a static route only as backup, assign an AD greater than 110:

ip route 172.16.20.0 255.255.255.0 10.0.0.2 200

The floating route remains less preferred while OSPF is usable and can be selected after the OSPF route is withdrawn.

OSPF Metric Comparison

If OSPF knows two paths to the same prefix, one with cost 10 and another with cost 30, OSPF normally selects the cost-10 path. This is a metric decision because both paths came from OSPF. If one path were static and the other OSPF, administrative distance would be considered instead.

IPv6 Lookup

With connected 2001:db8:10::/64, static 2001:db8:20::/64, and ::/0, a packet for 2001:db8:20::25 uses the /64 static route. A packet for an unrelated Internet prefix uses ::/0. Neighbor Discovery resolves the IPv6 next hop on the local link.

Common Troubleshooting Process

  1. Verify the destination prefix and the intended next hop.
  2. Check interface addressing and state with show ip interface brief, show ipv6 interface brief, and show interfaces.
  3. Use show ip route <destination> or show ipv6 route <destination> to identify the actual selected route.
  4. Check for a more-specific route that unexpectedly overrides the expected path.
  5. When competing routes exist, compare administrative distance between sources and metrics within the same protocol.
  6. Verify recursive next-hop reachability and ARP or Neighbor Discovery resolution.
  7. Use ping and traceroute carefully. They test forwarding behavior, but a failed end-to-end test may also indicate a return-path, ACL, or host problem.
SymptomLikely routing-table causeVerification commandTypical correction
No route to a remote destinationNo matching route, withdrawn route, or missing advertisementshow ip route <destination>Restore the route source, correct the prefix or next hop, or add a suitable default
Unexpected pathMore-specific prefix, lower AD, lower metric, or ECMPshow ip route <destination>; tracerouteCorrect specificity, preference, metric, or intended path
Static route exists but traffic failsUnreachable next hop, down interface, failed ARP/ND, or missing return routeshow ip route <next-hop>; show arp; show ipv6 neighborsFix adjacency, interface state, next-hop address, or return routing
Connected route absentInterface shutdown, physical/data-link failure, or invalid addressshow ip interface brief; show running-config interface <interface>Enable and repair the interface and correct Layer 3 addressing
Default route not usedMore-specific route exists, default is absent, or its next hop is unresolvedshow ip route 0.0.0.0 0.0.0.0; show ipv6 route ::/0Confirm a usable default and investigate the more-specific match

CCNA Exam Notes

  • Apply longest prefix match before administrative distance and metric.
  • Lower administrative distance is preferred between different route sources.
  • Metrics compare paths within a routing protocol and are protocol-specific.
  • Connected routes are not installed merely because an interface is configured; the interface must have valid Layer 3 state.
  • IPv4 uses ARP for local next-hop resolution; IPv6 uses Neighbor Discovery.
  • 0.0.0.0/0 and ::/0 are default routes, not host default-gateway settings.
  • A route code identifies the source of a route, not necessarily the route selected for forwarding.

For related study, review the OSPF configuration fundamentals, OSPF route summarization, and link-state advertisements.