Administrative distance is the feature that routers use in order to select the best path when there are two or more different routes to the same destination from two different routing protocols. Administrative distance defines the reliability of a routing protocol. The smaller the administrative distance value, the more reliable the protocol.
Note: When you change the default distances, it can lead to routing loops in the network. Change the administrative distance with caution and only after you have thought through what you want to achieve.
Network Diagram
Here the router R1 and R2 are connected via parallel serial lines. The routers R1 and R2 are configured with BGP and OSPF. The default administrative distance of OSPF is 110 while that of the eBGP is 20. With the command distance, we changed the AD value of BGP to 190. Prior to this command, the router R2 preferred the BGP routes over OSPF since they had the default AD values configured. After the AD value of the BGP changed, the OSPF routes takes the precedence.
Configurations
This document uses these configuration
R1 Configuration |
---|
interface Loopback0 ip address 1.1.1.1 255.255.255.255 ! ! interface Loopback10 ip address 10.10.10.10 255.255.255.255 ! ! interface Loopback20 ip address 20.20.20.20 255.255.255.255 ! ! interface Loopback30 ip address 30.30.30.30 255.255.255.255 ! ! interface Serial1/0 ip address 100.100.100.1 255.255.255.0 serial restart-delay 0 clock rate 64000 ! ! interface Serial1/1 ip address 192.168.12.1 255.255.255.0 serial restart-delay 0 clock rate 64000 ! ! router ospf 10 router-id 1.1.1.1 log-adjacency-changes network 1.1.1.1 0.0.0.0 area 0 network 10.10.10.10 0.0.0.0 area 0 network 20.20.20.20 0.0.0.0 area 0 network 100.100.100.1 0.0.0.0 area 0 ! router bgp 123 no synchronization bgp router-id 1.1.1.1 bgp log-neighbor-changes network 10.10.10.10 mask 255.255.255.255 network 20.20.20.20 mask 255.255.255.255 network 30.30.30.30 mask 255.255.255.255 neighbor 2.2.2.2 remote-as 100 neighbor 2.2.2.2 ebgp-multihop 5 neighbor 2.2.2.2 update-source Loopback0 no auto-summary ! |
R2 Configuration |
---|
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
!
interface Serial1/0
ip address 100.100.100.2 255.255.255.0
serial restart-delay 0
clock rate 64000
!
!
interface Serial1/1
ip address 192.168.12.2 255.255.255.0
serial restart-delay 0
clock rate 64000
!
!
router ospf 10
router-id 2.2.2.2
log-adjacency-changes
network 2.2.2.2 0.0.0.0 area 0
network 100.100.100.2 0.0.0.0 area 0
!
router bgp 100
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 123
neighbor 1.1.1.1 ebgp-multihop 5
neighbor 1.1.1.1 update-source Loopback0
distance 190 1.1.1.1 0.0.0.0
Changed the AD value of BGP as 190!
no auto-summary
!
|
On Router R2
When the distance command is not applied on Router R2
Show ip route |
---|
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 I - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route, + - replicated route Gateway of last resort is not set 1.0.0.0/32 is subnetted, 1 subnets O 1.1.1.1 [110/65] via 100.100.100.1, 00:00:03, Serial1/0 2.0.0.0/32 is subnetted, 1 subnets C 2.2.2.2 is directly connected, Loopback0 10.0.0.0/32 is subnetted, 1 subnets B 10.10.10.10 [20/0] via 1.1.1.1, 00:00:03 BGP Router Preffered Over OSPF 20.0.0.0/32 is subnetted, 1 subnets B 20.20.20.20 [20/0] via 1.1.1.1, 00:00:03 BGP Router Preffered Over OSPF 30.0.0.0/32 is subnetted, 1 subnets B 30.30.30.30 [20/0] via 1.1.1.1, 00:00:03 100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 100.100.100.0/24 is directly connected, Serial1/0 L 100.100.100.2/32 is directly connected, Serial1/0 192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.12.0/24 is directly connected, Serial1/1 L 192.168.12.2/32 is directly connected, Serial1/1 |
When the distance command is applied on Router R2
Show ip route |
---|
R2#sh ip route Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 I - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route, + - replicated route Gateway of last resort is not set 1.0.0.0/32 is subnetted, 1 subnets O 1.1.1.1 [110/65] via 100.100.100.1, 00:00:03, Serial1/0 2.0.0.0/32 is subnetted, 1 subnets C 2.2.2.2 is directly connected, Loopback0 10.0.0.0/32 is subnetted, 1 subnets O 10.10.10.10 [110/65] via 100.100.100.1, 00:00:03, Serial1/0 By increasing the AD of External BGP, OSPF takes precedence 20.0.0.0/32 is subnetted, 1 subnets O 20.20.20.20 [110/65] via 100.100.100.1, 00:00:03, Serial1/0 By increasing the AD of External BGP, OSPF takes precedence 30.0.0.0/32 is subnetted, 1 subnets B 30.30.30.30 [190/0] via 1.1.1.1, 00:00:03 100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 100.100.100.0/24 is directly connected, Serial1/0 L 100.100.100.2/32 is directly connected, Serial1/0 192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.12.0/24 is directly connected, Serial1/1 L 192.168.12.2/32 is directly connected, Serial1/1 |
http://www.cisco.com/c/en/us/support/docs/ip/ip-routed-protocols/113153-adjust-ad-00.html