ensp模拟 通过 bfd 快速实现 ospf 邻居的断开
ospf 邻居断开 判断的规则是 4 倍的hello 时间,未收到回复,则认为断开。所以通常是 40秒或者 120秒。
OSPF 路由器如果在 Dead Interval 时间内没有收到邻居的 Hello 包,就会宣告该邻居失效。
- 广播/点对点网络:约 40 秒后判定邻居失效
- NBMA 网络:约 120 秒后判定邻居失效
网络拓扑图

实验目的
通过 display ospf peer bref
查看邻居建立的情况。 对比开启 bfd 和 未开启bfd ospf 邻居断开的时间。
实验配置
# AR1
system-view
sysname R1
bfd
ospf 1 router-id 1.1.1.1
bfd all-interface enable
area 0
int g0/0/0
ip address 12.0.0.1 24
ospf enable area 0
# AR2
system-view
sysname R2
bfd
ospf 1 router-id 2.2.2.2
bfd all-interface enable
area 0
int g0/0/0
ip address 12.0.0.2 24
ospf enable area 0
实验现象
80秒后ospf 完成收敛

ospf 收敛之后,开始发送 bfd 报文

可以看到 bfd 有三种状态
- Down
- Init
- Up
之后大约每秒种发送一次 bfd 报文。
查看ospf 的邻居状态
<R1>display ospf peer brief
OSPF Process 1 with Router ID 1.1.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full
----------------------------------------------------------------------------
<R1>
首先在R1上显示当前的时间,在R2上shutdown 链路,然后再R1 上查看ospf 的状态。
<R1>display clock
2025-04-14 16:16:47
Monday
Time Zone(China-Standard-Time) : UTC-08:00
<R1>display clock
2025-04-14 16:16:59
Monday
Time Zone(China-Standard-Time) : UTC-08:00
<R1>display ospf peer brief
Apr 14 2025 16:17:05-08:00 R1 %%01BFD/4/STACHG_TODWN(l)[0]:BFD session changed t
o Down. (SlotNumber=0, Discriminator=2097152, Diagnostic=DetectDown, Application
s=OSPF, ProcessPST=False, BindInterfaceName=GigabitEthernet0/0/0, InterfacePhysi
calState=Up, InterfaceProtocolState=Up)
<R1>display ospf peer brief
Apr 14 2025 16:17:05-08:00 R1 %%01OSPF/3/NBR_CHG_DOWN(l)[1]:Neighbor event:neigh
bor state changed to Down. (ProcessId=256, NeighborAddress=2.2.2.2, NeighborEven
t=KillNbr, NeighborPreviousState=Full, NeighborCurrentState=Down)
<R1>display ospf peer brief
Apr 14 2025 16:17:05-08:00 R1 %%01OSPF/3/NBR_DOWN_REASON(l)[2]:Neighbor state le
aves full or changed to Down. (ProcessId=256, NeighborRouterId=2.2.2.2, Neighbor
AreaId=0, NeighborInterface=GigabitEthernet0/0/0,NeighborDownImmediate reason=Ne
ighbor Down Due to Kill Neighbor, NeighborDownPrimeReason=BFD Session Down, Neig
hborChangeTime=2025-04-14 16:17:05-08:00)
<R1>display ospf peer brief
OSPF Process 1 with Router ID 1.1.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
----------------------------------------------------------------------------
<R1>display clock
2025-04-14 16:17:09
Monday
Time Zone(China-Standard-Time) : UTC-08:00
可以看到,三秒内就完成了,邻居的断开。