HCNA Routing&Switching之动态路由协议OSPF DR和BDR

  前文我们了解了OSPF建立邻居关系的条件,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/15032907.html;今天我们来聊一聊OSPF中的DR和BDR;

  在说DR和BDR之前我们先来了解下OSPF的网络类型;

  首先OSPF的网络类型是基于接口来划分,其次OSPF的网络类型是通过接口的二层封装报文的方式进行了划分,默认情况下OSPF把接口二层是以太网封装的网络称为广播类型,把接口二层是PPP或者HDLC封装的网络称为点到点类型;

  在生活中,广播就是一个人说话,在同一个房间里的其他人都可以听到;在网络里,广播和这个类似;一个网络设备在一个广播域发送一条广播报文,在同一个广播域的所有设备都能收到该设备的广播;这样一来我们要想和其中的一台设备通讯怎么通讯呢?在二层为以太网封装的广播类型网络里,它是通过二层以太网封装目标MAC和源MAC;其原因是ip地址是变化的,如果单纯的使用ip地址不能够准确的标识某一台设备(因为ip地址是变化的),而MAC地址是设备的硬件地址,这个地址是设备出厂时就固定了,况且不会发生变化;所以确定一台设备的唯一性,我们可以通过MAC地址;有了通信双方的mac地址再结合三层的ip地址,我们就可以准确的将对应数据包发送给对方;

  对于点到点类型的网络,其二层就不需要封装MAC地址,一条链路上就只有两个端点,在A端点发送数据B端点就一定能收到;

  提示:广播类型的接口是以太网类型接口(就是我们常常看到的网口),而点到点类型的接口是串口;

  在点对点类型的网络中,基于接口封装的不同又可以分非广播多路访问和点到多点,如下图

  提示:默认情况下,OSPF认为帧中继(FR)、异步传输(ATM)的网络类型为NBMA;在帧中继网络里非广播多路访问和以太网中的广播类型,两者有一个相同的特点,就是都可以接多个设备;不同点是以太网二层封装需要封装mac地址,支持广播发送,而帧中继网络二层不需要封装mac地址,其原因是它不支持广播;不支持广播就意味着在ospf里不支持组播;不支持组播也就是说帧中继网络里,ospf只能通过单播的方式建立邻居;

  实验:如下图两个拓扑,R1和R2为以太网类型接口,R3和R4为串口接口,在两个实验环境中配置ospf,抓包看看两者发送到hello包有什么不同

  配置R1

sys
sys R1
int g0/0/0
ip add 12.0.0.1 24
ospf 1 router-id 1.1.1.1
area 0
net 12.0.0.1 0.0.0.0
dis ip int b
View Code

  配置R2

sys
sys R2
int g0/0/0
ip add 12.0.0.2 24
ospf 1 router-id 2.2.2.2
area 0
net 12.0.0.2 0.0.0.0
dis ip int b
View Code

  配置R3

sys
sys R3
int s4/0/0
ip add 34.0.0.3 24
ospf 1 router-id 3.3.3.3
area 0
net 34.0.0.3 0.0.0.0
dis ip int b
View Code

  配置R4

sys
sys R4
int s4/0/0
ip add 34.0.0.4 24
ospf 1 router-id 4.4.4.4
area 0
net 34.0.0.4 0.0.0.0
dis ip int b
View Code

  在R1或R2上抓包

  在R3或R4上抓包

  提示:默认情况串口链路的二层封装为ppp类型,这里抓包就选择ppp链路类型即可;

  提示:从上面的抓包情况可以看到,在以太网封类型的网络环境下抓包,其二层封装了目标mac和源mac,而在点到点类型的网络环境下抓包,其二层就不是使用以太网协议而是用ppp协议,并且数据包里面也没有封装mac地址;

  验证:查看对应ospf网络类型

  在R1或R2上验证相关接口的网络类型

  在R3或R4上验证相关接口的网络类型

  更改R3的s4/0/0的链路封装为FR,看看对应的接口类型是什么

  提示:可以看到修改了R3的s4/0/0接口的封装为FR以后,对应ospf就down掉了;并且对应接口的类型就变为了NBMA(非广播多路访问);

  OSPF DR和BDR

  DR和BDR的作用

  在上述的网络类型中,在多路访问网络类型中跑OSPF,每个路由器都会和其他路由器建立邻居,一个路由器发送一条链路更新,其他路由器都会跟着确认,这样一来,每个路由器都要经过两两的交互和确认,在一定程度上会带来路由器的性能的开销(hello包,DD,LSR,LSU,LSACK这些包过多,增加路由器的处理压力,从而导致路由器的性能降低);为了降低数据包的交换,在OSPF中会选举DR和BDR;如下图

  提示:广播型网络BMA和NBMA网络中,为了减少邻接关系的数量,从而减少数据包交换,次数,最终节省带宽,降低对路由器处理能力的压力,选举DR和BDR。

  相关术语概述

  DR:Designed Router,指定路由器,类似班长、总经理;

  BDR:Backup DR,备用DR,类似副班长、副总经理;

  DRouthers:类似普通学生、普通员工;

  三者的关系:DR、BDR、DRothers之间都保持邻接关系(Full),DRothers之间保持邻居关系(Two-Way);

  通信地址:224.0.0.6向DR和BDR发送链路状态更新,224.0.0.5向所有OSPF路由器发送;

  DR选举规则

  1、首先比较Hello报文中携带的优先级,优先级范围是0-255,默认情况下都是1;优先级最高的被选举为DR,优先级次高的被选举为BDR;优先级为0的不参与选举;

  2、如果优先级相同的情况下,比较Router id,router id 越大越优先;

  3、选举不具有抢占性,除非当DR和BDR都失效或重启OSPF进程;

  提示:DRothers的LSU向DR或BDR通过224.0.0.6发送,然后DR收到DRothers发送到LSU以后,会将对应的LSU通过224.0.0.5向其他路由器发送,其他路由器收到DR发送LSU以后,BDR向224.0.0.5直接确认,而DBothers则通过224.0.0.6向DR确认;总结一句话就是从DR或BDR发出的数据包都是发往224.0.0.5,DR和BDR都会监听224.0.0.6这个地址;DRothers发出的数据会通过224.0.0.6向DR或BDR发送;

  实验:如下图,全网运行ospf,看看对应的数据包会这么发送,对应路由器之间是什么关系

  配置R1

sys
sys R1
int g0/0/0
ip add 1.0.0.1 24
ospf 1 router-id 1.1.1.1
a 0
net 1.0.0.0 0.0.0.255
dis ip int b
dis ospf peer brief
View Code

  在R1上查看g0/0/0的接口信息,看看谁是DR和BDR

  提示:可以看到只配置了R1上的OSPF以后,对应DR就是它自己,因为此时没有其他设备和它竞选DR,所以只有它是DR;对于BDR来说,它不知道,因为目前就只有它自己在ospf里面,没有看到其他设备;

  配置R2

sys
sys R2
int g0/0/0
ip add 1.0.0.2 24
ospf 1 router-id 2.2.2.2
a 0
net 1.0.0.0 0.0.0.255
dis ip int b
dis ospf peer brief
View Code
<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 1.0.0.2 24
[R2-GigabitEthernet0/0/0]ospf 1 rout
Jul 24 2021 12:08:39-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/0]ospf 1 router-id 2.2.2.2
[R2-ospf-1]a 0
[R2-ospf-1-area-0.0.0.0]net 1.0.0.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]dis ip int b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              1.0.0.2/24           up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)     
[R2-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) 
[R2-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) 
[R2-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) 
[R2-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) 
[R2-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) 
[R2-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) 
[R2-ospf-1-area-0.0.0.0]dis ospf peer brief

         OSPF Process 1 with Router ID 2.2.2.2
                  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             1.1.1.1          Full        
 ----------------------------------------------------------------------------
[R2-ospf-1-area-0.0.0.0]

  提示:可以看到当R2配置好ospf以后,它会和R1先建立其邻接关系;

  再次在R1上查看g0/0/0的接口信息,看看此时谁是DR和BDR

  提示:此时可以看到DR是R1的接口ip地址,BDR是R2的接口地址;

  配置R3

sys
sys R3
int g0/0/0
ip add 1.0.0.3 24
ospf 1 router-id 3.3.3.3
a 0
net 1.0.0.0 0.0.0.255
dis ip int b
dis ospf peer brief
View Code
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 1.0.0.3 24
Jul 24 2021 12:14:41-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]ospf 1 router-id 3.3.3.3
[R3-ospf-1]a 0
[R3-ospf-1-area-0.0.0.0]net 1.0.0.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]dis ip int b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              1.0.0.3/24           up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)     
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:45-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:45-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[8]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[9]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[10]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[11]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[12]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) 
[R3-ospf-1-area-0.0.0.0]dis ospf peer brief

         OSPF Process 1 with Router ID 3.3.3.3
                  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             1.1.1.1          Full        
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 ----------------------------------------------------------------------------
[R3-ospf-1-area-0.0.0.0]

  提示:可以看到当R3配置好以后,对应R3和R1和R2都建立起邻接关系;

  查看R3g0/0/0接口信息,看看DR和BDR变化没有?

  提示:之所以DR和BDR没有发生变化,其原因是ospf已经选好了DR和BDR,而DR和BDR的选举是非抢占性,一旦选好,就不变了,除非重启ospf进程(所有路由器)来触发DR和BDR的重新选举;

  配置R4

sys
sys R4
int g0/0/0
ip add 1.0.0.4 24
ospf 1 router-id 4.4.4.4
a 0
net 1.0.0.0 0.0.0.255
dis ip int b
dis ospf peer brief
View Code
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R4
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 1.0.0.4 24
Jul 24 2021 12:20:57-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]ospf 1 router-id 4.4.4.4
[R4-ospf-1]a 0
[R4-ospf-1-area-0.0.0.0]net 1.0.0.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]dis ip int b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              1.0.0.4/24           up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)     
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:04-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:04-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[8]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:04-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[9]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:05-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[10]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:05-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[11]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:05-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[12]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:06-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[13]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:06-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[14]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief
Jul 24 2021 12:21:06-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[15]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=2Way) 
[R4-ospf-1-area-0.0.0.0]dis ospf peer brief

         OSPF Process 1 with Router ID 4.4.4.4
                  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             1.1.1.1          Full        
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 0.0.0.0          GigabitEthernet0/0/0             3.3.3.3          2-Way       
 ----------------------------------------------------------------------------
[R4-ospf-1-area-0.0.0.0]

  提示:可以看到当R4配置好以后,对应R4和R1(DR),R2(BDR)是邻接关系;而和R3(DRothers)建立的邻居关系;

  验证:在R1上发布更新,抓包看看对应的数据包会怎么发送和确认?

  提示:可以看到当R1(DR)发送LSU时,它会直接向224.0.0.5发送;其中R2(BDR)向224.0.0.5确认;R3(DRothers)和R4(DRothers)向224.0.0.6确认;

  验证:在R2上发送LSU,看看对应数据包会这么发送和确认的呢?

  提示:可以看到当R2(BDR)发送LSU时,它和R1发送LSU一样直接向224.0.0.5发送LSU,对应R1(DR)直接向224.0.0.5确认;R3、R4(DRother)向224.0.0.6确认;

  验证:当R3发送LSU,看看对应数据包会这么发送和确认呢?

  提示:可以看到当R3(DRother)发送LSU时,它首先会把LSU通过224.0.0.6向R1(DR)发送,当R1(DR)收到R3发送的LSU,它会通过224.0.0.5向其他路由器发送LSU(不会再发送给R3);R2(BDR)收到LSU向224.0.0.5确认,R4(DRother)向224.0.0.6确认;

  验证:当R4 发送LSU时,看看对应数据包会怎么发送和确认呢?

  提示:可以看到R4(DRother)发送LSU和R3(DRother)发送LSU一样;首先它会把LSU发送给R1(DR),然后由R1(DR)再向其他路由器发送LSU;BDR(R2)直接向224.0.0.5确认;DRother(R3)向224.0.0.6确认;

  验证:全网重启ospf进程,看看对应的DR和BDR是否会重新选举?

  提示:可以看到4个路由器分别重新启动了ospf以后,重置ospf 进程以后,R4当选为DR,R3当选为BDR;因为重启ospf进程对应的邻居和邻接关系又重新建立,此时4个路由器首先会比较对应的hello包里的优先级,默认情况下优先级都是1 ,此时优先级一样,会比较router id,router id谁大谁就是DR,次大者就为BDR,剩下没有被选举成DR或BDR的就沦为DRother;R4的router id为4.4.4.4 是4个路由器中最大的,所以R4当选DR,R3的router id为3.3.3.3 ,第二大,所以当选BDR;

作者:Linux-1874
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
原文地址:https://www.cnblogs.com/qiuhom-1874/p/15054938.html