网络基础(七)-----实操(OSPF综合练习)

Source

问题描述:

 一.分别配地址

具体请参考(网络基础五,里面有详细的IP地址划分),划分后的效果图

 第二.配置IP地址和环回接口

AR1

[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.1 29
Sep 13 2021 23:17:35-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
 IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[Huawei-GigabitEthernet0/0/0]int l0
[Huawei-LoopBack0]ip add 192.168.1.33 28

 AR2

[Huawei]int g 0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.2 29
Sep 13 2021 23:18:32-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
 IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[Huawei-GigabitEthernet0/0/0]int l0
[Huawei-LoopBack0]ip add 192.168.1.65 28

AR3

[Huawei]int g 0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.3 29
Sep 13 2021 23:19:35-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
 IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[Huawei]int g 0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.1.10 29
Sep 13 2021 23:24:34-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[13]:The line protoco
l IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[Huawei-GigabitEthernet0/0/0]int l0
[Huawei-LoopBack0]ip add 192.168.1.97 28

 AR4

[Huawei]int g 0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.9 29
[Huawei-GigabitEthernet0/0/0]
Sep 13 2021 23:20:30-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
 IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[Huawei-GigabitEthernet0/0/0]int l0 
[Huawei-LoopBack0]ip add 4.4.4.1 24

 第三步.配置OSPF

AR1

[Huawei]ospf 1 ro	
[Huawei]ospf 1 router-id 1.1.1.1
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]net	
[Huawei-ospf-1-area-0.0.0.1]network 192.168.1.1 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]net	
[Huawei-ospf-1-area-0.0.0.1]network 192.168.1.33 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]

 AR2

[Huawei]ospf 1 ro	
[Huawei]ospf 1 router-id 2.2.2.2
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]net	
[Huawei-ospf-1-area-0.0.0.1]network 192.168.1.2 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]net	
[Huawei-ospf-1-area-0.0.0.1]network 192.168.1.65 0.0.0.0

 AR3

[Huawei]ospf 1 ro	
[Huawei]ospf 1 router-id 3.3.3.3
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]net	
[Huawei-ospf-1-area-0.0.0.1]network 192.168.1.3 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]
[Huawei-ospf-1-area-0.0.0.1]net	
[Huawei-ospf-1-area-0.0.0.1]network 192.168.1.97 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]
/下面是区域2
[Huawei-ospf-1]area 2
[Huawei-ospf-1-area-0.0.0.2]net	
[Huawei-ospf-1-area-0.0.0.2]network 192.168.1.10 0.0.0.0

AR4

[Huawei]ospf 1 ro	
[Huawei]ospf 1 router-id 4.4.4.4
[Huawei-ospf-1]area 2
[Huawei-ospf-1-area-0.0.0.2]net	
[Huawei-ospf-1-area-0.0.0.2]network 192.168.1.9 0.0.0.0

配置完成几台路由器后都有OSPF的通信流程,效果如下

Sep 13 2021 23:22:35-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes
 event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.168.192, Ne
ighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init
) 
[Huawei-ospf-1-area-0.0.0.1]
Sep 13 2021 23:22:39-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes
 event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.168.192, Ne
ighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=ExSta
rt) 
[Huawei-ospf-1-area-0.0.0.1]
Sep 13 2021 23:22:39-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes
 event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.168.192, Ne
ighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState
=Exchange) 
[Huawei-ospf-1-area-0.0.0.1]
Sep 13 2021 23:22:39-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes
 event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.168.192, Ne
ighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=L
oading) 

 因为让AR3作为DR,而没有DBR,所以将除AR3之外的路由器都修改优先级,加一行代码如下:

[Huawei-GigabitEthernet0/0/0]ospf dr-priority 0

 三.配置缺省路由

因为AR4的环回没有宣告,但要求实现全网可达,所以给边界路由器AR4配置缺省路由

[Huawei-ospf-1]default-route-advertise

四.手工认证(安全性)

手工认证是相对应的,缺一不可,若只在一个接口配置,则另一方接受不到信息,出错

AR1

[Huawei-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456

AR3

[Huawei-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456

上面配置的是与AR3的0/0/0接口对应的,AR3 0/0/1接口同样方法配置即可