I'm working through my ICND 1 book (Wendell Odom CCENT/CCNA ICND 1 Official Exam Certification Guide, Second Edition). On page 484, its discussing identifying which route will be used when multiple routes are available.
Below is a snip of the output in the example:
172.16.0.0/16 is variably subnetted, 5 subnets, 4 masks
R 172.16.1.1/32 [120/1] via 172.16.25.2, 00:00:04, Serial0/1/1
R 172.16.1.0/24 [120/2] via 172.16.25.129, 00:00:09, Serial0/1/0
R 172.16.0.0/22 [120/1] via 172.16.25.2, 00:00:04, Serial0/1/1
R 172.16.0.0/16 [120/2] via 172.16.25.129, 00:00:09, Serial0/1/0
R 0.0.0.0/0 [120/3] via 172.16.25.129, 00:00:09, Serial0/1/0
The book states âIn cases where a particular destination IP address falls within the IP address range for multiple routes, then you pick the route with the longest prefix length. In this case:
Destination address 172.16.4.3 matches the last two routes listed in R1's routing table in the example, with the route for 172.16.0.0/16 having the longest prefix length.â
I wasn't clear on the term prefix length, but confirmed it just means mask, anyhow doesn't the route 172.16.0.0/22 have a longer prefix length than 172.16.0.0/16? Also, for what its worth, it the route for 172.16.0.0/22 has a better metric.
Any insight would be much appreciated, thank you!
172.16.0.0/22 = 172.16.0.0 255.255.252.0
So the range for this address is
172.16.0.1 -> 172.16.3.254 with 172.16.3.255 being the broadcast address.
So 172.16.4.3 does not match that routing entry so it will use 172.16.0.0.
The metric comes into play after the longest prefix has been chosen ie. if you had 2 or more entries with the same length prefix.