Exam alignment

Cisco objective 3.1 asks you to interpret routing-table components. Cisco objective 3.2 asks you to determine the default forwarding decision using longest prefix match, administrative distance, and routing protocol metric. This lesson combines both because they are operationally inseparable.

Learning Outcomes

Interpret each field in Cisco show ip route output.

Recognize common route-source codes such as L, C, S, O, D, R, and B.

Explain prefixes, subnet masks, next-hop addresses, exit interfaces, administrative distance, and metric.

Explain when and how a gateway of last resort is used.

Determine the complete routing/forwarding decision using longest prefix match, administrative distance, and routing protocol metric in the correct hierarchy.

Configure connected, static, default, and basic OSPF routes to generate realistic routing-table entries.

Use show commands, ping, traceroute, ARP, and CEF checks to troubleshoot routing problems.

Explain the control plane, data plane, RIB, FIB, and adjacency table and show how they interact during routing and forwarding.

Determine how a router forwards a packet by default: longest prefix match, default-route fallback, adjacency resolution, Layer 2 rewrite, and drop behavior when no route exists.


Suggested Study Flow

1. Understand what the routing table is and how connected, static, dynamic, and default routes enter it.

2. Learn how to read show ip route: route code, prefix/mask, next hop, exit interface, AD, and metric.

3. Understand the gateway of last resort and when the default route is used.

4. Master the complete decision hierarchy: longest prefix match first; for the same prefix compare AD; within the same protocol compare metric.

5. Learn the control plane and data plane: RIB route selection, CEF/FIB programming, adjacency resolution, and packet forwarding.

6. Walk through the default router forwarding process step by step from ingress frame to egress transmission.

7. Configure connected, static, default, and OSPF routes, then finish with verification, troubleshooting, and the enterprise lab.


1. What Is a Routing Table?

A routing table is the Layer 3 decision database a router or multilayer switch uses to determine where IP packets should be forwarded. It contains destination networks, how those networks were learned, the preferred path to each destination, and forwarding information such as a next-hop address or outgoing interface.

On Cisco IOS and IOS XE, the main operational command is show ip route. The resulting output is often called the Routing Information Base (RIB). Cisco Express Forwarding (CEF) builds a forwarding structure from the selected routes so packet forwarding can occur efficiently in the data plane.

Important distinction

The routing table is not a list of every path ever learned. It normally contains the best route or equal-cost best routes that survived protocol selection and route-source preference.


Pasted content image

Figure 1 - Routes can enter the RIB from connected interfaces, static configuration, dynamic routing, and a default route.


2. How Routes Enter the Routing Table

Route type

How it appears

How it is created

Typical example

Local

L

Automatically for each configured interface IP

L 10.10.10.1/32

Connected

C

Automatically when an interface is up/up with an IP prefix

C 10.10.10.0/24

Static

S

Configured with ip route

S 172.16.50.0/24 [1/0] via 10.0.12.2

Dynamic - OSPF

O

Learned through OSPF adjacency and LSDB calculation

O 10.30.30.0/24 [110/3] via 10.0.12.2

Default

S* / protocol-specific *

Static or dynamically learned 0.0.0.0/0

S* 0.0.0.0/0 [1/0] via 203.0.113.1

Connected and local routes appear only when the interface is operational. If the interface is administratively shut or line protocol is down, the associated connected/local routes are removed. Static routes depend on the configured next hop or interface and may also disappear if their resolution fails. Dynamic routes depend on routing-protocol operation and neighbor/path availability.


3. Reading show ip route

Example routing table

R1# show ip route

Codes: L - local, C - connected, S - static, O - OSPF

Gateway of last resort is 203.0.113.1 to network 0.0.0.0

 

C 10.10.10.0/24 is directly connected, GigabitEthernet0/0

L 10.10.10.1/32 is directly connected, GigabitEthernet0/0

C 10.0.12.0/30 is directly connected, GigabitEthernet0/1

L 10.0.12.1/32 is directly connected, GigabitEthernet0/1

O 10.20.20.0/24 [110/2] via 10.0.12.2, 00:00:35, GigabitEthernet0/1

O 10.30.30.0/24 [110/3] via 10.0.12.2, 00:00:35, GigabitEthernet0/1

S* 0.0.0.0/0 [1/0] via 203.0.113.1


Pasted content image

Figure 3 - Anatomy of an OSPF route entry.


For a learned route such as O 10.20.20.0/24 [110/2] via 10.0.12.2, the first value inside brackets is administrative distance and the second is the routing protocol metric. The next-hop address identifies the immediate Layer 3 neighbor to which the packet should be sent. The exit interface is the local interface used to reach that next hop.


4. Routing Protocol Code

The route code is the symbol at the beginning of a routing-table entry. It identifies the route source. The code is essential because it tells you whether the route came from the local device, a static configuration, OSPF, EIGRP, RIP, BGP, or another source.

Code

Meaning

Operational interpretation

L

Local

Host route to an IP address configured on the local router interface.

C

Connected

Network is directly attached to an up/up local interface.

S

Static

Route was manually configured with ip route.

O

OSPF

Route was learned through OSPF.

O IA

OSPF inter-area

Route came from a different OSPF area.

D

EIGRP

Route was learned using EIGRP.

R

RIP

Route was learned using RIP.

B

BGP

Route was learned using BGP.

*

Candidate default

The route is eligible to serve as a default route / gateway of last resort.

CCNA focus

You do not need every possible IOS route code memorized. Be comfortable identifying the major route sources and recognizing OSPF variations when they appear.


5. Prefix

A prefix is the destination network portion of a route. In 10.20.20.0/24, the destination prefix is 10.20.20.0 and the prefix length is /24. A packet does not need to have the exact destination address 10.20.20.0; any destination address that falls inside that prefix can match the route.

Route

Address range concept

Specificity

10.0.0.0/8

All addresses whose first octet is 10

8 network bits

10.10.0.0/16

Addresses beginning 10.10

16 network bits

10.10.10.0/24

Addresses beginning 10.10.10

24 network bits

10.10.10.128/25

10.10.10.128-10.10.10.255

25 network bits

0.0.0.0/0

All IPv4 destinations

0 network bits - least specific

Longer prefix lengths are more specific. This becomes critical during forwarding because a router can have several routes that all match the same destination address; the longest matching prefix is selected.

 

6. Network Mask and Prefix Length

The network mask identifies which bits of an IPv4 address represent the network prefix. Cisco routing output usually represents this as CIDR prefix length. For example, /24 is equivalent to 255.255.255.0, /30 is 255.255.255.252, and /32 identifies a single host address.

Prefix length

Dotted-decimal mask

Common use

/8

255.0.0.0

Large aggregate

/16

255.255.0.0

Medium aggregate

/24

255.255.255.0

Typical LAN

/30

255.255.255.252

Point-to-point IPv4 link

/32

255.255.255.255

Host/local route

 

Watch the distinction

Prefix is the network being reached. Prefix length/network mask defines the size of that network. A /32 local route is more specific than the connected /24 containing the same interface IP.


7. Next Hop and Exit Interface

The next hop is the address of the neighboring Layer 3 device that should receive the packet next. The next hop is not normally the final destination; it is the next router on the path. For directly connected routes, Cisco often displays “is directly connected” instead of a next-hop address.

Pasted content image

Figure 7 - Recursive next-hop resolution.


A router must be able to resolve the next-hop IP to a reachable connected path. In the example, the route to 172.16.50.0/24 points to 10.0.12.2. R1 also has a connected route to 10.0.12.0/30, so it knows that 10.0.12.2 is reachable through Gi0/1. ARP can then resolve the next-hop MAC address on Ethernet.


Verification

R1# show ip route 172.16.50.0

Routing entry for 172.16.50.0/24

 Known via "ospf 1", distance 110, metric 30

 * 10.0.12.2, from 2.2.2.2, via GigabitEthernet0/1

 

R1# show ip route 10.0.12.2

Routing entry for 10.0.12.0/30

 Known via "connected", distance 0, metric 0

 * directly connected, via GigabitEthernet0/1


8. Administrative Distance (AD)

Administrative distance is a local Cisco preference value used when the device knows the same destination prefix from different route sources. Lower AD is more trusted. AD does not travel with the packet and is not exchanged as a universal network-wide value; it is a local decision parameter on the router.


Pasted content image

Figure 8 - Same prefix, different route sources: lower administrative distance wins.


Route source

Default Cisco AD

Meaning

Connected

0

Most preferred because the network is directly attached.

Static

1

Normally preferred over dynamic protocols.

eBGP

20

External BGP route.

EIGRP internal

90

Internal EIGRP route.

OSPF

110

OSPF route.

IS-IS

115

IS-IS route.

RIP

120

RIP route.

EIGRP external

170

External EIGRP route.

iBGP

200

Internal BGP route.


Do not compare AD for different prefix lengths

A /25 OSPF route can be used over a /24 static route for destinations inside the /25 because forwarding first cares about longest prefix match. AD is relevant when competing routes describe the same prefix.


9. Routing Protocol Metric

A metric is a protocol-specific value used by a routing protocol to decide which path is best when multiple paths to the same prefix exist within that protocol. Lower is generally better for OSPF, RIP, and EIGRP, although the metric formula and meaning are different for each protocol.

Pasted content image

Figure 9 - OSPF compares OSPF cost for paths to the same prefix.


Protocol

Metric / path-selection input

Key idea

OSPF

Cost

Derived primarily from interface reference bandwidth/bandwidth relationship.

RIP

Hop count

Fewer routers/hops is better; 15 is maximum usable.

EIGRP

Composite metric

Primarily bandwidth and delay by default, with other K values available.

BGP

Path attributes

Uses a sequence of path attributes rather than a single IGP-style metric.

Never compare an OSPF cost of 20 directly with a RIP hop count of 2. The router first selects the preferred route source using administrative distance for the same prefix; metric is meaningful within the route source/protocol calculation.


10. Gateway of Last Resort

The gateway of last resort is the next hop associated with a default route. The default prefix 0.0.0.0/0 matches every IPv4 address, but because its prefix length is zero it is less specific than every normal route. It is therefore used only when no more-specific route exists.


Pasted content image

Figure 10 - Static default route toward the ISP.


Configure and verify a static default route

R1(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.1

 

R1# show ip route | include Gateway|0.0.0.0

Gateway of last resort is 203.0.113.1 to network 0.0.0.0

S* 0.0.0.0/0 [1/0] via 203.0.113.1

If no default route exists and no specific route matches a destination, the router drops the packet and may return an ICMP destination-unreachable message depending on the situation.


11. Forwarding Decision: Longest Prefix Match, Administrative Distance, and Metric

For CCNA, use one decision hierarchy but keep the control-plane and data-plane roles clear. First, compare destination prefixes by longest prefix match. If the exact same prefix is learned from different route sources, administrative distance (AD) determines which source is preferred for installation. If the same routing protocol has multiple paths to that prefix, the protocol metric selects the preferred path or equal-cost paths. These AD/metric choices occur in the control plane before packets are forwarded. The selected route or routes are installed in the RIB and programmed into CEF; the data plane then performs the actual packet forwarding by using the FIB and adjacency information. Sections 12 and 13 show this process in detail.


11.1 Complete Decision Hierarchy

Rule 1 - Longest Prefix Match (LPM): Compare all installed prefixes that contain the destination IP address and choose the prefix with the greatest prefix length. A matching /25 beats a /24, a /24 beats a /16, and every specific route beats 0.0.0.0/0. Prefix specificity is evaluated before AD because routes with different prefix lengths are different destinations in the routing table.


Rule 2 - Administrative Distance (AD): If multiple route sources offer the exact same prefix and mask, AD determines which route source is trusted. Lower AD is preferred. For example, a static 10.20.20.0/24 route with AD 1 is normally preferred over an OSPF 10.20.20.0/24 route with AD 110. AD is a control-plane selection value; it is not recalculated for every packet.


Rule 3 - Routing Protocol Metric: After the route source is known, the routing protocol compares its own path metric for multiple paths to the same prefix. OSPF uses cost, RIP uses hop count, and EIGRP uses its composite metric. The best metric is installed, or multiple equal-cost paths can be installed when equal-cost multipath is supported.


Decision priority: Different prefix lengths -> longest prefix match. Same prefix learned from different route sources -> administrative distance. Same prefix learned by the same protocol over multiple paths -> protocol metric. Equal-cost paths may be installed together and then used by CEF for load sharing.


Exam-style example: Suppose 10.10.10.130 matches an OSPF /25, a static /24, an OSPF /16, and the default route. The OSPF /25 wins because it is the longest match even though static normally has a lower AD. If both static and OSPF advertise the same /25, static normally wins because AD 1 is lower than OSPF AD 110. If OSPF has two paths to that /25 with costs 10 and 30, cost 10 is preferred; if both costs are equal and the platform allows ECMP, both next hops can be installed.


11.2 Commands to Verify Each Decision Stage

Routing table / AD / metric: Use show ip route and show ip route <prefix> to see the installed route, route code, prefix, AD/metric pair, next hop, and exit interface. Use show ip protocols to verify protocol parameters and administrative-distance information. For OSPF, show ip ospf interface can help verify interface cost.

R1# show ip route

R1# show ip route 10.20.20.0

R1# show ip protocols

R1# show ip ospf interface

R1# show ip cef 10.10.10.130 detail

R1# show adjacency

Data-plane validation: show ip cef <destination> reveals the CEF/FIB forwarding entry selected for the destination. show adjacency verifies the Layer 2 rewrite information associated with the next hop. These commands show the result of the control-plane choices after AD and metric have already influenced route installation.

Pasted content image

Figure 11.2 - Complete forwarding-decision hierarchy: longest prefix match, administrative distance, and protocol metric feed the RIB/CEF forwarding result.


Destination

Matching routes

Selected route

Reason

10.10.10.130

10.0.0.0/8, 10.10.0.0/16, 10.10.10.0/24, 10.10.10.128/25

10.10.10.128/25

Longest prefix: 25 bits

8.8.8.8

0.0.0.0/0 only

0.0.0.0/0

Only matching route

10.10.10.20

10.0.0.0/8, 10.10.0.0/16, 10.10.10.0/24

10.10.10.0/24

Longest matching prefix is /24


12. Control Plane and Data Plane

A router performs two related but different jobs. The control plane learns and selects routes. The data plane forwards actual packets. Keeping these roles separate is one of the most useful ways to understand routing-table questions and troubleshoot forwarding problems.

Pasted content image

Figure 8 - The control plane builds the RIB; the data plane uses the FIB and adjacency information to forward packets.


Control plane responsibilities

Learns directly connected networks when interfaces are configured and operational.

Accepts administrator-defined static and default routes.

Runs routing protocols such as OSPF, exchanges control packets, and calculates best paths.

Uses each protocol's path-selection rules and metric to choose best path(s) within that protocol.

Uses administrative distance when the same prefix is presented by different route sources, then installs the preferred route(s) in the Routing Information Base (RIB).

Programs the forwarding structures used by the data plane. On modern Cisco platforms this normally includes the CEF Forwarding Information Base (FIB) and adjacency table.


Data plane responsibilities

Receives packets on an ingress interface and performs a forwarding lookup for the destination IP address.

Uses longest prefix match against installed forwarding entries. It does not compare routing protocol code, AD, or metric for every packet.

Resolves the egress interface and next-hop Layer 2 adjacency, rewrites the Layer 2 header, decrements TTL, updates the IPv4 header checksum, and transmits the packet.

Uses an installed default route only when no more-specific route matches.

Drops traffic when no route matches and no usable default route exists; depending on conditions, the router can return an ICMP destination-unreachable message.

Topic

Control plane

Data plane

Primary job

Learn/select routes

Forward packets

Main structures

Routing protocols, RIB

CEF FIB, adjacency table

Uses AD / metric?

Yes, during route selection

No, not per packet

Uses longest prefix match?

Builds installed prefixes

Yes, for each destination lookup

Example commands

show ip route; show ip protocols

show ip cef; show adjacency

Control-plane example: build routing information

R1(config)# interface GigabitEthernet0/0

R1(config-if)# ip address 10.0.12.1 255.255.255.252

R1(config-if)# no shutdown

! Connected route appears automatically

R1(config)# ip route 172.16.50.0 255.255.255.0 10.0.12.2

! Static route enters the candidate routing information

R1(config)# router ospf 1

R1(config-router)# network 10.0.12.0 0.0.0.3 area 0

Verify the RIB and forwarding structures

R1# show ip route

R1# show ip route 172.16.50.0

R1# show ip protocols

R1# show ip cef 172.16.50.25

R1# show adjacency

CEF note: Cisco Express Forwarding is typically enabled on modern IOS/IOS XE platforms. CCNA questions focus on the logical result: the router uses the installed forwarding entry, performs longest prefix match, resolves the next-hop adjacency, and forwards the packet. Platform-specific hardware implementation can differ.


12.1 Control Plane - Topology, Configuration, and Verification

The control plane is responsible for learning reachability information and deciding which routes should become active. It receives connected routes from interface state, static routes from configuration, and dynamically learned routes from protocols such as OSPF. The control plane performs route selection before user packets arrive. The result is installed in the Routing Information Base (RIB), and the selected forwarding information is then programmed into CEF.

Pasted content image

Figure 12.1 - Control-plane topology: OSPF exchanges information, the router selects routes, and the RIB is built before packet forwarding.


Control-plane route-selection sequence

1. An interface becomes up/up, so IOS creates connected (C) and local (L) routes.

2. Static and default routes configured with ip route are evaluated for usability.

3. OSPF forms neighbors, exchanges LSAs, builds the LSDB, runs SPF, and calculates OSPF cost.

4. Each routing protocol selects its own best path(s) using its protocol-specific rules and metric.

5. If the same prefix is offered by different route sources, administrative distance determines which source is preferred.

6. The winning route or equal-cost routes are installed in the RIB.

7. CEF derives the FIB and adjacency information from the installed routing and Layer 2 state.


Example control-plane configuration on R1

R1(config)# interface GigabitEthernet0/0

R1(config-if)# ip address 10.0.12.1 255.255.255.252

R1(config-if)# no shutdown

R1(config-if)# exit

R1(config)# interface GigabitEthernet0/1

R1(config-if)# ip address 192.168.10.1 255.255.255.0

R1(config-if)# no shutdown

R1(config-if)# exit

R1(config)# router ospf 1

R1(config-router)# router-id 1.1.1.1

R1(config-router)# network 10.0.12.0 0.0.0.3 area 0

R1(config-router)# network 192.168.10.0 0.0.0.255 area 0

Control-plane verification commands

R1# show ip interface brief

R1# show ip protocols

R1# show ip ospf neighbor

R1# show ip ospf database

R1# show ip route

R1# show ip route ospf

R1# show ip route 192.168.30.0

What each command proves

show ip interface brief - confirms interfaces can contribute connected routes.

show ip protocols - confirms routing-process parameters, participating networks, and route sources.

show ip ospf neighbor - confirms OSPF adjacency state.

show ip ospf database - verifies the LSDB used by the OSPF control plane.

show ip route - displays the selected RIB entries after AD and metric decisions.


12.2 Data Plane - Topology, CEF, FIB, and Adjacency

The data plane forwards the actual user packets. On modern Cisco IOS/IOS XE devices, Cisco Express Forwarding (CEF) normally provides the forwarding structures. The Forwarding Information Base (FIB) contains destination prefixes and resolved next-hop/egress information. The adjacency table contains Layer 2 rewrite information such as the next-hop MAC address. The data plane does not rerun OSPF, compare administrative distance, or calculate a routing metric for every packet.

Pasted content image

Figure 12.2 - Data-plane topology: each router performs a FIB lookup, resolves the adjacency, rewrites the Layer 2 frame, and forwards the packet.


Data-plane packet processing

1. The ingress interface receives a Layer 2 frame and validates it for local processing/forwarding.

2. The router removes the incoming Layer 2 header and reads the destination IP address.

3. CEF performs a longest-prefix-match lookup in the FIB.

4. The selected FIB entry identifies the egress interface and next hop; recursive resolution is already optimized by CEF where possible.

5. The adjacency table supplies Layer 2 rewrite information. For IPv4 Ethernet, ARP is used when the required MAC address is not already known.

6. The router decrements TTL and updates the IPv4 header checksum.

7. A new Layer 2 header is built for the outgoing link. The source and destination IP addresses normally remain unchanged end to end unless NAT or another feature changes them.

8. The packet is queued and transmitted from the egress interface.


Data-plane verification commands

R1# show ip cef

R1# show ip cef 192.168.30.10

R1# show adjacency

R1# show adjacency detail

R1# show arp

R1# show interfaces GigabitEthernet0/0

R1# ping 192.168.30.10

R1# traceroute 192.168.30.10

CEF note

CEF is enabled by default on most modern Cisco IOS/IOS XE platforms.

show ip cef verifies the FIB; show adjacency verifies Layer 2 rewrite information.

Some platforms also support show ip cef exact-route <source> <destination> to show the CEF-selected path for a specific flow.

If a route is present in the RIB but forwarding fails, inspect CEF, adjacency/ARP, the egress interface, ACLs, and the return path.


12.3 How the Control Plane Programs the Data Plane

Think of the control plane and data plane as a pipeline. The control plane decides what the best routes are; the data plane turns those decisions into fast forwarding entries. This distinction explains why administrative distance and routing metrics are route-selection values, while longest prefix match is the normal packet-forwarding rule.

Pasted content image

Figure 12.3 - RIB-to-FIB pipeline: route sources feed the RIB; CEF programs the FIB and adjacency table; packets are then forwarded from those structures.


13. Determine How a Router Makes a Forwarding Decision by Default

When an IPv4 packet actually arrives, the control plane has already used administrative distance and routing-protocol metrics to select and install the best route or equal-cost routes for each prefix. The data plane then performs the per-packet lookup: it compares the destination IP address with installed FIB prefixes, applies longest prefix match, resolves the selected next hop and adjacency, rewrites the Layer 2 header, and transmits the packet. Therefore, all three concepts belong to the overall routing/forwarding decision chain, but AD and metric act during route installation while longest prefix match acts during the packet lookup.


Pasted content image

Figure 12 - Default router forwarding decision from destination lookup through adjacency resolution and transmission.


Default forwarding sequence

Step 1 - Receive the frame

The ingress interface receives an Ethernet frame addressed to the router. The router removes the incoming Layer 2 header and examines the Layer 3 packet.


Step 2 - Inspect destination IP

The destination IPv4 address is the key input to the forwarding lookup. Source IP is not used for normal destination-based routing unless policy-based features are configured.


Step 3 - Longest prefix match

The FIB is searched for all prefixes that contain the destination. The route with the greatest prefix length wins. A /25 beats a matching /24, which beats a matching /16, and all of them beat 0.0.0.0/0.


Step 4 - Default-route fallback

If no specific route matches, the router can use the default route 0.0.0.0/0. Its next hop becomes the gateway of last resort. If no default route exists, forwarding fails.


Step 5 - Resolve next hop and egress interface

The forwarding entry identifies an outgoing interface and/or next-hop IP. The adjacency table supplies the Layer 2 information required to send the frame. ARP is used for IPv4 next-hop MAC resolution on Ethernet when necessary.


Step 6 - TTL and header processing

The router decrements the IPv4 TTL. If TTL reaches zero, the packet is discarded and an ICMP Time Exceeded message is normally generated. The IPv4 header checksum is updated.


Step 7 - Rewrite the Layer 2 header

A new Ethernet frame is built for the outgoing link. The source MAC becomes the router's egress-interface MAC; the destination MAC becomes the next-hop router or final destination host MAC.


Step 8 - Queue and transmit

The packet is placed in the appropriate egress queue and transmitted. The next router repeats the same forwarding process independently.


Example - destination 10.30.30.10

Installed prefix

Next hop

Does it match 10.30.30.10?

Preference

10.0.0.0/8

10.0.12.2

Yes

Less specific

10.30.0.0/16

10.0.12.2

Yes

More specific

10.30.30.0/24

10.0.12.2

Yes

Winner - longest prefix

0.0.0.0/0

203.0.113.1

Yes

Used only if no longer match exists

R1 selects 10.30.30.0/24 because /24 is the longest matching prefix. It then forwards toward 10.0.12.2. The administrative distance and OSPF/static metric values are not re-evaluated for this packet; they already influenced which route for 10.30.30.0/24 was installed.


Verification for a forwarding decision

R1# show ip route 10.30.30.10

R1# show ip cef 10.30.30.10

R1# show arp

R1# show adjacency

R1# ping 10.30.30.10

R1# traceroute 10.30.30.10

Pasted content image

Figure 13 - Each router performs a new FIB lookup and builds a new Layer 2 frame for its outgoing link.


Where AD and metric fit

For CCNA questions, separate route selection from packet forwarding. A routing protocol first uses its own metric or path-selection algorithm to identify its best path(s). When different route sources offer the same destination prefix, the router uses administrative distance to choose the preferred source for installation. Once the best route is installed in the RIB/FIB, packet forwarding uses longest prefix match. This distinction prevents the common exam mistake of choosing a less-specific route simply because it has a lower AD.


13.1 Default Routing Decision - Detailed Step-by-Step Walkthrough

By default, an IP router makes a destination-based forwarding decision. The destination IPv4 address is the primary lookup key. The source address is not used for ordinary destination-based routing. Features such as policy-based routing, VRFs, NAT, security policies, or tunnels can affect processing, but the CCNA default decision process is the sequence below.

Pasted content image

Figure 13 - Default forwarding decision: inspect the destination, perform longest prefix match, resolve the next hop and adjacency, rewrite Layer 2, and transmit.


Step 1 - Receive and validate the ingress frame

The router receives an Ethernet frame addressed to its ingress-interface MAC address (or otherwise destined for local Layer 3 forwarding). It checks the frame and removes the incoming Layer 2 header. At this point, the previous-hop MAC addresses are no longer relevant to the next outgoing Ethernet frame.


Step 2 - Inspect the IP header and destination address

For normal IPv4 routing, the router reads the destination IP address. Example: 172.16.10.130. The destination address is compared with installed forwarding prefixes. The source IP does not decide the normal route unless a policy feature explicitly changes the forwarding behavior.


Step 3 - Search the FIB

CEF searches the FIB, which is derived from the selected RIB routes. Only installed, usable forwarding entries participate. Routes that lost the AD/metric competition and were never installed are not reconsidered for each packet.


Step 4 - Apply longest prefix match

If several prefixes contain the destination, the router chooses the most specific prefix - the route with the largest prefix length. For 172.16.10.130, matching routes /16, /24, /25, and /0 can coexist, but /25 wins because it matches the greatest number of destination bits.


Step 5 - Use the gateway of last resort only as a fallback

The default route 0.0.0.0/0 matches every IPv4 address, but it is the least specific possible route. It is used only when no more-specific installed route matches. If no specific route and no usable default route exist, the packet is dropped; an ICMP destination-unreachable message can be generated when appropriate.


Step 6 - Resolve the next hop and outgoing interface

The selected route can point to a directly connected interface, a next-hop address, or both. If a remote next-hop IP is listed, the router resolves how to reach that next hop. This is recursive next-hop resolution. CEF normally stores a resolved forwarding result so the router does not perform a slow recursive software lookup for every packet.


Step 7 - Resolve the Layer 2 adjacency

On Ethernet, the router needs a destination MAC address for the outgoing frame. For a remote network, this is normally the next-hop router MAC. For a directly connected destination subnet, it is the destination host MAC. ARP populates this information for IPv4; CEF represents the resulting rewrite information in the adjacency table.


Step 8 - Apply IP forwarding changes

The router decrements the IPv4 TTL by one. If TTL reaches zero, the packet is discarded and an ICMP Time Exceeded message is normally generated. Because the IPv4 header changed, the header checksum is updated.


Step 9 - Rewrite the Layer 2 header

The incoming Ethernet header is not forwarded unchanged. The router builds a new Layer 2 frame appropriate to the egress link. On Ethernet, the source MAC becomes the router egress-interface MAC and the destination MAC becomes the next-hop or final-host MAC.


Step 10 - Queue and transmit

The packet is placed into the appropriate output queue and transmitted. The next router repeats its own independent FIB lookup. The route chosen by R1 is not carried as a route-selection instruction inside the IP packet.


Commands to validate the forwarding decision

R1# show ip route

R1# show ip route 172.16.10.130

R1# show ip cef 172.16.10.130

R1# show adjacency

R1# show arp

R1# traceroute 172.16.10.130

Worked example - why /25 wins

C 172.16.0.0/16 is directly connected, GigabitEthernet0/2

S 172.16.10.0/24 [1/0] via 10.0.12.2

O 172.16.10.128/25 [110/20] via 10.0.13.2

S* 0.0.0.0/0 [1/0] via 203.0.113.1

Destination 172.16.10.130 matches all four entries: /16, /24, /25, and /0.

The router forwards using 172.16.10.128/25 because /25 is the longest matching prefix.

The OSPF route can therefore beat the static /24 for this packet even though static routes normally have a lower administrative distance. The prefixes are different lengths, so longest prefix match controls forwarding.

If the /25 were removed, the /24 would become the best match. If the /24 were also removed, the /16 would match. If none of those existed, the default /0 would be used.

Administrative distance only matters when competing route sources offer the same prefix and prefix length. Protocol metric selects among candidate paths within the routing protocol before the winning route is installed.

CCNA decision rule to remember

Route installation: protocol-specific path selection/metric first, then administrative distance when the same prefix is offered by different sources.

Packet forwarding: longest prefix match among installed FIB entries.

Default route: used only when no more-specific route matches.

Equal-cost routes: if multiple next hops are installed for the same prefix, CEF can load-share flows across them.

No match + no default route: drop the packet.

Question type

Decision rule

Different prefix lengths match the destination

Longest prefix match wins

Same prefix from static and OSPF

Lower administrative distance is normally preferred for installation

Same prefix, multiple OSPF paths

OSPF cost/path-selection rules determine best/equal-cost paths

Multiple equal-cost paths installed

CEF can load-share using a hash across the installed next hops

No specific route, default route installed

Use 0.0.0.0/0 / gateway of last resort

No matching route and no default

Drop the packet


14. Worked Examples: Applying Longest Prefix, AD, and Metric Together

Point 11 defines the complete hierarchy, while Sections 12 and 13 explain how the control plane prepares the forwarding information and how the data plane forwards each packet. This section now applies the hierarchy to exam-style scenarios. Remember the order: different prefix lengths are resolved by longest prefix match; the same prefix from different route sources is resolved by administrative distance; and multiple paths to the same prefix within one routing protocol are resolved by that protocol's metric. Equal-cost paths may be installed simultaneously.

1. Identify all route prefixes that can match the destination address.

2. Choose the most specific matching prefix (longest prefix length).

3. If the router learned that same prefix from different route sources, the source with the lower administrative distance is normally installed/preferred.

4. Within a routing protocol, the protocol uses its metric/path-selection rules to choose the best path for that prefix.

5. If equal-cost paths are supported and installed, the router can load-share across multiple next hops.

Exam shortcut

Different prefix lengths -> longest prefix match. Same prefix from different protocols -> administrative distance. Same prefix within one protocol -> routing protocol metric.


15. Creating Connected and Local Routes

Connected and local routes are generated automatically when an interface has an IP address and is operational. A connected route represents the subnet. A local route is a /32 host route to the router’s own interface address.


Connected-route configuration

R1(config)# interface GigabitEthernet0/0

R1(config-if)# description USERS-LAN

R1(config-if)# ip address 10.10.10.1 255.255.255.0

R1(config-if)# no shutdown

 

R1# show ip route connected

C 10.10.10.0/24 is directly connected, GigabitEthernet0/0

L 10.10.10.1/32 is directly connected, GigabitEthernet0/0

If Gi0/0 goes down/down, both entries are removed. This makes show ip interface brief a critical companion command when a connected route is missing.


16. Creating Static Routes

A static route explicitly tells the router how to reach a destination prefix. You can specify a next-hop IP address, an exit interface, or both. On Ethernet multiaccess networks, next-hop IP configuration is generally clearer because it identifies the exact adjacent router.


Static network route

R1(config)# ip route 172.16.50.0 255.255.255.0 10.0.12.2

 

R1# show ip route static

S 172.16.50.0/24 [1/0] via 10.0.12.2

The [1/0] means administrative distance 1 and metric 0. A static route can also be given a higher administrative distance to act as a backup; that concept is called a floating static route and is covered more fully under the static-routing objective.


17. Generating Dynamic Routes with OSPF

OSPF is the dynamic routing protocol configured in the later CCNA IP Connectivity objectives. A small OSPF configuration is useful here because it produces realistic O route entries with an AD/metric pair.

Basic OSPF example

R1(config)# router ospf 1

R1(config-router)# router-id 1.1.1.1

R1(config-router)# network 10.0.12.0 0.0.0.3 area 0

R1(config-router)# network 10.10.10.0 0.0.0.255 area 0

 

R2(config)# router ospf 1

R2(config-router)# router-id 2.2.2.2

R2(config-router)# network 10.0.12.0 0.0.0.3 area 0

R2(config-router)# network 10.20.20.0 0.0.0.255 area 0

Verification

R1# show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface

2.2.2.2 1 FULL/DR 00:00:35 10.0.12.2 Gi0/1

 

R1# show ip route ospf

O 10.20.20.0/24 [110/2] via 10.0.12.2, 00:00:35, Gi0/1


18. End-to-End Packet Forwarding Example

Assume PC-A 10.10.10.10 sends traffic to PC-B 10.30.30.10. PC-A recognizes that 10.30.30.10 is outside its local /24 subnet, so it sends the frame to default gateway R1. R1 removes the incoming Layer 2 header and performs a Layer 3 route lookup for 10.30.30.10.

1. R1 finds O 10.30.30.0/24 [110/3] via 10.0.12.2 and selects it as the longest matching route.

2. R1 resolves next hop 10.0.12.2 through connected network 10.0.12.0/30 and forwards to R2.

3. R2 performs a new route lookup. Routers do not carry a previously selected route decision inside the packet.

4. R2 forwards toward R3 using its best route.

5. R3 sees 10.30.30.0/24 as connected and ARPs for PC-B if required.

6. Each router rewrites the Layer 2 header for its own outgoing link while the IP source/destination addresses remain end-to-end (absent NAT).

Key point

Route lookup happens at every Layer 3 hop. A next hop is local to the current router’s decision; it is not necessarily the final destination.


19. High-Value Verification Commands

Command

What it proves / reveals

show ip route

Complete IPv4 routing table and gateway of last resort.

show ip route <prefix>

Detailed route source, AD, metric, next hop, and age for one prefix.

show ip route connected

Connected and local routes only.

show ip route static

Static routes only.

show ip route ospf

OSPF routes only.

show ip protocols

Dynamic-routing process, networks, sources, and administrative distance information.

show ip interface brief

Interface status and IP addressing; crucial for missing connected routes.

show arp / show ip arp

Layer 2 resolution for directly connected IPv4 next hops.

show ip cef <destination>

CEF forwarding entry / adjacency on supported IOS/IOS XE.

ping <destination>

Basic reachability test.

traceroute <destination>

Shows the Layer 3 hop sequence when responses are permitted.


20. Detailed Route Inspection

Detailed route output

R1# show ip route 10.30.30.0

Routing entry for 10.30.30.0/24

 Known via "ospf 1", distance 110, metric 3, type intra area

 Last update from 10.0.12.2 on GigabitEthernet0/1, 00:00:35 ago

 Routing Descriptor Blocks:

 * 10.0.12.2, from 2.2.2.2, 00:00:35 ago, via GigabitEthernet0/1

 Route metric is 3, traffic share count is 1

This command is useful when a summary line from show ip route is not enough. It identifies the protocol, administrative distance, metric, route age, next hop, source router, and outgoing interface.


21. Enterprise Lab Topology

Pasted content image

Figure 15 - Three-router OSPF domain with LANs and a static default route at R1.


Device

Interface

IP / Prefix

Purpose

R1

Gi0/0

10.10.10.1/24

Users LAN

R1

Gi0/1

10.0.12.1/30

R1-R2

R1

Gi0/2

203.0.113.2/30

ISP uplink

R2

Gi0/0

10.0.12.2/30

R1-R2

R2

Gi0/1

10.0.23.1/30

R2-R3

R2

Gi0/2

10.20.20.1/24

Branch LAN

R3

Gi0/0

10.0.23.2/30

R2-R3

R3

Gi0/1

10.30.30.1/24

Server LAN


21.1 Lab Configuration - R1

hostname R1

!

interface GigabitEthernet0/0

 description USERS-LAN

 ip address 10.10.10.1 255.255.255.0

 no shutdown

!

interface GigabitEthernet0/1

 description TO-R2

 ip address 10.0.12.1 255.255.255.252

 no shutdown

!

interface GigabitEthernet0/2

 description TO-ISP

 ip address 203.0.113.2 255.255.255.252

 no shutdown

!

ip route 0.0.0.0 0.0.0.0 203.0.113.1

!

router ospf 1

 router-id 1.1.1.1

 network 10.10.10.0 0.0.0.255 area 0

 network 10.0.12.0 0.0.0.3 area 0


21.2 Lab Configuration - R2

hostname R2

!

interface GigabitEthernet0/0

 description TO-R1

 ip address 10.0.12.2 255.255.255.252

 no shutdown

!

interface GigabitEthernet0/1

 description TO-R3

 ip address 10.0.23.1 255.255.255.252

 no shutdown

!

interface GigabitEthernet0/2

 description BRANCH-LAN

 ip address 10.20.20.1 255.255.255.0

 no shutdown

!

router ospf 1

 router-id 2.2.2.2

 network 10.0.12.0 0.0.0.3 area 0

 network 10.0.23.0 0.0.0.3 area 0

 network 10.20.20.0 0.0.0.255 area 0


21.3 Lab Configuration - R3

hostname R3

!

interface GigabitEthernet0/0

 description TO-R2

 ip address 10.0.23.2 255.255.255.252

 no shutdown

!

interface GigabitEthernet0/1

 description SERVER-LAN

 ip address 10.30.30.1 255.255.255.0

 no shutdown

!

router ospf 1

 router-id 3.3.3.3

 network 10.0.23.0 0.0.0.3 area 0

 network 10.30.30.0 0.0.0.255 area 0


21.4 Expected R1 Routing Table

R1# show ip route

Gateway of last resort is 203.0.113.1 to network 0.0.0.0

 

C 10.10.10.0/24 is directly connected, GigabitEthernet0/0

L 10.10.10.1/32 is directly connected, GigabitEthernet0/0

C 10.0.12.0/30 is directly connected, GigabitEthernet0/1

L 10.0.12.1/32 is directly connected, GigabitEthernet0/1

O 10.20.20.0/24 [110/2] via 10.0.12.2, GigabitEthernet0/1

O 10.30.30.0/24 [110/3] via 10.0.12.2, GigabitEthernet0/1

C 203.0.113.0/30 is directly connected, GigabitEthernet0/2

L 203.0.113.2/32 is directly connected, GigabitEthernet0/2

S* 0.0.0.0/0 [1/0] via 203.0.113.1

The exact OSPF cost can differ if interface bandwidth/reference bandwidth differs from the assumptions used in a lab platform. The interpretation remains the same: O is the route code, 110 is OSPF administrative distance, the second bracketed value is OSPF cost, and 10.0.12.2 is the next hop.


22. Routing-Table Troubleshooting Workflow

1. Check physical/interface state with show ip interface brief. If an interface is not up/up, connected routes may be missing.

2. Confirm the interface IP address and mask. An incorrect mask changes the connected prefix and can break adjacency or forwarding.

3. Check show ip route for the exact destination or a matching summary/default route.

4. If the correct prefix exists, verify the next hop is reachable and its connected network is present.

5. If the same prefix is learned from multiple sources, compare administrative distance.

6. If multiple paths exist within one protocol, inspect the protocol metric and protocol-specific state.

7. Check the gateway of last resort if the destination is external or unknown.

8. Use ping to test reachability and traceroute to identify the hop where forwarding stops.

9. Confirm reverse routing. One-way routing can make a valid forward path appear broken.

10. Only after routing is validated, investigate ACLs, NAT, policy, firewall, or application issues.

Quick knowledge check

1. What does the code C mean in show ip route?.

Answer: Connected route

2. Can a router have multiple equal-cost next hops for one prefix?

Answer: Yes, when the protocol/platform installs equal-cost paths.

3. What is the first routing rule applied to a destination lookup?

Answer: Longest prefix match among installed routes.

4. What happens when there is no matching route and no default route?

Answer: The router drops the packet and may return ICMP destination unreachable.