H3CSE路由篇
第二章:OSPF的基本配置和優化
一,ospf的基本配置:
1, 啟動ospf程序,并制定程序ID,預設為1
[R2]ospf 1 router-id 1.1.1.1(同時指定router-id)
2, 配置區域ID
[R2-ospf-1]area 0
3, 在指定網段的接口下使能ospf
[R2-ospf-1-area-0.0.0.0]net 12.0.0.0 0.0.0.255
二,ospf單區域的配置

R2:ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 12.0.0.0 0.0.0.255
FR-SWITCHING: ospf 1 router-id 2.2.2.2
network 12.0.0.0 0.0.0.255
配置完成檢視鄰居狀态:
[FR-SWITCHING-ospf-1]display ospf peer
OSPF Process 1 with Router ID 2.2.2.2
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time Interface State
1.1.1.1 12.0.0.1 1 40 GE0/1/0 Full/DR
三,ospf多區域的配置
在單區域的基礎上配置RTB:area 0.0.0.1
network 23.0.0.0 0.0.0.255
RTC:ospf 1 router-id 3.3.3.3
area 0.0.0.1
network 23.0.0.0 0.0.0.255
檢視結果:[FR-SWITCHING]display ospf peer
1.1.1.1 12.0.0.1 1 36 GE0/1/0 Full/DR
Area: 0.0.0.1
3.3.3.3 23.0.0.3 1 37 GE0/1/1 Full/DR
産看ospf路由表項:
[RTC-ospf-1]display ospf routing
OSPF Process 1 with Router ID 3.3.3.3
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
23.0.0.0/24 1 Transit 23.0.0.3 3.3.3.3 0.0.0.1
12.0.0.0/24 2 Inter 23.0.0.2 2.2.2.2 0.0.0.1
Total Nets: 2
Intra Area: 1 Inter Area: 1 ASE: 0 NSSA: 0
其中transit表示轉發網絡,inter表示區域間路由,stub表示末梢網絡
四,ospf的網絡類型:1,boardcast;2,NBMA;3,P2P;4,P2MP(cisco中存在第五種網絡類型:點到多點非廣播)
NBMA網絡中的ospf配置:(此處隻研究P2MP與NBMA環境下的ospf)
1, 模拟幀中繼交換機:
[FR-Switching]fr switching
[FR-Switching -serial0/2/0] interface Serial0/2/0
[FR-Switching serial0/2/0] link-protocol fr
[FR-Switching -serial0/2/0] fr interface-type dce
[FR-Switching -serial0/2/0] fr dlci 102
[FR-Switching -serial0/2/0] fr dlci 103
[FR-SWITCHING-serial0/2/0] fr dlci-switch 102 interface Serial0/2/1 dlci 201
[FR-SWITCHING-serial0/2/0] fr dlci-switch 103 interface Serial0/2/2 dlci 301
[FR-SWITCHING-serial0/2/1]link-protocol fr
[FR-SWITCHING-serial0/2/1] fr interface-type dce
[FR-SWITCHING-serial0/2/1] fr dlci-switch 201 interface Serial0/2/0 dlci 102
[FR-SWITCHING-serial0/2/1] fr dlci-switch 203 interface Serial0/2/2 dlci 302
[FR-SWITCHING-serial0/2/1] fr dlci 201
[FR-SWITCHING-serial0/2/1] fr dlci 203
[FR-SWITCHING-serial0/2/2] link-protocol fr
[FR-SWITCHING-serial0/2/2] fr interface-type dce
[FR-SWITCHING-serial0/2/2] fr dlci-switch 301 interface Serial0/2/0 dlci 103
[FR-SWITCHING-serial0/2/2] fr dlci-switch 302 interface Serial0/2/1 dlci 203
[FR-SWITCHING-serial0/2/2] fr dlci 301
[FR-SWITCHING-serial0/2/2] fr dlci 302
注:inverse arp可以自動解析每條虛鍊路連接配接的對端裝置IP位址,若不關閉則會影響靜态映射的實驗效果
2, 在非幀中繼交換機上配置(RTC、RTD同理)
[R2-serial0/2/0] interface Serial0/2/0
[R2-serial0/2/0]link-protocol fr
[R2 -Serial0/2/0]undo fr inarp(關閉逆向位址解析協定)
[R2-serial0/2/0]ip address 10.1.1.1 255.255.255.0
3,配置ospf協定(FR-SWITCHING、RTC同理)
[R2] ospf 1 router-id 1.1.1.1
[R2-ospf-1] peer 10.1.1.2(隻可以指定鄰居接口位址,因為它存在dlci映射關系)
[R2-ospf-1] peer 10.1.1.3
[R2-ospf-1]area 0.0.0.0
[R2 -ospf-1-area-0.0.0.0] network 1.1.1.1 0.0.0.0
[R2 -ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
檢視鄰居狀态
[R2]display ospf peer
OSPF Process 1 with Router ID 1.1.1.1
2.2.2.2 10.1.1.2 1 95 S0/2/0 Full/BDR
3.3.3.3 10.1.1.3 1 105 S0/2/0 Full/DR
檢視接口網絡類型:
[R2]display ospf interface Serial 0/2/0
OSPF Process 1 with Router ID 1.1.1.1
Interfaces
Interface: 10.1.1.1 (Serial0/2/0)
Cost: 1562 State: DROther Type: NBMA MTU: 1500
Priority: 1
Designated Router: 10.1.1.3
Backup Designated Router: 10.1.1.2
Timers: Hello 30, Dead 120, Poll 120, Retransmit 5, Transmit Delay 1
由以上結果可以看出,FR網絡的預設網絡類型為NBMA
在NBMA網絡中無法傳遞廣播、多點傳播封包,運作ospf時需發送單點傳播建立鄰居關系;
修改網絡類型:
[R2-serial0/2/0] ospf timer hello 10
[R2-serial0/2/0] ospf timer dead 40
[R2-serial0/2/0] ospf network-type broadcast
修改網絡類型為boardcast後,ospf便可以通過多點傳播建立鄰居關系,而不需要手動指定鄰居。
五,環境下的ospf
P2MP并不是預設的網絡類型,需通過強制更改NBMA網絡類型為P2MP;P2MP網絡上ospf可以通過多點傳播封包進行鄰居發現、建立于維護,需手動映射本地dlci與對端接口IP位址的映射通過廣播方式發送hello封包
配置執行個體:(RTC、RTD同理)
[FR-SWITCHING-Serial0/2/0]undo fr inarp(關閉逆向位址解析協定)
[R2-serial0/2/0]fr map ip 10.1.1.2 102 boardcast
[R2-serial0/2/0]fr map ip 10.1.1.3 103 boardcast(配置靜态映射,”boardcast”表示允許通過廣播或者多點傳播發送封包)
[R2-serial0/2/0]ospf network-type P2MP
[R2-serial0/2/0]ospf timer hello 30
[R2-serial0/2/0]ospf timer dead 120(P2MP預設與NBMA相同)
[R2] ospf 1 router-id 1.1.1.1