BFD

1.BFD简介 2.静态路由调用BFD 3.OSPF调用BFD 4.VRRP调用BFD​

​BFD:Bidirectional Forwarding Detection 双向转发检查

作用:毫秒级故障检查,通常结合三层协议(如静态路由,VRRP,OSPF,BGP等)实现链路故障快速检查。

1.BFD简介 2.静态路由调用BFD 3.OSPF调用BFD 4.VRRP调用BFD_第1张图片

​如图1:R1到达R2的2.2.2.2的路由有两条线路,有上面的链路带宽高,所以路由走上面的路线,

但是当在R2的一侧线路出现了故障,这时R1无法及时的感知线路出现故障,因此采用BFD进行快速检查,能在毫秒的时间内完成线路的切换。

1.静态BFD检查

1.BFD简介 2.静态路由调用BFD 3.OSPF调用BFD 4.VRRP调用BFD_第2张图片

​#R1的配置

[Huawei]sysnam R1

[R1]inteface Ethernet0/0/1

[R1-Ethernet0/0/1]ip address 21.1.1.10 255.255.255.0

[R1-Ethernet0/0/1]quit

[R1]interface Ethernet0/0/0

[R1-Ethernet0/0/0]ip address 12.1.1.10 255.255.255.0

[R1-Ethernet0/0/0]quit

[R1]interface loopback 0

[R1-loopback0]ip address 1.1.1.1 32

[R1-loopback0]quit

[R1]bfd

[R1-bfd]quit

[R1]bfd 1 bind peer-ip 12.1.1.11 source-ip 12.1.1.10

[R1-bfd-session-1]discriminator local 2

[R1-bfd-session-1]discriminator remot 1

[R1-bfd-session-1]commit

[R1-bfd-session-1]quit

[R1]

[R1]ip route-static 2.2.2.2 32 21.1.1.11

[R1]ip route-static 2.2.2.2 32 12.1.1.11 pre 55 track bfd-session 1

#R2的配置

[Huawei]sysnam R2

[R2]inteface Ethernet0/0/1 //进入接口

[R2-Ethernet0/0/1]ip address 21.1.1.11 255.255.255.0 //配置接口IP地址

[R2-Ethernet0/0/1]quit

[R2]interface Ethernet0/0/0

[R2-Ethernet0/0/0]ip address 12.1.1.11 255.255.255.0

[R2-Ethernet0/0/0]quit

[R2]interface loopback 0

[R2-loopback0]ip address 2.2.2.2 32

[R2-loopback0]quit

[R2]bfd //全局使能BFD

[R2-bfd]quit

[R2]bfd 1 bind peer-ip 12.1.1.1 0 source-ip 12.1.1.11 . //创建BFD进程1

[R2-bfd-session-1]discriminator local 1 //本地标识,两台路由器的标识需要互相对称

[R2-bfd-session-1]discriminator remot 2 //远端便是

[R2-bfd-session-1]commit //提交BFD配置

[R2-bfd-session-1]quit

[R2]ip route-static 1.1.1.1 32 21.1.1.10

[R2]ip route-static 1.1.1.1 32 12.1.1.10 pre 55 track bfd-session 1 //在静态路由下调用BFD

[R2]

#R10查看配置的BFD

display bfd session static


Local Remote PeerIpAddr State Type InterfaceName


1               2                    12.1.1.11                  Up                  S_IP_PEER -

Total UP/DOWN Session Number : 1/0

#R10上查看BFD详细配置

display bfd session static 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.11

Bind Interface : -

Track Interface : -

Bind Source IP Address : 12.1.1.10

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 : -

Destination Port : 3784 TTL : 254

Proc Interface Status : Disable Process PST : Disable

WTR Interval (ms) : -

Active Multi : 3

Last Local Diagnostic : No Diagnostic

Bind Application : No Application Bind

Session TX TmrID : - Session Detect TmrID : -

Session Init TmrID : - Session WTR TmrID : -

Session Echo Tx TmrID : -

PDT Index : FSM-0 | RCV-0 | IF-0 | TOKEN-0

Session Description : -


Total UP/DOWN Session Number : 1/0

2.动态BFD:OSPF调用BFD加速收敛

1.BFD简介 2.静态路由调用BFD 3.OSPF调用BFD 4.VRRP调用BFD_第3张图片

​#R1的配置

[R1]interface Ethernet0/0/0

[R1-Ethernet0/0/0]ip address 12.1.1.1 24

[R1-Ethernet0/0/0]quit

[R1]interface Loopback0

[R1-loopback0]ip address 1.1.1.1 255.255.255.255

[R1-loopback0]quit

[R1]router id 1.1.1.1 //配置路由器Router-ID

[R1]ospf 10 //开启OSPF进程10

[R1-ospf-10]area 0 //进入OSPF进程10的区域0

[R1-ospf-10-0.0.0.0]network 12.1.1.0 0.0.0.255 / /在OSPF10的区域0下宣告路由

[R1-ospf-10-0.0.0.0]network 1.1.1.1 0.0.0.0

[R1-ospf-10-0.0.0.0]quit

[R1-ospf-10]quit

[R1]bfd //全局开启BFD检查功能

[R1-bfd]quit

[R1]ospf 10 //进入OSPF进程10

[R1-ospf-10]bfd all-interfaces enable //在OSPF下开启BFD检测

[R1-ospf-10]quit

[R1]

#R2的配置

[R2]interface Ethernet0/0/0

[R2-Ethernet0/0/0]ip address 12.1.1.1 24

[R2-Ethernet0/0/0]quit

[R2]interface Loopback0 //进入环回口

[R2-loopback0]ip address 1.1.1.1 255.255.255.255 //配置环回口的地址

[R2-loopback0]quit

[R2]router id 1.1.1.1

[R2]ospf 10

[R2-ospf-10]area 0

[R2-ospf-10-0.0.0.0]network 12.1.1.0 0.0.0.255

[R2-ospf-10-0.0.0.0]network 1.1.1.1 0.0.0.0

[R2-ospf-10-0.0.0.0]quit

[R2-ospf-10]quit

[R2]bfd //全局开启BFD检查

[R2-bfd]quit

[R2]ospf 10 //进入OSPF的10进程

[R2-ospf-10]bfd all-interfaces enable

[R2-ospf-10]quit

[R2]

#R10下显示BFD的动态邻居

display bfd session dynamic


Local Remote PeerIpAddr State Type InterfaceName


8192 8192 21.1.1.11 Up D_IP_IF GigabitEthernet0/0/0

8193 8193 12.1.1.11 Up D_IP_IF GigabitEthernet0/0/1


Total UP/DOWN Session Number : 2/0

#R10上配置BFD的详细信息

display bfd session all verbose


Session MIndex : 257 (One Hop) State : Up Name : dyn_8192


Local Discriminator : 8192 Remote Discriminator : 8192

Session Detect Mode : Asynchronous Mode Without Echo Function

BFD Bind Type : Interface(GigabitEthernet0/0/0)

Bind Session Type : Dynamic

Bind Peer IP Address : 21.1.1.11

NextHop Ip Address : 21.1.1.11

Bind Interface : GigabitEthernet0/0/0

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 : -

Destination Port : 3784 TTL : 255

Proc Interface Status : Disable Process PST : Disable

WTR Interval (ms) : -

Active Multi : 3

Last Local Diagnostic : No Diagnostic

Bind Application : OSPF

Session TX TmrID : - Session Detect TmrID : -

Session Init TmrID : - Session WTR TmrID : -

Session Echo Tx TmrID : -

PDT Index : FSM-0 | RCV-0 | IF-0 | TOKEN-0

Session Description : -



Session MIndex : 258 (One Hop) State : Up Name : dyn_8193


Local Discriminator : 8193 Remote Discriminator : 8193

Session Detect Mode : Asynchronous Mode Without Echo Function

BFD Bind Type : Interface(GigabitEthernet0/0/1)

Bind Session Type : Dynamic

Bind Peer IP Address : 12.1.1.11

NextHop Ip Address : 12.1.1.11

Bind Interface : GigabitEthernet0/0/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 : -

Destination Port : 3784 TTL : 255

Proc Interface Status : Disable Process PST : Disable

WTR Interval (ms) : -

Active Multi : 3

Last Local Diagnostic : No Diagnostic

Bind Application : OSPF

Session TX TmrID : - Session Detect TmrID : -

Session Init TmrID : - Session WTR TmrID : -

Session Echo Tx TmrID : -

PDT Index : FSM-1 | RCV-0 | IF-0 | TOKEN-0

Session Description : -


Total UP/DOWN Session Number : 2/0

3.VRRP联动BFD

拓扑图拓扑图

​具体配置:

#R10配置

[R10]interface GigabitEthernet0/0/0 //进入接口GigabitEthernet0/0/0

[R10-GigabitEthernet0/0/0]ip address 21.1.1.10 255.255.255.0 //配置接口IP地址

[R10-GigabitEthernet0/0/0]quit //退出接口

[R10]bfd

[R10-bfd]quit

[R10]bfd 5 bind peer-ip 112.1.1.12 source-ip 112.1.1.10 //配置静态BFD-5

[R10-bfd-session-5]discriminator local 100 //配置本地值100

[R10-bfd-session-5]discriminator remote 200 //配置远端值200

[R10-bfd-session-5]commit //提交BFD配置

[R10-bfd-session-5]quit

[R10]bfd bb bind peer-ip 112.1.1.12 source-ip 112.1.1.10 auto

[R10-bfd-session-bb]quit

[R10]

[R10]interface GigabitEthernet0/0/1

[R10-GigabitEthernet0/0/1]ip address 12.1.1.10 255.255.255.0

[R10-GigabitEthernet0/0/1]vrrp vrid 10 virtual-ip 12.1.1.1

[R10-GigabitEthernet0/0/1]vrrp vrid 10 priority 105

[R10-GigabitEthernet0/0/1]vrrp vrid 10 track bfd-session 100//VRRP调用BFD100是BFD的本地标识

[R10-GigabitEthernet0/0/1]quit

[R10]interface loopback 0

[R10-loopback0]ip address 10.10.10.10 255.255.255.25

[R10-loopback0]quit

[R10]

#R11的配置

[R11]interface GigabitEthernet0/0/0

[R11-GigabitEthernet0/0/0]ip address 21.1.1.11 255.255.255.0

[R11-GigabitEthernet0/0/0]quit

[R11]interface GigabitEthernet0/0/1

[R11-GigabitEthernet0/0/1]ip address 12.1.1.11 255.255.255.0

[R11-GigabitEthernet0/0/1]vrrp vrid 10 virtual-ip 12.1.1.1

[R11-GigabitEthernet0/0/1]quit

[R11]interface loopback 0

[R11-loopback0]ip address 11.11.11.11 255.255.255.25

[R11-loopback0]quit

[R11]

#R12的配置

[R12]interface GigabitEthernet0/0/0

[R12-GigabitEthernet0/0/0]ip address 112.1.1.12 255.255.255.0

[R12-GigabitEthernet0/0/0]quit

[R12]

[R12]bfd 5 bind peer-ip 112.1.1.12 source-ip 112.1.1.10

[R12-bfd-session-5]discriminator local 200 //配置BFD的本地标识

[R12-bfd-session-5]discriminator remote 100 //配置BFD的远端标识

[R12-bfd-session-5]commit //提交BFD的配置

[R12-bfd-session-5]quit

[R12]bfd bb bind peer-ip 112.1.1.10 source-ip 112.1.1.12 auto //配置BFD自动检测机制

[R12]interface loopback 0

[R12-loopback0]ip address 12.12.12.12 255.255.255.255

[R12-loopback0]quit

[R12]

R10上查看BFD会话

[R10]display bfd session all


Local Remote PeerIpAddr State Type InterfaceName


8192 8192 21.1.1.11 Up D_IP_IF GigabitEthernet0/0/0

8193 8193 12.1.1.11 Up D_IP_IF GigabitEthernet0/0/1

100 200 112.1.1.12 Up S_IP_PEER -


Total UP/DOWN Session Number : 3/0

[R10]

#R10上查看VRRP配置(断开链路后VRRP优先级发生变化)

display vrrp

GigabitEthernet0/0/1 | Virtual Router 10

State : Backup

Virtual IP : 12.1.1.1 Master IP : 12.1.1.11

PriorityRun : 95 PriorityConfig : 105
MasterPriority : 100 Preempt : YES Delay Time : 0 s

TimerRun : 1 s TimerConfig : 1 s

Auth type : NONE Virtual MAC : 0000-5e00-010a

Check TTL : YES Config type : normal-vrrp

Backup-forward : disable Track BFD : bb Priority reduced : 10

BFD-session state : DOWN Create time : 2020-03-29 14:35:24 UTC-08:00

Last change time : 2020-03-29 15:29:32 UTC-08:00

#R10在对端链路回复后的优先级

display vrrp

GigabitEthernet0/0/1 | Virtual Router 10

State : Master

Virtual IP : 12.1.1.1 Master IP : 12.1.1.10

PriorityRun : 105 PriorityConfig : 105
MasterPriority : 105 Preempt : YES Delay Time : 0 s

TimerRun : 1 s TimerConfig : 1 s

Auth type : NONE Virtual MAC : 0000-5e00-010a

Check TTL : YES Config type : normal-vrrp

Backup-forward : disable Track BFD : bb Priority reduced : 10

BFD-session state : UP Create time : 2020-03-29 14:35:24 UTC-08:00

Last change time : 2020-03-29 15:37:00 UTC-08:00

注意:VRRP联动BFD:通常如果VRRP的上联有二层设备隔离,此时可以借助BFD实现故障检测。