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 c