一、概述
在前面的文章我们学习了VRRP与BFD协议,VRRP(虚拟路由冗余协议)的主要特点是当Master(主)设备出现故障时,Backup(备用)设备能够快速接替Master的转发工作,尽量缩短数据流的中断时间。
在没有采用BFD与VRRP联动机制前,当Master出现故障时,VRRP依靠Backup设置的超时时间来判断是否应该抢占,切换速度在1s以上。将BFD应用于Backup对Master的检测后,可以实现对Master故障的快速检测,如果通信不正常,可在50ms以内自动升级成Master,实现快速的主、备切换,缩短用户流量的中断时间。
如下图所示,RouterA和RouterB之间配置VRRP备份组建立主备关系,RouterA为主用设备,RouterB为备用设备,用户过来的流量从RouterA出去。当在RouterA和RouterB之间建立BFD会话后,VRRP备份组监视该BFD会话,当BFD会话状态变为Down时,系统会自动通过修改备份组优先级实现主备快速切换。
例如,当BFD检测到RouterA和RouterB之间的链路故障时,上报给VRRP一个BFD检测Down事件,RouterB上VRRP备份组的优先级增加,增加后的优先级大于RouterA上的VRRP备份组的优先级,于是RouterB立即升为Master,后继的用户流量就会通过RouterB转发,从而实现VRRP的主备快速切换。
二、实验
拓扑
1、基本配置思路分析
本拓扑要监控的是RouterA和RouterB之间的下行链路状态,故可采用VRRP和BFD联动实现主备网关间的快速切换。其配置思路如下。
- 配置各设备接口的IP地址及路由协议(假设为OSPF),使网络层路由可达。
- 在RouterA和RouterB上配置VRRP备份组,其中RouterA的优先级为120,抢占延时为20s,作为Master设备;RouterB的优先级为缺省值,作为Backup设备。
- 在RouterA和RouterB上配置静态BFD会话,监测备份组之间的链路。
- 在RouterB上配置VRRP与BFD联动,实现链路故障时VRRP备份组的快速切换。
基础配置
RouterA
system
sysname RouterA
int g 0/0/0
ip add 10.1.1.1 24RouterB
system
sysname RouterB
int g 0/0/0
ip add 10.1.1.2 24
路由配置
RouterA
ospf 1 router-id 1.1.1.1
area 0
netw 10.1.1.1 0.0.0.0RouterB
ospf 1 router-id 2.2.2.2
area 0
netw 10.1.1.2 0.0.0.0
查看OSPF邻居状态
[RouterA-ospf-1]dis ospf peer briefOSPF Process 1 with Router ID 1.1.1.1Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full ----------------------------------------------------------------------------
[RouterB]dis ospf peer brief OSPF Process 1 with Router ID 2.2.2.2Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full ----------------------------------------------------------------------------
VRRP配置
RouterA
int g 0/0/0
vrrp vrid 1 vir 10.1.1.3
vrrp vrid 1 pri 120
vrrp vrid 1 preempt-mode timer delay 0RouterB
int g 0/0/0
vrrp vrid 1 vir 10.1.1.3
查看VRRP状态
[RouterA]dis vrrp GigabitEthernet0/0/0 | Virtual Router 1State : MasterVirtual IP : 10.1.1.3Master IP : 10.1.1.1PriorityRun : 120PriorityConfig : 120MasterPriority : 120Preempt : YES Delay Time : 0 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledCreate time : 2025-05-15 15:53:17 UTC-08:00Last change time : 2025-05-15 15:53:20 UTC-08:00
[RouterB]dis vrrpGigabitEthernet0/0/0 | Virtual Router 1State : BackupVirtual IP : 10.1.1.3Master IP : 10.1.1.1PriorityRun : 100PriorityConfig : 100MasterPriority : 120Preempt : YES Delay Time : 0 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledCreate time : 2025-05-15 15:53:35 UTC-08:00Last change time : 2025-05-15 15:53:35 UTC-08:00
BFD配置
RouterA
bfd
q
bfd 1 bind peer-ip 10.1.1.2 interface GigabitEthernet 0/0/0
discriminator local 1
discriminator remote 2
commitRouterB
bfd
q
bfd 1 bind peer-ip 10.1.1.1 interface GigabitEthernet 0/0/0
discriminator local 2
discriminator remote 1
commit
查看BFD状态
[RouterA]dis bfd ses all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------1 2 10.1.1.2 Up S_IP_IF GigabitEthernet0/0/0
--------------------------------------------------------------------------------Total UP/DOWN Session Number : 1/0
[RouterB]dis bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------2 1 10.1.1.1 Up S_IP_IF GigabitEthernet0/0/0
--------------------------------------------------------------------------------Total UP/DOWN Session Number : 1/0
配置VRRP与BFD联动
RouterB
int g 0/0/0
vrrp vrid 1 track bfd 2 increased 40
此时我们将RouterA的下行接口down掉
[RouterB]dis vrrpGigabitEthernet0/0/0 | Virtual Router 1State : MasterVirtual IP : 10.1.1.3Master IP : 10.1.1.2PriorityRun : 140PriorityConfig : 100MasterPriority : 140Preempt : YES Delay Time : 0 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledTrack BFD : 2 Priority increased : 40BFD-session state : DOWNCreate time : 2025-05-15 15:53:35 UTC-08:00Last change time : 2025-05-15 16:03:20 UTC-08:00
可以看到RouterB很快就会切换至Master设备并开始传输数据。
以上就是本章的全部内容了,感谢大家的浏览观看!文章若有错误或疑问可联系博主删除更改。