Computer Networking Basics
A router's routing table has four routes: 0.0.0.0/0 (next hop router A), 10.0.0.0/8 (router B), 10.1.0.0/16 (router C) and 10.1.2.0/24 (router D). To which router is a packet for 10.1.5.9 sent?
- ARouter B
- BRouter D
- CRouter C
Show answer and explanation
Answer: C. Router C
Of the routes that match the destination address, a router chooses the one with the longest (most specific) prefix. This is called longest prefix match. 10.1.5.9 matches 0.0.0.0/0, 10.0.0.0/8 and 10.1.0.0/16, but it is not in the 10.1.2.0/24 range (10.1.2.0 to 10.1.2.255). The longest of the matches is /16, so the packet goes to router C. 0.0.0.0/0 is the default route that matches every destination and is used only when no other route matches.
- A. /8 also matches, but the longer /16 route matches too, so it is not chosen.
- B. 10.1.5.9 is not within 10.1.2.0/24 (10.1.2.0 to 10.1.2.255), so it does not match.
- C. Correct. It is the longest matching prefix, /16.