Longest match, administrative distance and metric

Longest prefix match

Say a router has these routes:

RouteContains 10.1.1.77?Prefix length
0.0.0.0/0Yes (the default route matches everything)0
10.0.0.0/8Yes8
10.1.1.0/24Yes24
10.1.1.64/26Yes (.64 to .127)26
10.1.1.0/26No (.0 to .63)26

Four routes contain 10.1.1.77. The longest is 10.1.1.64/26, so that's the one used. To see the choice for one address, give it to show ip route.

R2 has a /24 static route for PC3's LAN. R1 has only a default route, so the default route is its longest match. And 10.0.12.1 is R1's own address, so its /32 local route wins:

In NetLab

▶ R2
R2>enable
R2#show ip route 192.168.3.10
Routing entry for 192.168.3.0/24
  Known via "static", distance 1, metric 0
  Routing Descriptor Blocks:
  * 10.0.23.2
      Route metric is 0, traffic share count is 1
▶ R1
R1>enable
R1#show ip route 192.168.3.10
Routing entry for 0.0.0.0 0.0.0.0, supernet
  Known via "static", distance 1, metric 0, candidate default path
  Routing Descriptor Blocks:
  * 10.0.12.2
      Route metric is 0, traffic share count is 1
R1#show ip route 10.0.12.1
Routing entry for 10.0.12.1/32
  Known via "connected", distance 0, metric 0 (connected)
  Routing Descriptor Blocks:
  * directly connected, via GigabitEthernet0/1
      Route metric is 0, traffic share count is 1

Administrative distance

Learn this table: the exam asks it, and it explains why a static route beats OSPF.

SourceAD
Connected0
Static1
eBGP20
EIGRP (internal)90
OSPF110
IS-IS115
RIP120
EIGRP (external)170
iBGP200
DHCP default route254
Unusable255 (never installed)

Metric

The metric compares paths inside one protocol: OSPF uses cost (based on bandwidth), RIP uses hop count, EIGRP uses bandwidth and delay. You can't compare an OSPF cost with a RIP hop count, which is why AD is checked first.

Tip: A router with no route for a destination drops the packet and sends back an ICMP unreachable. On a Cisco ping that shows as U; on a PC as "Destination net unreachable".

HOME LABS COMMUNITY DASHBOARD