数通 | 多区域OSPF动态路由协议的配置

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

配置多区域OSPF动态路由协议

配置步骤(含完整指令)

首先,配置主机PC1、PC2的IP信息很简单(留意网关就好),比如PC1就这样:


配置主机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 ] 

参考资料

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,558评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,002评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,036评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,024评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,144评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,255评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,295评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,068评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,478评论 1 305
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,789评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,965评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,649评论 4 336
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,267评论 3 318
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,982评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,223评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,800评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,847评论 2 351

推荐阅读更多精彩内容