Default routes and the most specific match (longest match)
Sign in to read this lesson
A router connected to an ISP doesn't need every Internet network in its routing table: a default route (ip route 0.0.0.0 0.0.0.0 next-hop) matches all networks. Packets the router doesn't know where to deliver are thrown over to the ISP. A router always picks the most specific match (the longest prefix) in its routing table: for 192.168.1.140, the /25 wins over the /16 and /24 entries. The downside of static routes: in a network with many routers you have to write many routes, and there is no backup when a link fails.
What you will learn
- Default route:
ip route 0.0.0.0 0.0.0.0 1.2.3.1. The first 0.0.0.0 = all networks, the second 0.0.0.0 = all subnet masks, 1.2.3.1 = the next hop (the ISP router). - A default route matches every network: packets the router doesn't know where to deliver go to the ISP. There is no need to put every Internet network in the routing table.
- A router always uses the most specific match: when several entries match, the longest prefix wins.
- Example: destination 192.168.1.140 → /16, /24 and /25 all match, 192.168.1.128 /25 is chosen → 10.3.3.2.
- The downside of static routes: in a network with many routers you have to configure many routes, and there is no backup: when a link fails you have to edit the routes by hand. Such a network suits dynamic routing better.
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.