SkarpSkarp

Chapter 11 of 27

Routing Concepts: From Default Gateway to Path Selection

Move beyond a single LAN and discover how routers use routing tables, metrics, and administrative distance to choose the best path across networks.

27 min readen

Big Picture: From Switching to Routing

Layer 2 vs Layer 3

Switching is a Layer 2 function, forwarding frames using MAC addresses. Routing is a Layer 3 function, forwarding packets using IP addresses and routing tables.

Recall the OSI Model

From top to bottom: 1 Application, 2 Presentation, 3 Session, 4 Transport, 5 Network, 6 Data Link, 7 Physical. Routing lives at the Network layer, switching at the Data Link layer.

Campus Flow Overview

Hosts send traffic within a VLAN via switches. For remote networks, they send packets to a default gateway (router interface), which uses its routing table to reach other networks.

Exam Mindset

When you see MAC, VLAN, or STP, think switching. When you see IP networks, routing tables, or default gateways, think routing and Layer 3 decisions.

Default Gateway on Hosts vs Default Route on Routers

Host Default Gateway

A default gateway is the IP of a local router interface that a host uses when the destination IP is not in its own subnet.

Router Default Route

On routers, a default route (0.0.0.0/0 or ::/0) says: if no more specific route exists, forward packets to this next-hop or exit interface.

Analogy and Flow

Host: unknown network → send to default gateway. Router: unknown network → send via default route. This repeats hop by hop across the path.

Small Network Example

Hosts use the LAN router as default gateway; that router has a default route to the ISP. Packets traverse multiple routers, each using its routing table.

Inside a Routing Table: Route Types and Fields

What Is a Routing Table?

A routing table lists destination networks and how to reach them: route source, prefix, administrative distance, metric, and next-hop or exit interface.

Route Source Codes

Typical codes: C connected, L local, S static, O OSPF, D EIGRP, R RIP. These show how each route was learned.

Route Types

Directly connected and local routes appear automatically. Static routes are manual. Dynamic routes come from routing protocols such as OSPFv2.

Longest-Prefix Match

Routers pick the route whose prefix matches the destination IP with the greatest number of bits, even if another route has a lower metric.

Reading `show ip route`: A Worked Example

Sample Routing Table

A `show ip route` output lists connected (C), local (L), static (S), and dynamic (O for OSPF) routes plus a default route S* 0.0.0.0/0.

Interpreting Entries

Connected 10.0.0.0/24 is on G0/0, L 10.0.0.254/32 is the interface IP, O 172.16.0.0/16 is learned via OSPF from next-hop 10.0.0.1.

Default Route in Action

The S* 0.0.0.0/0 entry sends any traffic without a more specific match to 10.0.0.1, acting like a router-level default gateway.

Forwarding Decisions

Traffic to 172.16.5.10 uses OSPF route; traffic to 192.0.2.5 uses the default route, both via G0/0 to 10.0.0.1.

Static Routes and Default Routes: Concepts and Syntax

Static Route Basics

Static routes are manual entries telling a router how to reach a network. They are stable and simple but do not auto-adapt to failures.

IPv4 Static Route Syntax

Use `ip route <network> <mask> <next-hop>` or `ip route <network> <mask> <exit-interface>` with an optional administrative distance.

Default Static Route

A default route uses `0.0.0.0 0.0.0.0` for IPv4 or `::/0` for IPv6, sending all unknown traffic to a chosen next-hop router.

Reachability Requirement

A static route appears in the routing table only if the next-hop is reachable via another route or directly connected interface.

Hands-On: Configure and Verify Static and Default Routes

Practice-style configuration you could type on a lab router. Topology:

  • R1 G0/0: 10.0.0.1/24 (to R2)
  • R2 G0/0: 10.0.0.2/24 (to R1)
  • R2 G0/1: 192.168.50.1/24 (LAN)

Goal:

  • R1 should reach 192.168.50.0/24 via R2.
  • R2 should send all unknown traffic to R1 using a default route.

Configuration on R2 (LAN router):

```text

R2(config)# interface gigabitEthernet0/0

R2(config-if)# ip address 10.0.0.2 255.255.255.0

R2(config-if)# no shutdown

R2(config-if)# exit

R2(config)# interface gigabitEthernet0/1

R2(config-if)# ip address 192.168.50.1 255.255.255.0

R2(config-if)# no shutdown

R2(config-if)# exit

! Default route on R2 pointing to R1

R2(config)# ip route 0.0.0.0 0.0.0.0 10.0.0.1

```

Configuration on R1 (edge router):

```text

R1(config)# interface gigabitEthernet0/0

R1(config-if)# ip address 10.0.0.1 255.255.255.0

R1(config-if)# no shutdown

R1(config-if)# exit

! Static route to LAN behind R2

R1(config)# ip route 192.168.50.0 255.255.255.0 10.0.0.2

```

Verification:

```text

R1# show ip route 192.168.50.0

R1# ping 192.168.50.10

R2# show ip route

R2# show ip route 0.0.0.0

```

Think through the path: a host 192.168.50.10 sends to its default gateway 192.168.50.1 (R2), R2 uses its default route to reach R1, and R1 uses its own routes to reach further networks.

Metrics and Administrative Distance: Who Wins?

Administrative Distance

AD ranks route sources by trust. Lower is better: 0 connected, 1 static, 90 EIGRP, 110 OSPF, 120 RIP, 255 unusable.

Metrics

Metrics compare paths within a protocol. RIP uses hop count; OSPFv2 uses cost derived from bandwidth; lower metric is preferred.

Selection Process

First pick the lowest AD among routes to the same prefix, then the lowest metric within that protocol; remaining equal-cost paths may be load-balanced.

Local vs Shared

Administrative distance is local to each router and not advertised. Metrics are exchanged as part of the routing protocol updates.

Thought Exercise: Longest-Prefix Match and AD

Work through these scenarios mentally or on scratch paper. Focus on two key ideas: longest-prefix match and administrative distance.

Scenario 1: Longest-prefix match

Routing table entries on R1:

  • `S 10.0.0.0/8 [1/0] via 192.0.2.1`
  • `O 10.1.1.0/24 [110/20] via 203.0.113.1`

Question: A packet arrives with destination IP `10.1.1.50`. Which route is used and why?

Think it through:

  • Both routes match 10.1.1.50.
  • `/24` is more specific than `/8`.
  • Longest-prefix match beats AD and metric, so the OSPF route to 10.1.1.0/24 is chosen.

Scenario 2: Administrative distance

Routing table candidates on R2 for `172.16.0.0/16`:

  • Static: `S 172.16.0.0/16 [1/0] via 10.0.0.1`
  • OSPFv2: `O 172.16.0.0/16 [110/20] via 10.0.1.1`

Question: Which route appears in the routing table and is used for forwarding?

Think it through:

  • Same prefix length (`/16`), so longest-prefix match does not differentiate.
  • Compare AD: 1 (static) vs 110 (OSPF).
  • Static route wins; OSPF route is kept in the background and used only if the static route is removed or becomes invalid.

Pause and explain each answer to yourself in words. Being able to verbalize "why" is exactly what CCNA scenarios expect.

Quiz 1: Routing vs Switching and Default Gateway

Test your understanding of core routing concepts before we go deeper.

A host with IP 192.168.10.10/24 wants to reach 10.1.1.5. Its default gateway is 192.168.10.1. Which device makes the Layer 3 routing decision for this first hop, and what address does the host use as the destination MAC in its frame?

  1. The host makes the routing decision and uses the MAC of 10.1.1.5
  2. The default gateway router makes the routing decision; the host uses the MAC of 192.168.10.1
  3. The access switch makes the routing decision; the host uses the MAC of the switch
  4. The ISP router makes the routing decision; the host uses the MAC of 10.1.1.5
Show Answer

Answer: B) The default gateway router makes the routing decision; the host uses the MAC of 192.168.10.1

The host sees that 10.1.1.5 is not in its local /24 subnet, so it sends the packet to its default gateway. The host’s IP layer decides to forward to the gateway, but the first true Layer 3 routing decision for forwarding beyond the LAN is made by the router at 192.168.10.1. The host builds an Ethernet frame with destination MAC equal to the router’s interface MAC, not the remote host.

Quiz 2: Static Routes, Default Routes, and AD

Apply what you learned about static routes and administrative distance.

Router R3 has these routes to 192.168.50.0/24: 1) S 192.168.50.0/24 [1/0] via 10.0.0.2 2) O 192.168.50.0/24 [110/20] via 10.0.1.2 What will R3 do?

  1. Install only the OSPF route because its metric 20 is lower than 0
  2. Install both routes and load-balance because they have the same prefix length
  3. Install only the static route because its administrative distance is lower
  4. Discard both routes because they conflict
Show Answer

Answer: C) Install only the static route because its administrative distance is lower

For the same destination prefix, the router first compares administrative distance, not metric. The static route has AD 1, the OSPF route has AD 110. R3 installs only the static route in the routing table. The OSPF route is ignored for forwarding as long as the static route is valid.

Key Term Flashcards: Routing Essentials

Flip through these cards to reinforce key routing terms and relationships.

Routing
A Layer 3 function where a router forwards packets between different IP networks based on destination IP addresses and its routing table.
Switching
A Layer 2 function where a switch forwards frames within the same network based on destination MAC addresses and its MAC address table.
default gateway (host view)
A default gateway is the IP address of a router interface on the local network segment that a host uses to send traffic destined for remote networks.
Default route (router view)
A routing table entry (0.0.0.0/0 for IPv4, ::/0 for IPv6) that matches all destinations not covered by more specific routes and points to a next-hop or exit interface.
Administrative distance
A Cisco-specific value that ranks the trustworthiness of a route source; lower values are preferred when multiple routes to the same prefix exist.
Metric
A value used within a routing protocol to compare paths; examples include hop count (RIP) and cost based on bandwidth (OSPFv2). Lower metric is preferred.
Directly connected route
A route automatically created when a router interface with an IP address is up, representing the network on that interface.
Static route
A manually configured route that specifies a destination network and the next-hop IP or exit interface.
Longest-prefix match
The rule that, among all matching routes, the router chooses the route with the most specific prefix (largest subnet mask) for forwarding.

End-to-End Path Selection: Putting It All Together

From Host to Core

A client gets IP settings via DHCP, sends remote traffic to its default gateway; access switches forward frames within the VLAN using MAC addresses.

Routing Across the Network

The default gateway router consults its routing table; core and distribution routers use static and dynamic routes plus metrics and AD to select paths.

Edge and Beyond

An edge router typically uses a default route toward the ISP for unknown destinations, completing the path to external networks or the internet.

Your CCNA Focus

Be able to read `show ip route`, explain why a given path is chosen, and configure static and default routes that support end-to-end connectivity.

Key Terms

Metric
A value used within a routing protocol to compare paths; examples include hop count (RIP) and cost based on bandwidth (OSPFv2). Lower metric is preferred.
OSPFv2
Open Shortest Path First version 2 (OSPFv2) is a link-state interior gateway protocol used to exchange IPv4 routing information within a single autonomous system.
Routing
A Layer 3 function where a router forwards packets between different IP networks based on destination IP addresses and its routing table.
Switching
A Layer 2 function where a switch forwards frames within the same network based on destination MAC addresses and its MAC address table.
Static route
A manually configured route that specifies a destination network and the next-hop IP or exit interface.
Default route
A routing table entry (0.0.0.0/0 for IPv4, ::/0 for IPv6) that matches all destinations not covered by more specific routes and points to a next-hop or exit interface.
Routing table
The set of routes a router maintains, listing destination networks, administrative distance, metrics, and next-hop or exit interfaces used for forwarding.
default gateway
A default gateway is the IP address of a router interface on the local network segment that a host uses to send traffic destined for remote networks.
Longest-prefix match
The rule that, among all matching routes, the router chooses the route with the most specific prefix (largest subnet mask) for forwarding.
Administrative distance
A Cisco-specific value that ranks the trustworthiness of a route source; lower values are preferred when multiple routes to the same prefix exist.
Directly connected route
A route automatically created when a router interface with an IP address is up, representing the network on that interface.

Finished reading?

Test your understanding with a custom practice exam on this chapter.

Test yourself