Question

Difficulty: HardRouter Forwarding Decision Logic

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 172.31.45.138172.31.45.138. Which next-hop IP address will the router choose to forward this packet?

  1. 10.4.4.4Answer
  2. B
    10.3.3.3
  3. C
    10.2.2.2
  4. D
    192.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

1
Determine which routing entries encompass the destination IP address 172.31.45.138.
The destination address 172.31.45.138 falls within the ranges for 0.0.0.0/0, 172.31.0.0/16, 172.31.45.0/24, 172.31.45.128/26 (range 172.31.45.128 to 172.31.45.191), and 172.31.45.128/27 (range 172.31.45.128 to 172.31.45.159).
A router evaluates all matching routes in its routing table before selecting the forwarding path.
2
Apply the Longest Prefix Match (LPM) rule among all valid matching routes.
Prefix lengths are /0, /16, /24, /26, and /27. The route with the longest prefix length is 172.31.45.128/27.
Routers always prioritize the most specific route (longest subnet mask / prefix length) regardless of administrative distance or metric.
3
Identify the next-hop IP associated with the winning route 172.31.45.128/27.
The route specifies 'via 10.4.4.4, GigabitEthernet0/2'.
The packet must be forwarded to the next-hop interface/IP designated by the longest matching routing table entry.

Key Concept

Longest Prefix Match (LPM) precedence in router forwarding logic
Rate this question