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.
| Field | Meaning | Example value |
|---|---|---|
| Destination prefix | Network address and prefix length | 10.20.30.0/24 |
| Route code/source | How the route was learned | O for OSPF |
| Administrative distance | Preference between different route sources | 110 |
| Metric | Path-quality value used by a routing protocol | 20 |
| Next hop | Neighbor router or destination address to which the packet is sent next | 192.0.2.2 |
| Exit interface | Local interface used for transmission | GigabitEthernet0/0 |
| Age or update time | How long ago the route was learned or refreshed, when IOS provides it | 00:12:41 |
| Default indicator | Marks a candidate default route or gateway of last resort | S* |
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 code | Route source | How the route is learned | CCNA relevance |
|---|---|---|---|
| C | Connected | Created from an active Layer 3 interface and its subnet | Fundamental local reachability |
| L | Local | Host route to the router's own interface address | Important IOS IPv4 and IPv6 entry |
| S | Static | Configured manually by an administrator | Predictable paths and small networks |
| S* | Default static | Static route for 0.0.0.0/0 | Common edge-router default |
| R | RIP | Learned through Routing Information Protocol | Recognition and administrative distance |
| O | OSPF | Learned through Open Shortest Path First | Common CCNA link-state protocol |
| D | EIGRP internal | Learned as an internal EIGRP route | Recognition and preference |
| EX | EIGRP external | Redistributed or externally learned EIGRP route | Recognize its different preference |
| B | BGP | Learned through Border Gateway Protocol | Basic route-source recognition |
| i | IS-IS | Learned through Intermediate System to Intermediate System | Recognition-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 stage | Comparison made | Winning condition | Example |
|---|---|---|---|
| 1. Prefix match | Which routes contain the destination address? | Most-specific, longest matching prefix | /24 beats /16 |
| 2. Administrative distance | Different sources advertise the same prefix | Lowest distance | Static 1 beats OSPF 110 |
| 3. Metric | Routes from the same protocol/source | Best protocol-specific metric, usually lowest | OSPF cost 10 beats cost 30 |
| 4. Multipath | Remaining equal best paths | Install or use multiple qualifying paths | ECMP 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 source | Default administrative distance | Selection implication |
|---|---|---|
| Connected | 0 | Preferred over other sources for the same prefix |
| Static | 1 | Normally preferred over dynamic sources |
| eBGP | 20 | Preferred over most interior protocols by default |
| EIGRP internal | 90 | Preferred over OSPF and RIP for the same prefix |
| OSPF | 110 | Common interior route preference |
| RIP | 120 | Less preferred than OSPF by default |
| EIGRP external | 170 | Less preferred than internal EIGRP and OSPF |
| iBGP | 200 | Low preference compared with most listed sources |
| Unknown or unusable | 255 | Never 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
- The router receives a frame on an interface and removes the incoming Layer 2 header.
- It reads the packet's destination IP address and searches the appropriate IPv4 or IPv6 forwarding information.
- It applies longest prefix match, then route-source preference and protocol metric where competing routes have the same prefix.
- It determines the next hop and exit interface. A recursive lookup may be required.
- It resolves the local next hop: IPv4 uses ARP, while IPv6 uses Neighbor Discovery.
- It builds a new Layer 2 frame and transmits it through the selected interface.
- 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.
| Task | IPv4 command | IPv6 command |
|---|---|---|
| Display all routes | show ip route | show ipv6 route |
| Inspect a prefix | show ip route 192.0.2.0 255.255.255.0 | show ipv6 route 2001:db8:20::/64 |
| Filter by source | show ip route static | show ipv6 route static |
| Check interface state | show ip interface brief | show ipv6 interface brief |
| Check Layer 2 resolution | show arp | show 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
- Verify the destination prefix and the intended next hop.
- Check interface addressing and state with
show ip interface brief,show ipv6 interface brief, andshow interfaces. - Use
show ip route <destination>orshow ipv6 route <destination>to identify the actual selected route. - Check for a more-specific route that unexpectedly overrides the expected path.
- When competing routes exist, compare administrative distance between sources and metrics within the same protocol.
- Verify recursive next-hop reachability and ARP or Neighbor Discovery resolution.
- Use
pingandtraceroutecarefully. They test forwarding behavior, but a failed end-to-end test may also indicate a return-path, ACL, or host problem.
| Symptom | Likely routing-table cause | Verification command | Typical correction |
|---|---|---|---|
| No route to a remote destination | No matching route, withdrawn route, or missing advertisement | show ip route <destination> | Restore the route source, correct the prefix or next hop, or add a suitable default |
| Unexpected path | More-specific prefix, lower AD, lower metric, or ECMP | show ip route <destination>; traceroute | Correct specificity, preference, metric, or intended path |
| Static route exists but traffic fails | Unreachable next hop, down interface, failed ARP/ND, or missing return route | show ip route <next-hop>; show arp; show ipv6 neighbors | Fix adjacency, interface state, next-hop address, or return routing |
| Connected route absent | Interface shutdown, physical/data-link failure, or invalid address | show ip interface brief; show running-config interface <interface> | Enable and repair the interface and correct Layer 3 addressing |
| Default route not used | More-specific route exists, default is absent, or its next hop is unresolved | show ip route 0.0.0.0 0.0.0.0; show ipv6 route ::/0 | Confirm 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/0and::/0are 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.