本文說明在開放最短路徑優先(OSPF)進程之間重新分配時存在次優路由問題,並提供解決方案。
本文件沒有特定需求。
本文件所述內容不限於特定軟體和硬體版本。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路正在作用,請確保您已瞭解任何指令可能造成的影響。
如需文件慣例的詳細資訊,請參閱思科技術提示慣例。
當網路中多個點中的不同OSPF進程之間重分配時,可能會出現次路由甚至路由環路的情況。
在下面的拓撲中,我們有OSPF 1和OSPF 2兩個進程。路由器1(R1)和路由器2(R2)從OSPF 1重分發到OSPF 2。
R1 |
---|
hostname r1 ! ip subnet-zero ! interface Loopback0 ip address 10.255.255.1 255.255.255.255 ! interface Loopback1 ip address 192.168.255.1 255.255.255.255 ! interface Ethernet0/0 ip address 10.0.0.1 255.255.255.0 ! interface Ethernet1/0 ip address 192.168.0.1 255.255.255.0 ! router ospf 1 router-id 10.255.255.1 log-adjacency-changes passive-interface Loopback0 network 10.0.0.0 0.0.0.255 area 0 network 10.255.255.1 0.0.0.0 area 0 ! router ospf 2 router-id 192.168.255.1 log-adjacency-changes redistribute ospf 1 subnets match internal !--- Redistributing OSPF 1 into OSPF 2. passive-interface Loopback1 network 192.168.0.0 0.0.0.255 area 0 network 192.168.255.1 0.0.0.0 area 0 ! ip classless ! end |
R2 |
---|
hostname r2 ! ip subnet-zero ! interface Loopback0 ip address 10.255.255.2 255.255.255.255 ! interface Loopback1 ip address 192.168.255.2 255.255.255.255 ! interface Ethernet0/0 ip address 10.0.0.2 255.255.255.0 ! interface Ethernet1/0 ip address 192.168.0.2 255.255.255.0 ! router ospf 1 router-id 10.255.255.2 log-adjacency-changes passive-interface Loopback0 network 10.0.0.0 0.0.0.255 area 0 network 10.255.255.2 0.0.0.0 area 0 ! router ospf 2 router-id 192.168.255.2 log-adjacency-changes redistribute ospf 1 subnets match internal !--- Redistributing OSPF 1 into OSPF 2. passive-interface Loopback1 network 192.168.0.0 0.0.0.255 area 0 network 192.168.255.2 0.0.0.0 area 0 ! ip classless end |
在上面的拓撲中,R4的E1/0在區域1中,E0/0在區域0中。因此,R4是區域邊界路由器(ABR),將網路10.0.1.0/24通告為到R1和R2的區域間(IA)路由。R1和R2將此資訊重新分發到OSPF 2。redistribute配置命令在以上的R1和R2配置中突出顯示。因此,R1和R2將以10.0.1.0/24的身份獲知IA通過OSPF 1並作為外部型別2(E2)通過OSPF 2,因為外部鏈路狀態通告(LSA)在整個OSPF 2域中傳播。
由於IA路由始終優先於E1或E2路由,因此期望在R1和R2的路由表中看到,10.0.1.0/24是下一跳R4的IA路由。但是,在檢視其路由表時,會看到不同的情況:在R1上,10.0.1.0/24是下一跳R4的IA路由,但在R2上,10.0.1.0/24是下一跳R1的E2路由。
以下是R1的show ip route命令的輸出。
r1#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 !--- The gateway of the last resort is not set. 10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks O E2 10.255.255.2/32 [110/1] via 192.168.0.2, 00:24:21, Ethernet1/0 C 10.0.0.0/24 is directly connected, Ethernet0/0 O IA 10.0.1.0/24 [110/20] via 10.0.0.4, 00:23:49, Ethernet0/0 C 10.255.255.1/32 is directly connected, Loopback0 O IA 10.255.255.4/32 [110/11] via 10.0.0.4, 00:23:49, Ethernet0/0 192.168.255.0/32 is subnetted, 3 subnets O 192.168.255.3 [110/11] via 192.168.0.3, 00:26:09, Ethernet1/0 O 192.168.255.2 [110/11] via 192.168.0.2, 00:26:09, Ethernet1/0 C 192.168.255.1 is directly connected, Loopback1 C 192.168.0.0/24 is directly connected, Ethernet1/0 O 192.168.1.0/24 [110/20] via 192.168.0.3, 00:26:09, Ethernet1/0
這是R2的show ip route命令的命令輸出。
r2#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 !--- The gateway of last resort is not set. 10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks C 10.255.255.2/32 is directly connected, Loopback0 C 10.0.0.0/24 is directly connected, Ethernet0/0 O E2 10.0.1.0/24 [110/20] via 192.168.0.1, 00:25:34, Ethernet1/0 O E2 10.255.255.1/32 [110/1] via 192.168.0.1, 00:25:34, Ethernet1/0 O E2 10.255.255.4/32 [110/11] via 192.168.0.1, 00:25:34, Ethernet1/0 192.168.255.0/32 is subnetted, 3 subnets O 192.168.255.3 [110/11] via 192.168.0.3, 00:26:45, Ethernet1/0 C 192.168.255.2 is directly connected, Loopback1 O 192.168.255.1 [110/11] via 192.168.0.1, 00:26:45, Ethernet1/0 C 192.168.0.0/24 is directly connected, Ethernet1/0 O 192.168.1.0/24 [110/20] via 192.168.0.3, 00:26:45, Ethernet1/0
在路由器上啟用多個OSPF進程時,從軟體角度看,這些進程是獨立的。在一個OSPF進程內,OSPF協定始終優先使用內部路由而不是外部路由。但是,OSPF在進程之間不執行任何OSPF路由選擇(例如,在決定應將哪個進程的路由安裝到路由表中時,不考慮OSPF指標和路由型別)。
不同OSPF進程之間沒有互動,而中斷時間是管理距離。因此,由於兩個OSPF進程的預設管理距離均為110,因此嘗試安裝該路由的第一個進程會將其加入路由表中。因此,必須配置來自不同OSPF進程的路由的管理距離,這樣某些OSPF進程的路由會因人的意圖而優先於其它進程的路由,而不是偶然性。
有關管理距離的詳細資訊,請參閱什麼是管理距離。有關Cisco路由器如何選擇要放入路由表中的路由的詳細資訊,請參閱Cisco路由器中的路由選擇。
由於我們知道在上述情況下,路由器根據管理距離選擇最佳路由,因此防止此行為的邏輯方法是增加OSPF 2中外部路由的管理距離。這樣,通過OSPF 1獲知的路由將始終優先於從OSPF 1重分發到OSPF 2的外部路由。這是使用子路由器配置命令distance ospf external <value>完成的,如以下配置所示。
R1 |
---|
hostname r1 ! ip subnet-zero ! interface Loopback0 ip address 10.255.255.1 255.255.255.255 ! interface Loopback1 ip address 192.168.255.1 255.255.255.255 ! interface Ethernet0/0 ip address 10.0.0.1 255.255.255.0 ! interface Ethernet1/0 ip address 192.168.0.1 255.255.255.0 ! router ospf 1 router-id 10.255.255.1 log-adjacency-changes passive-interface Loopback0 network 10.0.0.0 0.0.0.255 area 0 network 10.255.255.1 0.0.0.0 area 0 ! router ospf 2 router-id 192.168.255.1 log-adjacency-changes redistribute ospf 1 subnets match internal passive-interface Loopback1 network 192.168.0.0 0.0.0.255 area 0 network 192.168.255.1 0.0.0.0 area 0 distance ospf external 115 !--- Increases the administrative distance of external !--- routes to 115. ! ip classless ! end |
R2 |
---|
hostname r2 ! ip subnet-zero ! interface Loopback0 ip address 10.255.255.2 255.255.255.255 ! interface Loopback1 ip address 192.168.255.2 255.255.255.255 ! interface Ethernet0/0 ip address 10.0.0.2 255.255.255.0 ! interface Ethernet1/0 ip address 192.168.0.2 255.255.255.0 ! router ospf 1 router-id 10.255.255.2 log-adjacency-changes passive-interface Loopback0 network 10.0.0.0 0.0.0.255 area 0 network 10.255.255.2 0.0.0.0 area 0 ! router ospf 2 router-id 192.168.255.2 log-adjacency-changes redistribute ospf 1 subnets match internal passive-interface Loopback1 network 192.168.0.0 0.0.0.255 area 0 network 192.168.255.2 0.0.0.0 area 0 distance ospf external 115 !--- Increases the administrative distance of !--- external routes to 115. ! ip classless ! end |
更改OSPF 2中外部路由的管理距離時,生成的路由表如下所示。
以下是R1的show ip route命令的輸出。
r1#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 !--- The gateway of the last resort is not set. 10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks O 10.255.255.2/32 [110/11] via 10.0.0.2, 00:00:35, Ethernet0/0 C 10.0.0.0/24 is directly connected, Ethernet0/0 O IA 10.0.1.0/24 [110/20] via 10.0.0.4, 00:00:35, Ethernet0/0 C 10.255.255.1/32 is directly connected, Loopback0 O 10.255.255.4/32 [110/11] via 10.0.0.4, 00:00:35, Ethernet0/0 192.168.255.0/32 is subnetted, 3 subnets O 192.168.255.3 [110/11] via 192.168.0.3, 00:00:35, Ethernet1/0 O 192.168.255.2 [110/11] via 192.168.0.2, 00:00:35, Ethernet1/0 C 192.168.255.1 is directly connected, Loopback1 C 192.168.0.0/24 is directly connected, Ethernet1/0 O 192.168.1.0/24 [110/20] via 192.168.0.3, 00:00:35, Ethernet1/0
這是R2的show ip route命令的命令輸出。
r2#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 !--- The gateway of the last resort is not set. 10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks C 10.255.255.2/32 is directly connected, Loopback0 C 10.0.0.0/24 is directly connected, Ethernet0/0 O 10.255.255.1/32 [110/11] via 10.0.0.1, 00:01:28, Ethernet0/0 O IA 10.0.1.0/24 [110/20] via 10.0.0.4, 00:01:28, Ethernet0/0 O 10.255.255.4/32 [110/11] via 10.0.0.4, 00:01:28, Ethernet0/0 192.168.255.0/32 is subnetted, 3 subnets O 192.168.255.3 [110/11] via 192.168.0.3, 00:01:28, Ethernet1/0 C 192.168.255.2 is directly connected, Loopback1 O 192.168.255.1 [110/11] via 192.168.0.1, 00:01:28, Ethernet1/0 C 192.168.0.0/24 is directly connected, Ethernet1/0 O 192.168.1.0/24 [110/20] via 192.168.0.3, 00:01:28, Ethernet1/0
必須注意的是,在某些情況下,當存在從OSPF 2重分發到OSPF 1的路由協定,並且存在其他重分發到OSPF 2的路由協定(路由資訊協定[RIP]、增強型內部網關路由協定(EIGRP)靜態資訊等)時,這會導致這些外部路由在OSPF 2中進行快速路由。
如果實施兩個不同的OSPF進程的最終原因是過濾某些路由,則Cisco IOS®軟體版本12.2(4)T中有一個稱為OSPF ABR第3類LSA過濾的新功能,可用於在ABR中執行路由過濾。
在上面的示例中,作為OSPF 2一部分的鏈路可以配置為OSPF 1中的另一個區域,而不是配置第二個OSPF進程。然後,您可以使用此新功能在R1和R2中實施所需的路由過濾。有關此功能的詳細資訊,請參閱OSPF ABR第3類LSA過濾。
修訂 | 發佈日期 | 意見 |
---|---|---|
1.0 |
01-Jan-2008 |
初始版本 |