簡介
本文件說明如何針對多區域相鄰,設定開放式最短路徑優先 (OSPF) 連結狀態路由通訊協定。
必要條件
需求
思科建議您瞭解以下主題:
思科還建議您在嘗試本文檔中所述的配置之前滿足以下要求:
- 必須在網路中預配置OSPF鏈路狀態路由協定。
- 只有兩個OSPF揚聲器使用OSPF多區域功能之間的介面。多區域OSPF僅在點對點網路型別上工作。
採用元件
本文檔中的資訊基於多區域OSPF。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
背景資訊
OSPF鏈路狀態路由協定使用Areas的概念,它是OSPF域內的子域。區域內的路由器維護該區域的完整拓撲資訊。預設情況下,一個介面只能屬於一個OSPF區域。這不僅會導致網路中路由不理想,而且如果網路設計不當,還會導致其他問題。
當在介面上配置多區域鄰接時,OSPF揚聲器會通過該鏈路形成多個鄰接關係(ADJ)。多區域介面是一個邏輯的點對點介面,ADJ通過此介面形成。本文檔描述了多區域OSPF ADJ可用於解決問題並滿足網路要求的場景。
設定
網路圖表
在此網路圖中,使用了網路/OSPF域。系統要求從Router 5(R5)到R1(10.1.1.1)的流量始終通過R3。假定R3是網路中的一個防火牆,所有流量都可以通過它進行路由,或者假定R3和R4之間的鏈路比R2和R4之間的鏈路具有更多的頻寬。無論哪種情況,系統都要求流量從R5傳遞到R1時必須通過R3(10.1.1.1/32字首)。
路由器初始配置
本節介紹R1到R5的初始配置。
配置R1
interface Ethernet0/0
ip address 192.168.12.1 255.255.255.0
!
interface Loopback0
ip address 10.1.1.1 255.255.255.255
!
ip route 0.0.0.0 0.0.0.0 192.168.12.2
配置R2
interface Ethernet0/0
ip address 192.168.12.2 255.255.255.0
!
interface Ethernet0/1
ip address 192.168.23.2 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 0
!
interface Ethernet0/2
ip address 192.168.24.2 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
!
interface Loopback0
ip address 10.2.2.2 255.255.255.255
!
ip route 10.1.1.1 255.255.255.255 192.168.12.1
!
router ospf 1
router-id 0.0.0.2
redistribute static metric-type 1 subnets
配置R3
interface Ethernet0/0
ip address 192.168.34.3 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
!
interface Ethernet0/1
ip address 192.168.23.3 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 0
!
interface Loopback0
ip address 10.3.3.3 255.255.255.255
!
router ospf 1
router-id 0.0.0.3
配置R4
interface Ethernet0/0
ip address 192.168.34.4 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
!
interface Ethernet0/1
ip address 192.168.45.4 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
!
interface Ethernet0/2
ip address 192.168.24.4 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
!
interface Loopback0
ip address 10.4.4.4 255.255.255.255
!
router ospf 1
router-id 0.0.0.4
配置R5
interface Ethernet0/1
ip address 192.168.45.5 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
!
interface Loopback0
ip address 10.5.5.5 255.255.255.255
!
router ospf 1
router-id 0.0.0.5
預設行為
在先前配置就緒的情況下,本節介紹預設路由器行為。
以下是從R5到10.1.1.1的跟蹤路徑。請注意,流量通過R2,而不是R3:
R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 6 msec 6 msec 6 msec <<< R4
2 192.168.24.2 6 msec 6 msec 8 msec <<< R2
3 192.168.12.1 8 msec * 3 msec <<< R1
在此網路中,路由器R4必須根據系統要求做出決定,而且能夠將流量路由到R3,而不是直接路由到R2。
以下是R4上的路由表示例:
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 30, type extern 1
Last update from 192.168.24.2 on Ethernet0/2, 00:14:33 ago
Routing Descriptor Blocks:
* 192.168.24.2, from 0.0.0.2, 00:14:33 ago, via Ethernet0/2 <<< Towards R2
Route metric is 30, traffic share count is 1
字首10.1.1.1/32的度量與此路由關聯30。這是因為自治系統邊界路由器(ASBR)(R2)使用的預設度量為20,而R4上介面Eth0/2的開銷為10。
從R4到10.1.1.1/32字首通過R3的路徑更長。此處,R4上介面Ethernet 0/2的開銷(通往R2的路徑)被更改,以驗證它是否更改了行為:
interface Ethernet0/2
ip address 192.168.24.4 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
ip ospf cost 100
end
以下是R5的追蹤軌跡和R4的show ip route 命令輸出:
R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 4 msec 9 msec 8 msec <<< R4
2 192.168.24.2 8 msec 9 msec 10 msec <<< R2
3 192.168.12.1 10 msec * 5 msec <<< R1
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 120, type extern 1
Last update from 192.168.24.2 on Ethernet0/2, 00:01:50 ago
Routing Descriptor Blocks:
* 192.168.24.2, from 0.0.0.2, 00:01:50 ago, via Ethernet0/2
Route metric is 120, traffic share count is 1
如追蹤軌跡所示,來自R5的流量採用相同的路徑,並且流量不通過R3。此外,如show ip route 10.1.1.1命令在R4上的輸出所示,在R4上新增的成本100(介面乙太網路0/2)會生效,而且到達首碼的路由的開銷為120(而不是30)。但是,路徑仍然沒有更改,並且流量流經R3的要求尚未滿足。
要確定此行為的原因,以下是R4 show ip ospf border-routers命令輸出(R4介面Ethernet 0/2上的開銷仍設定為100):
R4#show ip ospf border-routers
OSPF Router with ID (0.0.0.4) (Process ID 1)
Base Topology (MTID 0)
Internal Router Routing Table
Codes: i - Intra-area route, I - Inter-area route
i 0.0.0.2 [100] via 192.168.24.2, Ethernet0/2, ABR/ASBR, Area 99, SPF 3
i 0.0.0.3 [10] via 192.168.34.3, Ethernet0/0, ABR, Area 99, SPF 3
在R4上,您可以看到有兩個區域邊界路由器(ABR)(0.0.0.2,即R2;0.0.3,即R3),並且R2是ASBR。此輸出還顯示ASBR的區域內(i)資訊。
現在,R4上的介面Ethernet 0/2關閉,以確定流量是否通過R3,並檢視show ip ospf border-routers命令輸出如何顯示:
interface Ethernet0/2
ip address 192.168.24.4 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
ip ospf cost 100
shutdown
end
以下是R5的trace和R4的show ip route命令輸出:
R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 7 msec 7 msec 8 msec <<< R4
2 192.168.34.3 9 msec 8 msec 8 msec <<< R3
3 192.168.23.2 9 msec 9 msec 7 msec <<< R2
4 192.168.12.1 8 msec * 4 msec <<< R1
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 40, type extern 1 <<< Metric 40
Last update from 192.168.34.3 on Ethernet0/0, 00:01:46 ago <<< Traffic to R2
Routing Descriptor Blocks:
* 192.168.34.3, from 0.0.0.2, 00:01:46 ago, via Ethernet0/0
Route metric is 40, traffic share count is 1
如圖所示,當R4上的Interface Ethernet 0/2關閉時,流量會通過R3。此外,與通往R3的路由相關的開銷僅為40,而通過R2通往10.1.1.1/32的開銷為120。OSPF協定仍然更喜歡通過R2而不是R3路由流量,即使通過R3到達10.1.1.1/32的成本更低。
以下是show ip ospf border-routers在R4上的輸出:
R4#show ip ospf border-routers
OSPF Router with ID (0.0.0.4) (Process ID 1)
Base Topology (MTID 0)
Internal Router Routing Table
Codes: i - Intra-area route, I - Inter-area route
I 0.0.0.2 [20] via 192.168.34.3, Ethernet0/0, ASBR, Area 99, SPF 4
i 0.0.0.3 [10] via 192.168.34.3, Ethernet0/0, ABR, Area 99, SPF 4
到達ASBR所需的資訊是區域間信息。但是,詳細說明如何到達ASBR的區域內資訊優先於區域間資訊,而不管與兩條路徑關聯的OSPF開銷如何。
因此,通過R3的路徑不是首選路徑,即使通過R3的開銷較低。
在這裡,R4上恢復了Interface Ethernet 0/2:
interface Ethernet0/2
no shutdown
end
來自R5的跟蹤指示路由操作返回到之前觀察到的那些操作(流量不通過R3流動):
R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 6 msec 7 msec 7 msec <<< R4
2 192.168.24.2 7 msec 8 msec 7 msec <<< R2
3 192.168.12.1 8 msec * 12 msec <<< R1
有多種方法可以解決此問題(此清單並非詳盡無遺):
- 將R2和R3之間的區域更改為99,然後修改成本。
- 在R2和R3之間新增另一條鏈路,並將其配置為區域99。
- 使用多區域ADJ
請參閱下一節,瞭解多區域OSPF ADJ的運作方式及其如何解決當前的問題。
多區域鄰接配置
如前所述,多區域ADJ可用於在單個鏈路上形成多個點對點邏輯鄰接。要求鏈路上必須只有兩個OSPF揚聲器,而在廣播網路中,您必須手動將OSPF網路型別更改為鏈路上的點到點。
此功能允許多個區域共用單個物理鏈路,並在共用該鏈路的每個區域中建立區域內路徑。
為了滿足此要求,您必須通過鏈路Ethernet 0/1在R2和R3之間配置OSPF多區域ADJ,該鏈路當前僅位於區域0中。
R2的配置如下:
interface Ethernet0/1
ip address 192.168.23.2 255.255.255.0
ip ospf network point-to-point
ip ospf multi-area 99
ip ospf 1 area 0
end
R3的配置如下:
interface Ethernet0/1
ip address 192.168.23.3 255.255.255.0
ip ospf network point-to-point
ip ospf multi-area 99
ip ospf 1 area 0
end
OSPF ADJ通過虛擬鏈路啟動:
%OSPF-5-ADJCHG: Process 1, Nbr 0.0.0.2 on OSPF_MA0 from LOADING to FULL, Loading Done
%OSPF-5-ADJCHG: Process 1, Nbr 0.0.0.3 on OSPF_MA0 from LOADING to FULL, Loading Done
以下是新成立的ADJ:
R2#show ip ospf neighbor 0.0.0.3
<Snip>
Neighbor 0.0.0.3, interface address 192.168.23.3
In the area 99 via interface OSPF_MA0
Neighbor priority is 0, State is FULL, 6 state changes
DR is 0.0.0.0 BDR is 0.0.0.0
Options is 0x12 in Hello (E-bit, L-bit)
Options is 0x52 in DBD (E-bit, L-bit, O-bit)
LLS Options is 0x1 (LR)
Dead timer due in 00:00:39
Neighbor is up for 00:03:01
Index 2/3, retransmission queue length 0, number of retransmission 0
First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
Last retransmission scan length is 0, maximum is 0
Last retransmission scan time is 0 msec, maximum is 0 msec
R3#show ip ospf neighbor 0.0.0.2
<Snip>
Neighbor 0.0.0.2, interface address 192.168.23.2
In the area 99 via interface OSPF_MA0
Neighbor priority is 0, State is FULL, 6 state changes
DR is 0.0.0.0 BDR is 0.0.0.0
Options is 0x12 in Hello (E-bit, L-bit)
Options is 0x52 in DBD (E-bit, L-bit, O-bit)
LLS Options is 0x1 (LR)
Dead timer due in 00:00:39
Neighbor is up for 00:01:41
Index 2/3, retransmission queue length 0, number of retransmission 0
First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0
Last retransmission scan length is 0, maximum is 0
Last retransmission scan time is 0 msec, maximum is 0 msec
驗證
要驗證您的配置是否正常工作,請在R4上輸入show ip ospf border-routers命令:
R4#show ip ospf border-routers
OSPF Router with ID (0.0.0.4) (Process ID 1)
Base Topology (MTID 0)
Internal Router Routing Table
Codes: i - Intra-area route, I - Inter-area route
i 0.0.0.3 [10] via 192.168.34.3, Ethernet0/0, ABR, Area 99, SPF 10
i 0.0.0.2 [20] via 192.168.34.3, Ethernet0/0, ABR/ASBR, Area 99, SPF 10
如圖所示,用於將流量路由到R2(0.0.0.2)/ASBR的區域內資訊通過R3。這可解決前面提到的問題。
以下是R5的追蹤軌跡:
R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 8 msec 9 msec 8 msec <<< R4
2 192.168.34.3 8 msec 8 msec 8 msec <<< R3
3 192.168.23.2 7 msec 8 msec 8 msec <<< R2
4 192.168.12.1 8 msec * 4 msec <<< R1
如圖所示,從R5發往10.1.1.1的流量會正確通過R3,並且滿足系統要求。
在R2、R3和R4上輸入show ip ospf neighbor命令以驗證是否已建立ADJ:
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
0.0.0.3 0 FULL/ - 00:00:39 192.168.23.3 Ethernet0/1
0.0.0.4 0 FULL/ - 00:00:37 192.168.24.4 Ethernet0/2
0.0.0.3 0 FULL/ - 00:00:33 192.168.23.3 OSPF_MA0
R3#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
0.0.0.2 0 FULL/ - 00:00:34 192.168.23.2 Ethernet0/1
0.0.0.2 0 FULL/ - 00:00:35 192.168.23.2 OSPF_MA0
0.0.0.4 0 FULL/ - 00:00:39 192.168.34.4 Ethernet0/0
R4#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
0.0.0.2 0 FULL/ - 00:00:32 192.168.24.2 Ethernet0/2
0.0.0.5 0 FULL/ - 00:00:32 192.168.45.5 Ethernet0/1
0.0.0.3 0 FULL/ - 00:00:35 192.168.34.3 Ethernet0/0
註:在這些輸出中,Ethernet0/1 Interface條目表示區域0上的ADJ,OSPF_MA0 Interface條目表示區域99上的多區域ADJ。
R4介面Ethernet 0/2的開銷仍為100,在R4上首選通過R3的路徑。如果移除此開銷,則R4會像以前一樣將流量直接路由到R2。
以下是R4上的配置和show ip route命令輸出,其中R4介面Ethernet 0/2上仍配置的IP OSPF開銷為100:
interface Ethernet0/2
ip address 192.168.24.4 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
ip ospf cost 100
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 40, type extern 1
Last update from 192.168.34.3 on Ethernet0/0, 00:28:45 ago
Routing Descriptor Blocks:
* 192.168.34.3, from 0.0.0.2, 00:28:45 ago, via Ethernet0/0
Route metric is 40, traffic share count is 1
以下是移除成本時R4上的組態和show ip route指令輸出:
interface Ethernet0/2
ip address 192.168.24.4 255.255.255.0
ip ospf network point-to-point
ip ospf 1 area 99
end
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 30, type extern 1
Last update from 192.168.24.2 on Ethernet0/2, 00:00:13 ago
Routing Descriptor Blocks:
* 192.168.24.2, from 0.0.0.2, 00:00:13 ago, via Ethernet0/2 <<< Route changed back to R2
Route metric is 30, traffic share count is 1
疑難排解
目前尚無特定資訊可用於排解此組態的疑難問題。