One of the the concepts that comes up occasionally is that of precedence. For example, one might consider the following routing table entries.
ip route 0.0.0.0 0.0.0.0 22.214.171.124 //default route ip route 192.168.0.0 255.255.0.0 126.96.36.199 //supernet/cidr route ip route 192.168.1.0 255.255.255.0 188.8.131.52 //network route ip route 192.168.1.0 255.255.255.128 184.108.40.206 //subnet route ip route 192.168.1.20 255.255.255.255 220.127.116.11 //host route
Questions often arise around which path a packet would take when it matches more than one entry. For example, a packet may have a destination address of 192.168.1.20. In this case it matches every single route entry.
The logic is actually simple, even straightforward. A packet will follow the most specific route entry that it matches. So a packet destined to 192.168.1.20 would be routed to a router at 18.104.22.168. If the destination happened to be 192.168.1.21, it would be routed over to 22.214.171.124.
As a personal challenge, think about where packets with the following destinations might be routed:
As with everything, there can be some exceptions to the rule. I think one could contrive interesting examples with recursive routes. Another exception is when no ip classless has been configured on the router.
In that case, the rule only has a minor change. When using no ip classless, a packet will only use the default route when there are no subnets of its classful network. That process is describe in detail in Classful Routing With-no ip classless.
Disclaimer: This article includes the independent thoughts, opinions, commentary or technical detail of Paul Stewart. This
may or may does not reflect the position of past, present or future employers.