Question

Difficulty: MediumRouter Forwarding Decision Logic

Refer to the following routing table output from a Cisco router:

Codes: C - connected, S - static, R - RIP, D - EIGRP, O - OSPF

Gateway of last resort is not set

S 172.20.0.0/16 [1/0] via 10.0.0.1, GigabitEthernet0/0
D 172.20.100.0/24 [90/2578560] via 10.0.0.2, GigabitEthernet0/1
O 172.20.100.32/27 [110/20] via 10.0.0.3, GigabitEthernet0/2
S 172.20.100.40/30 [1/0] via 10.0.0.4, GigabitEthernet0/3

Which next-hop IP address and exit interface will the router select to forward an ingress IPv4 packet destined for 172.20.100.45?

  1. 10.0.0.3 via GigabitEthernet0/2 because 172.20.100.32/27 is the longest matching prefix for the destination address.Answer
  2. B
    10.0.0.1 via GigabitEthernet0/0 because static routes have a lower administrative distance than OSPF routes.
  3. C
    10.0.0.4 via GigabitEthernet0/3 because 172.20.100.40/30 has a longer prefix length than /27.
  4. D
    10.0.0.2 via GigabitEthernet0/1 because EIGRP routes take precedence over OSPF routes regardless of subnet mask length.

Answer

The router forwards the packet to next-hop 10.0.0.3 out interface GigabitEthernet0/2 because 172.20.100.32/27 is the longest matching prefix that encompasses destination 172.20.100.45.
When a router receives a packet, it compares the destination IPv4 address against all routes in the Routing Information Base (RIB). Destination 172.20.100.45 matches three routes: 172.20.0.0/16, 172.20.100.0/24, and 172.20.100.32/27. The longest matching prefix is 172.20.100.32/27 because 27 bits is the most specific mask matching the target IP. Therefore, the router forwards the packet to next-hop 10.0.0.3 out interface GigabitEthernet0/2.

Step-by-Step Solution

1
Determine which routing table prefixes encompass the destination IP address 172.20.100.45.
The prefixes 172.20.0.0/16, 172.20.100.0/24, and 172.20.100.32/27 match destination 172.20.100.45. The prefix 172.20.100.40/30 covers range .40 to .43 and does NOT match .45.
Routing lookup requires identifying all routes whose network mask bits match the destination address.
2
Compare the prefix lengths of all valid candidate routes.
The prefix length /27 is more specific (longer) than /24 and /16.
The router forwarding decision engine strictly follows the Longest Prefix Match (LPM) logic before considering Administrative Distance or Metric.
3
Identify the exit interface and next-hop IP associated with the longest prefix match.
The route entry 172.20.100.32/27 points to next-hop 10.0.0.3 via interface GigabitEthernet0/2.
The candidate route with the longest matching prefix determines the forwarding path.

Key Concept

Router Forwarding Decision Logic and Longest Prefix Match (LPM)
Rate this question