You want to change the administrative distance for an external network.
Use the distance command to adjust the administrative distance for a particular routing protocol. The precise syntax depends on the routing protocol. This example uses RIP:
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#router rip Router(config-route)#network 192.168.15.0 Router(config-route)#distance 15 192.168.15.1 0.0.0.0 Router(config-route)#distance 200 192.168.15.0 0.0.0.255 Router(config-route)#distance 255 Router(config-route)#end Router#
For EIGRP, you can specify the distance for routes learned from both internal and external neighbors:
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#router eigrp 111 Router(config-route)#network 192.168.16.0 Router(config-route)#distance eigrp 55 200 Router(config-route)#end Router#
With OSPF, you can also control the distance depending on whether the neighboring router is in the same area:
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#router ospf 66 Router(config-route)#distance ospf inter-area 115 Router(config-route)#distance ospf intra-area 105 Router(config-route)#distance ospf external 125 Router(config-route)#end Router#
Finally, you can configure BGP distances for internal, external, and local routes:
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#router bgp 65520 Router(config-route)#distance bgp 115 220 50 Router(config-route)#end Router#
When dealing with administrative distances, always bear in mind that they only affect route selection on a particular router. Administrative distances are not distributed by the routing protocols. However, they can affect the routing protocols; in particular, distance vector algorithms distribute only locally used routes. Adjusting the administrative distance could change which routes are used, so you should always be extremely careful when changing them.
The main place where it makes sense to consider changing the administrative distance for a routing protocol is when the same route is distributed by two different protocols. For example, suppose you have an OSPF network that uses EIGRP to distribute routes for dial backup links. When both the primary OSPF link and backup EIGRP link are active, the router will prefer the routes it learns via EIGRP by default (because of the lower administrative distance values). This will cause performance problems, since the backup link most likely has lower bandwidth and it may also interfere with dropping the dialup connection after the primary link recovers because the backup is actively passing traffic. Changing the administrative distance can be an effective way to resolve this kind of conflict. However, we want to stress that this is a relatively unusual case.
The default values for administrative distances are given in Table 5-1 and discussed in Recipe 5.5. You can adjust these values to force the router to prefer routes learned by one protocol over those learned from another. In Recipe 5.5, we gave high administrative distances to static routes so that the router would not use them unless the dynamic routing protocol was unavailable. This recipe shows that it is also possible to modify the administrative distances for the routing protocols themselves to allow one protocol to dominate over another.
In the RIP example shown in the solution section, the last distance command overrides the default administrative distance for RIP routes and sets it to 255:
Router(config)#router rip
Router(config-route)#distance 255
This is the worst possible administrative distance value. Any route with an administrative distance of 255 is considered infinitely far away and will never be used. You could also configure a lower administrative distance value for this protocol. For example, if we gave it a value of 105, the RIP routes would be better than OSPF but worse than IGRP by default.
The first distance command line overrides the new default value for routes received from one particular router, 192.168.15.1. These routes will have a distance value of 15.
Router(config-route)#distance 15 192.168.15.1 0.0.0.0
The last field in this line is an address wildcard pattern. In the binary representation of this number, the zeros represent values in the address that are important and ones represent values that can be ignored. In this case, the wildcard is 0.0.0.0, which means that every bit is important. So this refers to a single specific device, which is a router whose RIP routes we want to treat differently.
The other distance command line in the RIP example changes the administrative distance value to 200 for routes learned from devices in the 192.168.15.0 subnet:
Router(config-route)#distance 200 192.168.15.0 0.0.0.255
Because last field is 0.0.0.255, this command includes every device in the 192.168.15.0/24 subnet.
The router processes these commands sequentially and stops as soon as it gets a match. So, although the device 192.168.15.1 is also a member of the 192.168.15.0 subnet, its routes receive an administrative distance of 15. However, if the two commands were set in the opposite order, the more specific one would never be invoked.
This example represents another interesting use for administrative distances. You can use them (as we have in this RIP example) to ensure that you favor routes learned from particular routers over other less reliable devices. Note that this is only possible with distance vector protocols, so it will not work, for example, with OSPF. Refer to Chapter 6 for more information about RIP.
The EIGRP and OSPF configurations are similar, except that they include different options. The EIGRP example uses the distance eigrp command:
Router(config)#router eigrp 111 Router(config-route)#distance eigrp 55 200
This sets the administrative distance for routes learned by EIGRP to 55 if they are from the same EIGRP network, or 200 if they are external routes that have been redistributed into EIGRP.
OSPF also allows you to set a different administrative distance for external routes. And, for internal routes, you can specify different administrative distances depending on whether the route destination is internal or external to the area. This might be useful in certain cases where you want to connect to another area through an external network rather than through the OSPF core. However, in most cases you do not need to treat intra-area and inter-area OSPF routes differently.
When setting distances for use with BGP, the syntax is distance bgp <external> <internal> <local>.
Router(config-route)#distance bgp 115 220 50
The external and internal distances are used for routes learned through the eBGP and iBGP protocols, respectively. Local routes in this context are routes to destinations inside of this Autonomous System (AS). For more information on BGP, please refer to Chapter 9. Adjusting BGP administrative distances is relatively rare and frequently dangerous. The default values of 20 for eBGP and 200 for iBGP means that the router will generally prefer external BGP routes, but will prefer any internal routing protocol to iBGP. This is almost always the required behavior. If you want to change the way the router handles BGP routes, we don't recommend using administrative distance. We discuss several other options for manipulating BGP routes in Chapter 9.
Recipe 5.4; Chapter 6; Chapter 7; Chapter 8; Chapter 9
Top |