Refer to the following routing table output from a Cisco router:
text
Gateway of last resort is 192.168.1.1 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 192.168.1.1
D 172.31.0.0/16 [90/2172416] via 10.1.1.1, 01:24:12, GigabitEthernet0/0
O 172.31.45.0/24 [110/20] via 10.2.2.2, 00:45:10, GigabitEthernet0/1
S 172.31.45.128/26 [1/0] via 10.3.3.3
D 172.31.45.128/27 [90/307200] via 10.4.4.4, 02:11:05, GigabitEthernet0/2
The router receives an IP packet with a destination address of . Which next-hop IP address will the router choose to forward this packet?
- 10.4.4.4Answer
- B10.3.3.3
- C10.2.2.2
- D192.168.1.1
Answer
The router will forward the packet to next-hop IP address 10.4.4.4.
When forwarding a packet, a Cisco router compares the destination IP address against all network entries in the routing table and selects the route with the longest prefix match (the most specific subnet mask). The destination address 172.31.45.138 matches 172.31.45.128/27 (host range .128–.159), which has a 27-bit mask length. This is more specific than the /26, /24, /16, or default /0 routes. Therefore, the router forwards the packet to next-hop 10.4.4.4 via GigabitEthernet0/2.
Step-by-Step Solution
Key Concept
Longest Prefix Match (LPM) precedence in router forwarding logic