7.3 Route Redistribution
7.3.4
Modifying administrative distance by using the distance command
When using multiple IP routing protocols on a router, the default distances usually suffice. 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 favor IGRP routes over OSPF routes, as shown in the figure. However, because IGRP does not support CIDR, you may want the router to use the OSPF route instead. In this case, you can configure the local router to apply a custom administrative distance to all OSPF routes, as shown in the Figure.

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 via a specific routing process. The commands in the figure will assign the value of 95 to all routes learned by the OSPF 1 process. Note 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.

You can also apply the distance command 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, you may discover 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, you can configure a router 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, you can apply an administrative distance value 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 you are certain that it is necessary to guarantee optimal routing.