HCNA Routing&Switching之动态路由协议OSPF基础(一)_动态路由 OSPF(Open Shortest Path First)开放最短路径优先,它是现目前在大中型网络上使用最为广泛的IGP协议(内部网关协议),它是链路状态路由协议的一种;链路状态就是说这种协议之间传输的数据包不是直接的路由条目,而是描述路由器之间的链路相关信息,比如地址、掩码、开销、网络类型、邻居关系等;路由器收到此类数据包,会根据某种算法自动计算出到达目标网络的最优路由,并存放在路由表中;



  前文我们了解了基于路径矢量算法的动态路由协议RIP防环以及度量值的修改相关话题,回顾请参考​​javascript:void(0)​​;今天我们来了解下OSPF的相关话题;

  首先先来回顾下RIP,RIP是基于距离矢量的动态路由协议,它有两个最大的特点,也是它的缺点,第一是它收敛比较慢,主要体现在30秒发一次路由更新;其次是它不易扩展,不易扩展主要体现在,RIP是把路由的跳数作为度量值,并规定跳数为16条的路由,是不可达路由;这也意味着RIP不适用中大型网络;除了以上两个特点,还有它不了解整个网络拓扑,它只知道它的邻居告诉它的路由,这也是RIP不适用较大网络环境的原因之一吧!!

  如果我们要在一个大型的网络环境中使用动态路由协议,我们该跑什么动态路由协议呢?基于RIP的种种不适用大型网络环境的特点,以及生产环境的需要,新的动态路由协议OSPF产生了;OSPF(Open Shortest Path First)开放最短路径优先,它是现目前在大中型网络上使用最为广泛的IGP协议(内部网关协议),它是链路状态路由协议的一种;链路状态就是说这种协议之间传输的数据包不是直接的路由条目,而是描述路由器之间的链路相关信息,比如地址、掩码、开销、网络类型、邻居关系等;路由器收到此类数据包,会根据某种算法自动计算出到达目标网络的最优路由,并存放在路由表中;它和RIP不一样,运行RIP的两个路由器之间发送的是路由信息,路由器A发送什么路由,路由器B就只能收对应的路由;而ospf之间发送的是链路状态,它会根据收到的链路状态数据包结合spf算法,然后计算出到达目标网络的最优路径;ospf这就好比我们在生活中使用的地图,我们到达目标地点的路径有很多,根据不同时间段路况信息的不同,我们选择对应的路也会有所不同;而RIP就像我们生活中的路牌,我们永远不知道下一个路由还有几个路牌,我们只有到达了下一个路牌才知道对应去往目标该怎么走;其次ospf是无类,所谓无类就是描述目标网络时,它是结合掩码,而RIP只能宣告其目标网络的主类地址,从一定程度上来说,ospf比RIP严谨,准确;除此之外,OSPF还是用组播(224.0.0.5/6),收敛较快,以开销(cost)作为度量值,采用SPF算法有效避免环路,以低频的方式发送定期更新,区域的设计,不支持自动汇总,支持手动汇总等等特点;

  OSPF区域概述

  为了适应大型的网络环境,OSPF在AS内划分了多个区域,区域是以接口为单位进行划分,每个OSPF路由器只维护所在区域的完整链路状态信息;OSPF中的区域是用区域ID进行区分,相同区域ID的接口表示在同一个区域中,区域ID可以表示一个十进制的数字如:1;也可以表示成一个IP,如:1.1.1.1;区域设计的最大好处是,相同区域的链路状态,只在该区域内部泛红(1类和2类lLSA),这样做的目的可以尽量减少路由表的条目(减少了路由表路由的条目数量,在一定程度上也能提高路由器在路由表中查找路由的时间,提升了路由查找速度),使拓扑变化仅影响本区域内部;

  OSPF区域分类

  OSPF的区域主要分骨干区域和非骨干区域,所谓骨干区域是指区域id为0,也称该区域为核心区域,传输区域;非骨干区域就是指区域ID不是0 的区域,也称常规区域;在ospf中所有其他非骨干区域必须和骨干区域直接相连,这样做的目的主要是骨干区域负责在不同的非骨干区域之间分发路由信息;

  单区域示意图

HCNA Routing&Switching之动态路由协议OSPF基础(一)_OSPF基础_02

  提示:单区域是指该网络环境中就只有一个区域,对于这种单区域环境,区域ID就是不是0都可以,但是建议是0;

  多区域示意图

HCNA Routing&Switching之动态路由协议OSPF基础(一)_OSPF_03

  提示:多区域我们需要注意核心区域必须是area 0 ,其他非核心区域的区域ID可以任意非零数字,并且非核心区域必须要和核心区域直接相连;一般情况下不能存在区域0连接区域1,区域1连接区域2;特殊的环境中我们需要用特殊的方法去解决;

  OSPF的路由器类型

  IR:Internal Router,内部路由器,特点是所有的接口都属于同一区域;

  BR:Backbone Router,骨干路由器,特点是至少有一个接口属于骨干区域;

  ABR:Area Border Router,区域边界路由器,特点是连接一个或者多个区域到骨干区域,至少有一个接口属于骨干区域;

  ASBR:Autonomous System Border Router,自治系统边界路由器,特点是能从其他路由协议学习到的路由以注入的方式到OSPF进程中;

  以上分类是按照路由器接口处在不同的区域位置进行划分,对于路由器来说,一台路由器可以同时属于多种类型;如下图

HCNA Routing&Switching之动态路由协议OSPF基础(一)_OSPF基础_04

  提示:对于区域0中的路由器它既可以是BR,也可以是asbr,或者其他类型;

   OSPF核心工作流程

  1、发现并建立邻居

  2、传播 LSA(区别于距离矢量的路由表更新);LSA是Link State Advertisement,链路状态宣告;它不是路由信息,而是用来描述链路(路由器接口)的信息,比如地址、掩码、开销、网络类型、邻居关系等;

  3、将LSA泛洪到区域中的所有OSPF路由器,而不仅是直连的路由器;

  4、收集LSA创建LSDB(链路状态数据库);

  5、使用SPF算法计算到每个目标网络的最短距离,并将其置于路由表中;

  验证:如下图实验拓扑,所有路由器都跑OSPF;

HCNA Routing&Switching之动态路由协议OSPF基础(一)_OSPF_05

  根据上述实验拓扑配置相关路由器

  R1的配置



<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int lo1
[R1-LoopBack1]ip add 1.1.1.1 32
[R1-LoopBack1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
Jul 18 2021 00:05:30-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 13.0.0.1 24
Jul 18 2021 00:05:30-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]net 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]net 12.0.0.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]net 13.0.0.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]q
[R1-ospf-1]q
[R1]dis ip int b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 4
The number of interface that is DOWN in Protocol is 1

Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.0.0.1/24 up up
GigabitEthernet0/0/1 13.0.0.1/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack1 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
[R1]


  在R2的g0/0/0接口上抓包,看看对应能抓到什么包?

HCNA Routing&Switching之动态路由协议OSPF基础(一)_动态路由_06

  提示:可以看到我们把R1配置好ospf,并宣告对应的网络以后,在R2和R1直连的接口上可以抓到ospf的hello包;其实这个包的作用就是建立邻居用的;

  R2的配置



<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip ad
Jul 18 2021 00:11:22-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[R2-GigabitEthernet0/0/1]ip add 24.0.0.2 24
[R2-GigabitEthernet0/0/1]ospf 1 router-id 2.2.2.2
Jul 18 2021 00:11:22-08:00 R2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]net 12.0.0.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]net 24.0.0.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]q
[R2-ospf-1]q
[R2]
Jul 18 2021 00:11:31-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.12, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
[R2]
Jul 18 2021 00:11:31-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.12, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
[R2]
Jul 18 2021 00:11:31-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.12, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
[R2]
Jul 18 2021 00:11:31-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.12, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
[R2]
Jul 18 2021 00:11:31-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.12, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
[R2]
Jul 18 2021 00:11:31-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.12, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[R2]


  提示:可以看到我现在再配置R2时,对应多了很多日志信息;这些日志信息就是R1和R2相关接口建立起邻居的过程;

  在R1和R2直连的接口上抓包看看对应能抓到什么包?

HCNA Routing&Switching之动态路由协议OSPF基础(一)_OSPF区域_07

  提示:从上面的抓包信息可以看到,在R2配置好ospf,并在对应区域宣告了对应的网络以后,首先我们能够看到R2也发送了一条hello包,然后R2就发了ARP请求,R1回应了R2的arp请求的报文,这个报文主要是R2获取R1对应接口的mac,以便后续发送LSA做准备(这说明邻居已经建立好了);当R2收到R1相关接口的mac地址以后,接下来R2首先向R1发送了DB description的数据包,随后R1也发送了对应的DB description包,这个包主要用来向对方描述自己数据库中的相关说明和描述;随后R2发送了LSR,R1回复了LSU,这一个过程就是R2请求R1的LSA,R1通过恢复LSU将LSA发送给R2;随后R1向R2发送LSR,R2回复LSU,最后各自都收到对应的LSU并发送了LSACK,后续就没有再发送LSA,只是有规律的各自发送helllo包;

  验证:查看R1的路由表,看看R1是否学习到R2上相关接口的路由?

HCNA Routing&Switching之动态路由协议OSPF基础(一)_动态路由_08

  提示:可以看到R1学习到了R2上的到达24.0.0.0/24网络的路由;

  验证:查看R2上的路由表,看看是否学习到达R1相关接口的路由呢?

HCNA Routing&Switching之动态路由协议OSPF基础(一)_OSPF_09

  提示:可以看到R2上也学习到达1.1.1.1/32和13.0.0.0/24网络的路由;

  验证:查看R1上的ospf邻居表,看看R1和R2是否是邻居

HCNA Routing&Switching之动态路由协议OSPF基础(一)_OSPF区域_10

  提示:可以看到在R1上查看ospf邻居表,里面记录了R2的Router-id,说明R2和R1现在是邻居;并且两者的状态为full;

  通过上述的实验我们大致可以看到ospf首先会通过发送hello包,建立邻居,在邻居建立以后,然后路由器会发送自己的数据库描述信息,然后再发送LSR,对应路由器发送LSU,最后当两者都收到对方的LSU以后,都会在此向对方发送LSACK,表示已经收到对方的LSU而做出的确认包;确认包的主要作用就是告诉对方,收到对方的LSU,如果没有确认包,路由器会持续的发送LSU;最后在根据各自收到的LSA相关信息,通过spf算法生成路由,并存放在路由表中;

  R3的配置



[Huawei]sys R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 34.0.0.3 24
[R3-GigabitEthernet0/0/0]int g0/
Jul 18 2021 00:44:28-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 13.0.0.3 24
Jul 18 2021 00:44:28-08:00 R3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[R3-GigabitEthernet0/0/1]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]net 13.0.0.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]net 34.0.0.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:34-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.13, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
[R3-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:34-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.13, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
[R3-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:34-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.13, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
[R3-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:35-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.13, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
[R3-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:35-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.13, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
[R3-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:35-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.13, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[R3-ospf-1-area-0.0.0.0]


  R4的配置



<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R4
[R4]int lo4
[R4-LoopBack4]ip add 4.4.4.4 32
[R4-LoopBack4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 24.0.0.4 24
Jul 18 2021 00:44:46-08:00 R4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 34.0.0.4 24
[R4-GigabitEthernet0/0/1]ospf 1 router-id 4.4.4.4
Jul 18 2021 00:44:46-08:00 R4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[R4-ospf-1]
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]net 4.4.4.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]net 24.0.0.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]net 34.0.0.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:48-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.24, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:48-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.24, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:48-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.24, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:48-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.24, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:48-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.24, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:48-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.24, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:51-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[8]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.34, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:44:51-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[9]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.34, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:45:24-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[10]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.34, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:45:24-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[11]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.34, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:45:24-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[12]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.34, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
[R4-ospf-1-area-0.0.0.0]
Jul 18 2021 00:45:24-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[13]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.34, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[R4-ospf-1-area-0.0.0.0]


  验证:查看R1上的邻居表



<R1>dis ospf peer

OSPF Process 1 with Router ID 1.1.1.1
Neighbors

Area 0.0.0.0 interface 12.0.0.1(GigabitEthernet0/0/0)'s neighbors
Router ID: 2.2.2.2 Address: 12.0.0.2
State: Full Mode:Nbr is Master Priority: 1
DR: 12.0.0.1 BDR: 12.0.0.2 MTU: 0
Dead timer due in 33 sec
Retrans timer interval: 5
Neighbor is up for 00:39:19
Authentication Sequence: [ 0 ]

Neighbors

Area 0.0.0.0 interface 13.0.0.1(GigabitEthernet0/0/1)'s neighbors
Router ID: 3.3.3.3 Address: 13.0.0.3
State: Full Mode:Nbr is Master Priority: 1
DR: 13.0.0.1 BDR: 13.0.0.3 MTU: 0
Dead timer due in 35 sec
Retrans timer interval: 5
Neighbor is up for 00:06:15
Authentication Sequence: [ 0 ]

<R1>


  提示:可以看到现在R1有两个邻居,分别是2.2.2.2和3.3.3.3

  验证:查看R1的LSDB数据



<R1>dis ospf lsdb

OSPF Process 1 with Router ID 1.1.1.1
Link State Database

Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 4.4.4.4 4.4.4.4 388 60 80000007 0
Router 2.2.2.2 2.2.2.2 419 48 80000009 1
Router 1.1.1.1 1.1.1.1 436 60 8000000C 0
Router 3.3.3.3 3.3.3.3 391 48 80000007 1
Network 24.0.0.2 2.2.2.2 419 32 80000002 0
Network 34.0.0.4 4.4.4.4 388 32 80000002 0
Network 13.0.0.1 1.1.1.1 436 32 80000002 0
Network 12.0.0.1 1.1.1.1 623 32 80000003 0


<R1>dis ospf lsdb router

OSPF Process 1 with Router ID 1.1.1.1
Area: 0.0.0.0
Link State Database


Type : Router
Ls id : 4.4.4.4
Adv rtr : 4.4.4.4
Ls age : 398
Len : 60
Options : E
seq# : 80000007
chksum : 0x95e4
Link count: 3
* Link ID: 4.4.4.4
Data : 255.255.255.255
Link Type: StubNet
Metric : 0
Priority : Medium
* Link ID: 24.0.0.2
Data : 24.0.0.4
Link Type: TransNet
Metric : 1
* Link ID: 34.0.0.4
Data : 34.0.0.4
Link Type: TransNet
Metric : 1

Type : Router
Ls id : 2.2.2.2
Adv rtr : 2.2.2.2
Ls age : 429
Len : 48
Options : E
seq# : 80000009
chksum : 0xeaf0
Link count: 2
* Link ID: 12.0.0.1
Data : 12.0.0.2
Link Type: TransNet
Metric : 1
* Link ID: 24.0.0.2
Data : 24.0.0.2
Link Type: TransNet
Metric : 1

Type : Router
Ls id : 1.1.1.1
Adv rtr : 1.1.1.1
Ls age : 447
Len : 60
Options : E
seq# : 8000000c
chksum : 0x6382
Link count: 3
* Link ID: 1.1.1.1
Data : 255.255.255.255
Link Type: StubNet
Metric : 0
Priority : Medium
* Link ID: 12.0.0.1
Data : 12.0.0.1
Link Type: TransNet
Metric : 1
* Link ID: 13.0.0.1
Data : 13.0.0.1
Link Type: TransNet
Metric : 1

Type : Router
Ls id : 3.3.3.3
Adv rtr : 3.3.3.3
Ls age : 403
Len : 48
Options : E
seq# : 80000007
chksum : 0x902b
Link count: 2
* Link ID: 34.0.0.4
Data : 34.0.0.3
Link Type: TransNet
Metric : 1
* Link ID: 13.0.0.1
Data : 13.0.0.3
Link Type: TransNet
Metric : 1

<R1>


  提示:可以看到LSDB数据库中记录了每个路由器发送的LSA内容;

  验证:查看R1的路由表,看看现在是否学习到了去往相关网络的路由呢?

HCNA Routing&Switching之动态路由协议OSPF基础(一)_OSPF_11

  提示:可以看到在R1上有两条等价路由,都是可以去往4.4.4.4/32,并且也有去往34.0.0.0/24和34.0.0.0/24网络的路由;

  验证:在R1上用源地址为1.1.1.1去ping 4.4.4.4,看看是否能够正常通信呢?

HCNA Routing&Switching之动态路由协议OSPF基础(一)_动态路由_12

  提示:可以看到用源地址为1.1.1.1是能够正常ping通4.4.4.4,说明R1到R4的链路已经打通了;


作者:​​Linux-1874​

本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.