本文說明如何更改路由協定的管理距離值,以影響Cisco路由器中的路由選擇。
管理距離是當存在從兩種不同的路由協定到達同一目標的兩個或多個不同路由時,路由器用來選擇最佳路徑的功能。管理距離定義了路由協定的可靠性。管理距離值越小,協定越可靠。
注意:更改預設距離時,可能導致網路中的路由環路。請謹慎更改管理距離,並且僅在考慮過要達到的目標之後。
本文件沒有特定先決條件。
本檔案中的組態是根據Cisco IOS軟體版本12.4(15)T 13上的Cisco 3700系列路由器。
如需文件慣例的詳細資訊,請參閱思科技術提示慣例。
本節提供用於設定本文件中所述功能的資訊。
註:使用Command Lookup Tool(僅限註冊客戶)查詢有關本文檔中使用的命令的更多資訊。
路由器R1和R2通過並行串列線路連線。路由器R1和R2配置了BGP和OSPF。OSPF的預設管理距離為110,而eBGP的預設管理距離為20。使用命令distance時,我們將BGP的AD值更改為190。在此命令之前,路由器R2優先使用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命令輸出的分析。
在路由器R2上未應用distance命令時
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 |
在路由器R2上應用distance命令時
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 |
初始版本 |