企業網主流動態路由OSPF協議報文 ,及基本配置,一分鐘瞭解下

一、OSPF簡介

OSPF(Open Shortest Path First,開放最短路徑優先)是 IETF(Internet Engineering Task Force,

互聯網工程任務組)組織開發的一個基於鏈路狀態的內部網關協議。

二、OSPF的特點

OSPF 具有如下特點:

1、適應範圍廣:支持各種規模的網絡,最多可支持幾百臺路由器。

2、快速收斂:在網絡的拓撲結構發生變化後立即發送更新報文,使這一變化在自治系統中同步。

3、 無自環:由於 OSPF 根據收集到的鏈路狀態用最短路徑樹算法計算路由,從算法本身保證了

不會生成自環路由。

4、區域劃分:允許自治系統的網絡被劃分成區域來管理。路由器鏈路狀態數據庫的減小降低了

內存的消耗和 CPU 的負擔;區域間傳送路由信息的減少降低了網絡帶寬的佔用。

5、等價路由:支持到同一目的地址的多條等價路由。

6、路由分級:使用 4 類不同的路由,按優先順序來說分別是:區域內路由、區域間路由、第一

類外部路由、第二類外部路由。

7、支持驗證:支持基於區域和接口的報文驗證,以保證報文交互和路由計算的安全性。

8、 組播發送:在某些類型的鏈路上以組播地址發送協議報文,減少對其他設備的干擾。

三、OSPF報文類型

OSPF 協議報文直接封裝為 IP 報文,協議號為 89。

1、 Hello 報文:週期性發送,用來發現和維持 OSPF 鄰居關係,以及進行 DR(Designated

Router,指定路由器)/BDR(Backup Designated Router,備份指定路由器)的選舉。

2、DD(Database Description,數據庫描述)報文:描述了本地 LSDB(Link State DataBase,

鏈路狀態數據庫)中每一條 LSA(Link State Advertisement,鏈路狀態通告)的摘要信息,

用於兩臺路由器進行數據庫同步。

3、 LSR(Link State Request,鏈路狀態請求)報文:向對方請求所需的 LSA。兩臺路由器互相

交換 DD 報文之後,得知對端的路由器有哪些 LSA 是本地的 LSDB 所缺少的,這時需要發送

LSR 報文向對方請求所需的 LSA。

4、 LSU(Link State Update,鏈路狀態更新)報文:向對方發送其所需要的 LSA。

5、LSACK(Link State Acknowledgment,鏈路狀態確認)報文:用來對收到的 LSA 進行確認。

四、基本OSPF配置

1. 組網需求

A、 所有的交換機都運行 OSPF,並將整個自治系統劃分為 3 個區域。

B、 其中 Switch A 和 Switch B 作為 ABR 來轉發區域之間的路由。

C、 配置完成後,每臺交換機都應學到 AS 內的到所有網段的路由

2. 組網圖

企業網主流動態路由OSPF協議報文 ,及基本配置,一分鐘瞭解下

3. 配置步驟(IP地址忽略)

配置 OSPF 基本配置

1)、 配置 Switch A

<switcha> system-view/<switcha>

[SwitchA] router id 10.2.1.1

[SwitchA] ospf

[SwitchA-ospf-1] area 0

[SwitchA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255

[SwitchA-ospf-1-area-0.0.0.0] quit

[SwitchA-ospf-1] area 1

[SwitchA-ospf-1-area-0.0.0.1] network 10.2.1.0 0.0.0.255

[SwitchA-ospf-1-area-0.0.0.1] quit

[SwitchA-ospf-1] quit

2)、 配置 Switch B

<switchb> system-view/<switchb>

[SwitchB] router id 10.3.1.1

[SwitchB] ospf

[SwitchB-ospf-1] area 0

[SwitchB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.0] quit

[SwitchB-ospf-1] area 2

[SwitchB-ospf-1-area-0.0.0.2] network 10.3.1.0 0.0.0.255

[SwitchB-ospf-1-area-0.0.0.2] quit

[SwitchB-ospf-1] quit

3)、配置 Switch C

<switchc> system-view/<switchc>

[SwitchC] router id 10.4.1.1

[SwitchC] ospf

[SwitchC-ospf-1] area 1

[SwitchC-ospf-1-area-0.0.0.1] network 10.2.1.0 0.0.0.255

[SwitchC-ospf-1-area-0.0.0.1] network 10.4.1.0 0.0.0.255

[SwitchC-ospf-1-area-0.0.0.1] quit

[SwitchC-ospf-1] quit

4)、 配置 Switch D

<switchd> system-view/<switchd>

[SwitchD] router id 10.5.1.1

[SwitchD] ospf

[SwitchD-ospf-1] area 2

[SwitchD-ospf-1-area-0.0.0.2] network 10.3.1.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.2] network 10.5.1.0 0.0.0.255

[SwitchD-ospf-1-area-0.0.0.2] quit

[SwitchD-ospf-1] quit

4. 驗證配置

1)、 查看 Switch A 的 OSPF 鄰居

[SwitchA] display ospf peer verbose

OSPF Process 1 with Router ID 10.2.1.1

Neighbors

Area 0.0.0.0 interface 10.1.1.1(Vlan-interface100)'s neighbors

Router ID: 10.3.1.1 Address: 10.1.1.2 GR State: Normal

State: Full Mode: Nbr is Master Priority: 1

DR: 10.1.1.1 BDR: 10.1.1.2 MTU: 0

Options is 0x02 (-|-|-|-|-|-|E|-)

Dead timer due in 37 sec

Neighbor is up for 06:03:59

Authentication Sequence: [ 0 ]

Neighbor state change count: 5

Area 0.0.0.1 interface 10.2.1.1(Vlan-interface200)'s neighbors

Router ID: 10.4.1.1 Address: 10.2.1.2 GR State: Normal

State: Full Mode: Nbr is Master Priority: 1

DR: 10.2.1.1 BDR: 10.2.1.2 MTU: 0

Options is 0x02 (-|-|-|-|-|-|E|-)

Dead timer due in 32 sec

Neighbor is up for 06:03:12

Authentication Sequence: [ 0 ]

Neighbor state change count: 5

2)、查看 Switch A 的 OSPF 路由信息

[SwitchA] display ospf routing

OSPF Process 1 with Router ID 10.2.1.1

Routing Tables

Routing for Network

Destination Cost Type NextHop AdvRouter Area

10.2.1.0/24 1 Transit 10.2.1.1 10.2.1.1 0.0.0.1

10.3.1.0/24 2 Inter 10.1.1.2 10.3.1.1 0.0.0.0

10.4.1.0/24 2 Stub 10.2.1.2 10.4.1.1 0.0.0.1

10.5.1.0/24 3 Inter 10.1.1.2 10.3.1.1 0.0.0.0

10.1.1.0/24 1 Transit 10.1.1.1 10.2.1.1 0.0.0.0

Total Nets: 5

Intra Area: 3 Inter Area: 2 ASE: 0 NSSA: 0

3)、查看 Switch D 的 OSPF 路由信息

[SwitchD] display ospf routing

OSPF Process 1 with Router ID 10.5.1.1

Routing Tables

Routing for Network

Destination Cost Type NextHop AdvRouter Area

10.2.1.0/24 3 Inter 10.3.1.1 10.3.1.1 0.0.0.2

10.3.1.0/24 1 Transit 10.3.1.2 10.3.1.1 0.0.0.2

10.4.1.0/24 4 Inter 10.3.1.1 10.3.1.1 0.0.0.2

10.5.1.0/24 1 Stub 10.5.1.1 10.5.1.1 0.0.0.2

10.1.1.0/24 2 Inter 10.3.1.1 10.3.1.1 0.0.0.2

Total Nets: 5

Intra Area: 2 Inter Area: 3 ASE: 0 NSSA: 0

4)、 在 Switch D 上使用 Ping 進行測試連通性

[SwitchD] ping 10.4.1.1

Ping 10.4.1.1 (10.4.1.1): 56 data bytes, press CTRL_C to break

56 bytes from 10.4.1.1: icmp_seq=0 ttl=253 time=1.549 ms

56 bytes from 10.4.1.1: icmp_seq=1 ttl=253 time=1.539 ms

56 bytes from 10.4.1.1: icmp_seq=2 ttl=253 time=0.779 ms

56 bytes from 10.4.1.1: icmp_seq=3 ttl=253 time=1.702 ms

56 bytes from 10.4.1.1: icmp_seq=4 ttl=253 time=1.471 ms


分享到:


相關文章: