OSPF协议简介
开放式最短路径优先OSPF(Open Shortest Path First)是IETF组织开发的一个基于链路状态的内部网关协议(Interior Gateway Protocol)。OSPF分为OSPFv2和OSPFv3两个版本,其中OSPFv2用在IPv4网络,OSPFv3用在IPv6网络。
主要要了解OSPF的三张表:
邻居表(Peer table)
OSPF是一种可靠的路由协议,要求在路由器之间传递链路状态通告之前,需先建立OSPF邻居关系,hello报文用于发现直连链路上的其他OSPF路由器,再经过一系列的OSPF消息交互最终建立起全毗邻的邻居关系,OSPF路由器的邻居信息显示在邻居表中。链路状态数据库(Link-state database,简称LSDB)
OSPF用LSA(link state Advertisement,链路状态通告)来描述网络拓扑信息,然后OSPF路由器用LSDB来存储网络的这些LSA。OSPF将自己产生的以及邻居通告的LSA搜集并存储在LSDB中。掌握LSDB的查看以及对LSA的深入分析才能够深入理解OSPF。OSPF路由表(Routing table)
基于LSDB进行SPF(Dijkstra算法)计算,而得出的OSPF路由表。
拓扑图(含IP规划)
配置任务
按照拓扑图要求配置IP地址,配置多区域OSPF动态路由协议,最终实现PC1和PC2的互相通信。配置工具
华为网络设备仿真平台eNSP
配置步骤(含完整指令)
首先,配置主机PC1、PC2的IP信息很简单(留意网关就好),比如PC1就这样:
然后,需要配置的是R1、R2、R3、R4的各个端口所分配的IP地址,以R1为例,需要配置的有Eth0/0/0(10.1.1.2/30)、Eth0/0/1(10.1.4.1/30)、G0/0/0(10.1.3.1/30)这三个端口。
<Huawei>sys # R1
Enter system view, return user view with Ctrl+Z.
[Huawei]int eth0/0/0
[Huawei-Ethernet0/0/0]ip address 10.1.1.2 30
[Huawei-Ethernet0/0/0]
Jul 25 2019 20:13:20-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface Ethernet0/0/0 has entered the UP state.
Jul 25 2019 20:13:24-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/0]int eth0/0/1
[Huawei-Ethernet0/0/1]ip address 10.1.4.1 30
[Huawei-Ethernet0/0/1]
Jul 25 2019 20:13:47-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface Ethernet0/0/1 has entered the UP state.
Jul 25 2019 20:13:54-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 2, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/1]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.1.3.1 30
[Huawei-GigabitEthernet0/0/0]
Jul 25 2019 20:14:12-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
Jul 25 2019 20:14:14-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 3, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]
<Huawei>sys # R1
Enter system view, return user view with Ctrl+Z.
[Huawei]int eth0/0/0
[Huawei-Ethernet0/0/0]ip address 10.1.2.2 30
[Huawei-Ethernet0/0/0]
Jul 25 2019 20:16:05-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface Ethernet0/0/0 has entered the UP state.
Jul 25 2019 20:16:13-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/0]int eth0/0/1
[Huawei-Ethernet0/0/1]ip address 10.1.5.1 30
[Huawei-Ethernet0/0/1]
Jul 25 2019 20:16:39-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface Ethernet0/0/1 has entered the UP state.
Jul 25 2019 20:16:43-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 2, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/1]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.1.3.2 30
[Huawei-GigabitEthernet0/0/0]
Jul 25 2019 20:16:59-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
Jul 25 2019 20:17:03-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 3, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]
<Huawei>sys #R3
Enter system view, return user view with Ctrl+Z.
[Huawei]int eth0/0/0
[Huawei-Ethernet0/0/0]ip address 10.1.1.1 30
[Huawei-Ethernet0/0/0]
Jul 25 2019 20:18:56-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface Ethernet0/0/0 has entered the UP state.
Jul 25 2019 20:19:03-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/0]int eth0/0/1
[Huawei-Ethernet0/0/1]ip address 10.1.2.1 30
[Huawei-Ethernet0/0/1]
Jul 25 2019 20:19:22-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface Ethernet0/0/1 has entered the UP state.
Jul 25 2019 20:19:23-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 2, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/1]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.2 24
[Huawei-GigabitEthernet0/0/0]
Jul 25 2019 20:19:40-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
Jul 25 2019 20:19:43-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 3, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]
<Huawei>sys #R4
Enter system view, return user view with Ctrl+Z.
[Huawei]int eth0/0/0
[Huawei-Ethernet0/0/0]ip address 10.1.5.2 30
[Huawei-Ethernet0/0/0]
Jul 25 2019 20:21:02-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface Ethernet0/0/0 has entered the UP state.
Jul 25 2019 20:21:03-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/0]int eth0/0/1
[Huawei-Ethernet0/0/1]ip address 10.1.4.2 30
[Huawei-Ethernet0/0/1]
Jul 25 2019 20:21:25-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface Ethernet0/0/1 has entered the UP state.
Jul 25 2019 20:21:33-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 2, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/1]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.2.2 24
[Huawei-GigabitEthernet0/0/0]
Jul 25 2019 20:21:50-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
Jul 25 2019 20:21:53-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 3, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]
接下来,需要开始配置OSPF协议了,大致步骤如下:
- 创建OSPF进程,并指定OSPF进程号及Router-ID
ospf [ process-id | router-id router-id ]
- 进入特定area的配置视图
area area-id
- 在特定area的配置视图内,在特定接口激活OSPF
network ip-address wildcard-mask(通配符掩码)
下面就按照上面这个配置步骤一步一步来:
# R3
[Huawei]ospf 1 router-id 1.1.1.1
Jul 25 2019 20:25:13-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:25:33-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.1]network 10.1.1.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:28:34-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 6, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.1]network 10.1.2.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:28:54-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 7, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:29:24-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 8, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.1]q
[Huawei-ospf-1]
# R1
[Huawei]ospf 1 router-id 2.2.2.2
[Huawei-ospf-1]
Jul 25 2019 20:35:25-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]
Jul 25 2019 20:35:55-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.0]network 10.1.3.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.0]
Jul 25 2019 20:36:15-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 6, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:36:35-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 7, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.1]network 10.1.1.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:36:55-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 8, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:36:57-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[0]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.1.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
Jul 25 2019 20:36:57-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.1.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
Jul 25 2019 20:36:57-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.1.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
Jul 25 2019 20:36:57-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.1.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
Jul 25 2019 20:36:58-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.1.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
Jul 25 2019 20:36:58-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.1.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[Huawei-ospf-1-area-0.0.0.1]q
[Huawei-ospf-1]area 2
[Huawei-ospf-1-area-0.0.0.2]
Jul 25 2019 20:37:25-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 9, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.2]network 10.1.4.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.2]
Jul 25 2019 20:37:45-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 10, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.2]
# R2
[Huawei]ospf 1 router-id 3.3.3.3
[Huawei-ospf-1]
Jul 25 2019 20:42:44-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]
Jul 25 2019 20:43:04-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.0]network 10.1.3.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.0]
Jul 25 2019 20:43:24-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[0]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.3.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
Jul 25 2019 20:43:24-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.3.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
Jul 25 2019 20:43:24-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.3.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
Jul 25 2019 20:43:24-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 6, the change loop count is 0, and the maximum number of records is 4095.
Jul 25 2019 20:43:24-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.3.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exch
ange)
Jul 25 2019 20:43:24-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.3.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loadin
g)
Jul 25 2019 20:43:24-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.3.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:43:34-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 7, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.1]network 10.1.2.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.1]
Jul 25 2019 20:43:51-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.2.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
Jul 25 2019 20:43:51-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.2.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
Jul 25 2019 20:43:51-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[8]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.2.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
Jul 25 2019 20:43:51-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[9]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.2.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exch
ange)
Jul 25 2019 20:43:51-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[10]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.2.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
Jul 25 2019 20:43:51-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[11]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.2.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
Jul 25 2019 20:43:54-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 8, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.1]q
[Huawei-ospf-1]area 2
[Huawei-ospf-1-area-0.0.0.2]
Jul 25 2019 20:44:04-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 9, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.2]network 10.1.5.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.2]
Jul 25 2019 20:44:24-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 10, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.2]
# R4
[Huawei]ospf 1 router-id 4.4.4.4
[Huawei-ospf-1]area
Jul 25 2019 20:48:14-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1]area 2
[Huawei-ospf-1-area-0.0.0.2]
Jul 25 2019 20:48:24-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.2]network 10.1.5.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.2]
Jul 25 2019 20:48:44-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 6, the change loop count is 0, and the maximum number of records is 4095.
Jul 25 2019 20:48:47-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[0]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.5.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
Jul 25 2019 20:48:47-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.5.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
Jul 25 2019 20:48:47-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.5.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
Jul 25 2019 20:48:47-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.5.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
Jul 25 2019 20:48:47-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.5.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
Jul 25 2019 20:48:47-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.5.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[Huawei-ospf-1-area-0.0.0.2]network 10.1.4.0 0.0.0.3
[Huawei-ospf-1-area-0.0.0.2]
Jul 25 2019 20:49:04-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 7, the change loop count is 0, and the maximum number of records is 4095.
Jul 25 2019 20:49:07-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.4.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
Jul 25 2019 20:49:07-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.4.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
Jul 25 2019 20:49:07-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[8]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.4.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
Jul 25 2019 20:49:07-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[9]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.4.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
Jul 25 2019 20:49:07-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[10]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.4.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
Jul 25 2019 20:49:07-08:00 Huawei %%01OSPF/4/NBR_CHANGE_E(l)[11]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.4.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[Huawei-ospf-1-area-0.0.0.2]network 192.168.2.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.2]
Jul 25 2019 20:49:34-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 8, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-ospf-1-area-0.0.0.2]
至此,上面这些步骤算是配置完成了多区域OSPF动态路由协议!
结果验证
- ping验证(PC1 上 ping PC2)
PC>ping 192.168.2.1
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
From 192.168.2.1: bytes=32 seq=1 ttl=125 time=125 ms
From 192.168.2.1: bytes=32 seq=2 ttl=125 time=172 ms
From 192.168.2.1: bytes=32 seq=3 ttl=125 time=172 ms
From 192.168.2.1: bytes=32 seq=4 ttl=125 time=140 ms
From 192.168.2.1: bytes=32 seq=5 ttl=125 time=110 ms
--- 192.168.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 110/143/172 ms
- tracert验证
PC>tracert 192.168.2.1
traceroute to 192.168.2.1, 8 hops max
(ICMP), press Ctrl+C to stop
1 192.168.1.2 31 ms 31 ms 32 ms
2 10.1.2.2 62 ms 63 ms 62 ms
3 10.1.5.2 78 ms 94 ms 94 ms
4 192.168.2.1 125 ms 109 ms 125 ms
- 查看路由表情况(以R2为例)
很明显,OSPF动态协议配置成功了,动态增加了两条协议类型为OSPF的路由表项!
[Huawei]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/30 OSPF 10 2 D 10.1.2.1 Ethernet0/0/0
10.1.2.0/30 Direct 0 0 D 10.1.2.2 Ethernet0/0/0
10.1.2.2/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
10.1.3.0/30 Direct 0 0 D 10.1.3.2 GigabitEthernet
0/0/0
10.1.3.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.1.4.0/30 OSPF 10 2 D 10.1.5.2 Ethernet0/0/1
10.1.5.0/30 Direct 0 0 D 10.1.5.1 Ethernet0/0/1
10.1.5.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 OSPF 10 2 D 10.1.2.1 Ethernet0/0/0
192.168.2.0/24 OSPF 10 2 D 10.1.5.2 Ethernet0/0/1
这里的话,补充一下几条OSPF中常用的查看和验证指令:
- 查看OSPF协议相关运行参数——
display ospf brief
- 查看OSPF邻居表——
display ospf peer
- 查看LSDB表 ——
display ospf lsdb
- 查看OSPF路由——
display ospf routing
比如display ospf peer
,我们可以看看路由器R2:
[Huawei]display ospf peer
OSPF Process 1 with Router ID 3.3.3.3
Neighbors
Area 0.0.0.0 interface 10.1.3.2(GigabitEthernet0/0/0)'s neighbors
Router ID: 2.2.2.2 Address: 10.1.3.1
State: Full Mode:Nbr is Slave Priority: 1
DR: 10.1.3.2 BDR: 10.1.3.1 MTU: 0
Dead timer due in 32 sec
Retrans timer interval: 5
Neighbor is up for 01:31:04
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.1 interface 10.1.2.2(Ethernet0/0/0)'s neighbors
Router ID: 1.1.1.1 Address: 10.1.2.1
State: Full Mode:Nbr is Slave Priority: 1
DR: 10.1.2.1 BDR: 10.1.2.2 MTU: 0
Dead timer due in 40 sec
Retrans timer interval: 5
Neighbor is up for 01:31:09
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.2 interface 10.1.5.1(Ethernet0/0/1)'s neighbors
Router ID: 4.4.4.4 Address: 10.1.5.2
State: Full Mode:Nbr is Master Priority: 1
DR: 10.1.5.2 BDR: 10.1.5.1 MTU: 0
Dead timer due in 39 sec
Retrans timer interval: 5
Neighbor is up for 01:31:09
Authentication Sequence: [ 0 ]