Changing Administrative Distances

Problem

You want to change the administrative distance for an external network.

Solution

You 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#

And 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#

 

Discussion

When dealing with administrative distances, always bear in mind that they only affect route selection on this particular router. Administrative distances are not distributed by the routing protocols. However, they can affect the routing protocols. Distance vector algorithms in particular only distribute the routes that are used locally. Adjusting the administrative distance could change which routes are used. So you should always be extremely careful when adjusting administrative distances.

In fact, 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 will probably also interfere with dropping the dialup connection because it is actively passing traffic. Changing the administrative distance can be an effective way of resolving this kind of conflict.

However, we want to stress that this is a relatively unusual case.

The default values for administrative distances are mentioned in Table 5-3 and discussed in Recipe 5.4. You can adjust these values to force the router to prefer routes learned by one protocol over those learned from another. In Recipe 5.4, we gave high administrative distances to static routes so that the router would not use them unless the dynamic routing protocol was unavailable. And this recipe shows that it is also possible to modify the administrative distances for the routing protocols themselves to allow one protocol to dominate another.

In the RIP example, shown in the Solution section above, 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. If we gave it a value of 105, for example, then by default RIP routes would be better than OSPF, but worse than IGRP.

The second 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 0s represent values in the address that are important and 1s 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 third distance command line in the RIP 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

The last field, 0.0.0.255, includes every device in the subnet.

Note 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. Please 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 in which 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 :

Router(config-route)#distance bgp 115 220 50

The external and internal distances are used for routes learned through eBGP and iBGP protocols, respectively. Local routes in this context are routes to destinations inside of this Autonomous System. For more information on BGP, please refer to Chapter 9. Adjusting BGP administrative distances is relatively rare and frequently dangerous. The default value of 20 for eBGP and 200 for iBGP means that the router generally will prefer external BGP routes, but 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 options for manipulating BGP routes in Chapter 9.

See Also

Recipe 5.4; Chapters 6, 7, 8, and 9

Router Configuration and File Management

Router Management

User Access and Privilege Levels

TACACS+

IP Routing

RIP

EIGRP

OSPF

BGP

Frame Relay

Handling Queuing and Congestion

Tunnels and VPNs

Dial Backup

NTP and Time

DLSw

Router Interfaces and Media

Simple Network Management Protocol

Logging

Access-Lists

DHCP

NAT

First Hop Redundancy Protocols

IP Multicast

IP Mobility

IPv6

MPLS

Security

Appendix 1. External Software Packages

Appendix 2. IP Precedence, TOS, and DSCP Classifications

Index



Cisco IOS Cookbook
Cisco IOS Cookbook (Cookbooks (OReilly))
ISBN: 0596527225
EAN: 2147483647
Year: 2004
Pages: 505

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net