BFD与VRRP联动

一、概述

        在前面的文章我们学习了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 24

RouterB
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.0

RouterB
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 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        
 ----------------------------------------------------------------------------
[RouterB]dis ospf peer brief 

	 OSPF Process 1 with Router ID 2.2.2.2
		  Peer 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 0

RouterB
int g 0/0/0
vrrp vrid 1 vir 10.1.1.3

查看VRRP状态

[RouterA]dis vrrp 
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Master
    Virtual IP : 10.1.1.3
    Master IP : 10.1.1.1
    PriorityRun : 120
    PriorityConfig : 120
    MasterPriority : 120
    Preempt : YES   Delay Time : 0 s
    TimerRun : 1 s
    TimerConfig : 1 s
    Auth type : NONE
    Virtual MAC : 0000-5e00-0101
    Check TTL : YES
    Config type : normal-vrrp
    Backup-forward : disabled
    Create time : 2025-05-15 15:53:17 UTC-08:00
    Last change time : 2025-05-15 15:53:20 UTC-08:00
[RouterB]dis vrrp
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Backup
    Virtual IP : 10.1.1.3
    Master IP : 10.1.1.1
    PriorityRun : 100
    PriorityConfig : 100
    MasterPriority : 120
    Preempt : YES   Delay Time : 0 s
    TimerRun : 1 s
    TimerConfig : 1 s
    Auth type : NONE
    Virtual MAC : 0000-5e00-0101
    Check TTL : YES
    Config type : normal-vrrp
    Backup-forward : disabled
    Create time : 2025-05-15 15:53:35 UTC-08:00
    Last 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
commit

RouterB
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 vrrp
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Master
    Virtual IP : 10.1.1.3
    Master IP : 10.1.1.2
    PriorityRun : 140
    PriorityConfig : 100
    MasterPriority : 140
    Preempt : YES   Delay Time : 0 s
    TimerRun : 1 s
    TimerConfig : 1 s
    Auth type : NONE
    Virtual MAC : 0000-5e00-0101
    Check TTL : YES
    Config type : normal-vrrp
    Backup-forward : disabled
    Track BFD : 2  Priority increased : 40
    BFD-session state : DOWN
    Create time : 2025-05-15 15:53:35 UTC-08:00
    Last change time : 2025-05-15 16:03:20 UTC-08:00

可以看到RouterB很快就会切换至Master设备并开始传输数据。

以上就是本章的全部内容了,感谢大家的浏览观看!文章若有错误或疑问可联系博主删除更改。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Fanmeang.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值