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?
- 10.0.0.3 via GigabitEthernet0/2 because 172.20.100.32/27 is the longest matching prefix for the destination address.Answer
- B10.0.0.1 via GigabitEthernet0/0 because static routes have a lower administrative distance than OSPF routes.
- C10.0.0.4 via GigabitEthernet0/3 because 172.20.100.40/30 has a longer prefix length than /27.
- D10.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
Key Concept
Router Forwarding Decision Logic and Longest Prefix Match (LPM)