简介
BFD:BFD:BidirectionalForwarding Detection,双向转发检查 作用:毫秒级故障检查,通常结合三层协议(如静态路由、vrrp、ospf、BGP等)实现链路故障快速检查
简单实验拓扑
AR1:
[AR1]ip route-static 2.2.2.0 24 12.1.1.2
[AR1]ip route-static 2.2.2.0 24 21.1.1.2 preference 70
AR2:
[AR2]ip route-static 1.1.1.0 24 12.1.1.1
[AR2]ip route-static 1.1.1.1 24 21.1.1.1 preference 70
[AR1]ping -a 1.1.1.1 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=470 ms
Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=60 ms
Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=40 ms
Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=40 ms
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/130/470 ms
R1:
[AR1]bfd
[AR1]bfd 1 bind peer-ip 12.1.1.2 source-ip 12.1.1.1
[AR1-bfd-session-1]discriminator local 1 #配置本地标识
[AR1-bfd-session-1]discriminator remote 2 #配置远端标识
[AR1-bfd-session-1]comm
[AR1-bfd-session-1]commit #提交
R2:
bfd
bfd 1 bind peer-ip 12.1.1.1 source-ip 12.1.1.2
discriminator local 2
discriminator remote 1
commit
在静态路由上配置bfd:
R1:
[AR1]ip route-static 2.2.2.0 24 12.1.1.2 track bfd-session 1
R2:
[AR2]ip route-static 1.1.1.0 24 12.1.1.1 track bfd-session 1
1
查看bfd信息
[AR1]dis bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
1 2 12.1.1.2 Up S_IP_PEER -
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
查看更加详细的bfd信息:
[AR1]dis bfd session all verbose
--------------------------------------------------------------------------------
Session MIndex : 256 (Multi Hop) State : Up Name : 1
--------------------------------------------------------------------------------
Local Discriminator : 1 Remote Discriminator : 2
Session Detect Mode : Asynchronous Mode Without Echo Function
BFD Bind Type : Peer IP Address
Bind Session Type : Static
Bind Peer IP Address : 12.1.1.2
Bind Interface : -
Track Interface : -
Bind Source IP Address : 12.1.1.1
FSM Board Id : 0 TOS-EXP : 7
Min Tx Interval (ms) : 1000 Min Rx Interval (ms) : 1000
Actual Tx Interval (ms): 1000 Actual Rx Interval (ms): 1000
Local Detect Multi : 3 Detect Interval (ms) : 3000
Echo Passive : Disable Acl Number : -
ospf 调用bfd 加快收敛
前言:ospf默认的hello报文是10秒钟发一次,检测到故障是40秒也就是需要四十秒才能将那个有问题的路由清除,在ospf上调用bfd可以起到快速收敛的作用
实验拓扑:
AR1:
[AR1]ospf 1
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.255
[AR1-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255
[AR1]ospf 1
[AR1-ospf-1]bfd all-interfaces enable
AR2:
[AR2]ospf 1
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]net
[AR2-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.255
[AR2-ospf-1-area-0.0.0.0]network 2.2.2.0 0.0.0.255
[AR2]ospf 1
[AR2-ospf-1]bfd all-interfaces enable
如果我们把右边的网线断开,如果通过ospf去收敛的话需要几十秒,但是通过调用bfd几秒就可以收敛完成
[AR1]dis ospf peer brief
OSPF Process 1 with Router ID 12.1.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 12.1.1.2 Full
----------------------------------------------------------------------------