本文档描述了如何更改路由协议的管理距离值来影响思科路由器中的路由选择。
管理距离是在有使用两个不同路由协议的两个或多个不同的路由通往同一目标时,路由器用来选择最佳路径的功能。管理距离定义了路由协议的可靠性。管理距离值越小,协议越可靠。
注意:当更改默认距离时,可能导致网络中出现路由环路。在考虑好要实现的目标之后,谨慎地更改管理距离。
本文档没有任何特定的前提条件。
本文档中的配置是基于装有思科 IOS 软件 12.4(15)T 13 版本的思科 3700 系列路由器。
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
本部分提供有关如何配置本文档所述功能的信息。
注意:使用命令查找工具(仅限注册客户)可查找有关本文档中使用的命令的详细信息。
在这里,路由器 R1 和 R2 是通过并行串联线连接。路由器 R1 和 R2 是使用 BGP 和 OSPF 进行配置。OSPF的默认管理距离为110,而eBGP的默认管理距离为20。使用命令distance,我们将BGP的AD值更改为190。在此命令之前,路由器R2优先于OSPF的BGP路由,因为它们配置了默认AD值。更改 BGP 的 AD 值后,OSPF 路由获得优先权。
本文档使用以下配置
R1 的配置 |
---|
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 配置 |
---|
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 ! |
请使用本部分描述的命令来验证配置。
命令输出解释程序(仅限注册用户)(OIT) 支持某些 show 命令。使用 OIT 可查看对 show 命令输出的分析。
当 distance 命令未应用于路由器 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 |
当 distance 命令应用于路由器 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 |
版本 | 发布日期 | 备注 |
---|---|---|
1.0 |
26-Jul-2011 |
初始版本 |