BFD与VRRP协议的联动配置
参考阅读
BFD技术与静态路由联动(Huawei设备)
BFD与OSPF联动(Huawei设备)
一、实验搭建
实验拓扑如下:
分析:
- R4、R5模拟两个终端设备,访问R1的环回有两条链路,通过R2出去为主链路,通过R3出去为备链路;
- 由于R1、R2间连接的网络时MA网络,所以当R2的0口出现故障后,R1并不会察觉到,即VRRP不能切换到备份链路,所以需要联动BFD
1.1 OSPF的配置
R2、R3上注意宣告静默接口;R1正常宣告即可
[R1-ospf-1]di th
[V200R003C00]
#
ospf 1
area 0.0.0.0
network 10.0.1.0 0.0.0.255
network 10.0.12.0 0.0.0.255
network 10.0.13.0 0.0.0.255
#
return
[R2-ospf-1]di th
[V200R003C00]
#
ospf 1
silent-interface GigabitEthernet0/0/1
area 0.0.0.0
network 10.0.2.0 0.0.0.255
network 10.0.12.0 0.0.0.255
network 192.168.45.0 0.0.0.255
#
return
[R3-ospf-1]di th
[V200R003C00]
#
ospf 1
silent-interface GigabitEthernet0/0/1
area 0.0.0.0
network 10.0.3.0 0.0.0.255
network 10.0.13.0 0.0.0.255
network 192.168.45.0 0.0.0.255
#
return
通过修改OSPF的cost来控制选路,即R2这边为主链路,则cost应小写;R1上的两个接口也要声明
[R2-GigabitEthernet0/0/0]di th
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 10.0.12.2 255.255.255.0
ospf cost 90
#
return
[R3-GigabitEthernet0/0/0]di th
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 10.0.13.2 255.255.255.0
ospf cost 100
#
return
[R1-GigabitEthernet0/0/0]di th
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 10.0.12.1 255.255.255.0
ospf cost 90
#
return
[R1-GigabitEthernet0/0/1]di th
[V200R003C00]
#
interface GigabitEthernet0/0/1
ip address 10.0.13.1 255.255.255.0
ospf cost 100
#
return
检查OSPF的邻居建立情况,可见连接了两个BMA网络,自己的环回时P2P
1.2VRRP的配置
R2、R3上起VRRP协议,虚拟的网关为192.168.45.1
[R2-GigabitEthernet0/0/1]di th
[V200R003C00]
#
interface GigabitEthernet0/0/1
ip address 192.168.45.2 255.255.255.0
vrrp vrid 1 virtual-ip 192.168.45.1
vrrp vrid 1 priority 150
#
return
[R3-GigabitEthernet0/0/1]di th
[V200R003C00]
#
interface GigabitEthernet0/0/1
ip address 192.168.45.3 255.255.255.0
vrrp vrid 1 virtual-ip 192.168.45.1
#
return
查看VRRP的状态情况,可见R2为主,R3为备
R4、R5上配置两条静态的缺省,下一跳为VRRP的Virtual IP
[R4]ip route-static 0.0.0.0 0.0.0.0 192.168.45.1
[R5]ip route-static 0.0.0.0 0.0.0.0 192.168.45.1
验证测试路由可达性,可见正常情况下路由走的是R2出去
若此时R1连接R2的接口down掉,R1是感知不到的,VRRP的主不会切换,则导致路由黑洞
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]shutdown
1.3 BFD联动的配置
R1、R2上启用BFD会话双向监测技术
[R1]bfd
[R1-bfd]quit
[R1]bfd 1 bind peer-ip 192.168.45.2 source-ip 10.0.12.1 auto [R1-bfd-session-1]commit
[R1-bfd-session-1]quit
[R2]bfd
[R2-bfd]quit
[R2]bfd 1 bind peer-ip 10.0.12.1 source-ip 192.168.45.2 auto [R2-bfd-session-1]commit
[R2-bfd-session-1]quit
检查BFD的会话建立情况,可见状态为UP
R2的VRRP中配置BFD联动,即检测BFD会话,相应的减少优先级,用于切换主备
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]vrrp vrid 1 track bfd-session session-name 1 reduce 60
验证检测:
down掉R1连接R2的接口
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]shutdown
查看BFD会话,可见状态为DOWN
查看VRRP是否切换主备,可见与预期相符
流量测试:
可见,路由也切换正常
二、实验分析
- 可否在OSPF中检测BFD,即不用VRRP与BFD联动?
不行,如果在R1、R2的OSPF中联动BFD,当R2接口down掉,即BFD会话也DOWN,那么OSPF邻居就会断开,而R2学不到R1的回环,且由于网关是虚拟的IP,主设备没有切换,路由还是会来到R2上,至此产生路由黑洞
- BFD与VRRP联动是还有什么应用场景?
在VRRP中联动的BFD会话可以检测不是VRRP设备直连的网段,即本实验中的R1、R2中的交换机可以换成一个三层设备,BFD检测这个三层设备与R2的直连链路