8.3 Route Redistribution  
  8.3.3 Modifying administrative distance by using the distance command  
When using multiple IP routing protocols on a router, the default administrative distance of each is usually sufficient. However, some circumstances call for changing the administrative distance values on a router.

For example, if a router is running both IGRP and OSPF, it may receive routes to the same network from both protocols. The default administrative distances favors IGRP routes over OSPF routes. However, because IGRP does not support CIDR, the router will need to use the OSPF route instead. In this case, configure the local router to apply a custom administrative distance to all OSPF routes.

With the distance 95 OSPF configuration command, RTZ compares the IGRP and OSPF routes and comes up with a different result.

In its broadest application, the distance command can be used to modify the administrative distance value applied to all routes learned by way of a specific routing process. The commands in Figure will assign the value of 95 to all routes learned by the OSPF 1 process. Notice that these values are local to the router. Although RTZ assigns the 10.0.0.0 network an administrative distance of 95, all other Cisco OSPF routers will apply a value of 110, unless otherwise configured.

The distance command can also be applied with optional arguments to make changes to selected routes based on where they originate. The expanded syntax of the distance command is as follows:

Router(config-router)#distance weight [source-ip-address source-mask (access-list-number | name)]

After running multiple protocols on a boundary router, it may be discovered that one or two suboptimal paths have been installed because of their lower administrative distance. Rather than assign a new distance value to all routes learned by a process, specific routes can be identified based on their source IP. Using the optional arguments, configure a router as follows to apply an administrative distance of 105 to all RIP routes received from 10.4.0.2:

RTZ(config)#router rip
RTZ(config-router)#distance 105 10.4.0.2 255.255.255.255

Alternatively, an administrative distance value can be applied to only certain routes from that same source by specifying an access list.

Remember that the administrative distance defaults exist for a reason and will serve a network well in most circumstances. Use the distance command only when certain that it is necessary to guarantee optimal routing.