VRRP与BFD联动监视上行链路

一、拓扑

        本拓扑局域网内的主机通过交换机双归属到部署了VRRP备份组的RouterA和RouterB,其中RouterA为Master。正常情况下,RouterA承担网关工作,用户侧流量经交换机->RouterA->RouterC->RouterE进行转发。用户希望当RouterC到RouterE之间的链路故障时,VRRP备份组可以在1s内感知故障,并快速进行主备切换,启用RouterB承担业务转发,以减小链路故障对业务转发的影响。

1、基本配置思路

本拓扑监控的是上行非直连链路,可采用与BFD联动的方式,基本的配置思路如下。

  • 配置各设备接口的IP地址及路由协议,使网络层路由可达。
  • 在RouterA和RouterB上配置VRRP备份组,其中RouterA的优先级为120,抢占延时为20s,作为Master设备;RouterB的优先级为缺省值,作为Backup设备。
  • 在RouterA和RouterE上配置静态BFD会话,监测RouterA到RouterE之间的链路。
  • 在RouterA上配置VRRP与BFD联动,实现链路故障时触发VRRP备份组主备切换的目的。

基础配置

RouterA
system
sysname RouterA
int g 0/0/0
ip add 10.1.1.1 24
int g 0/0/1
ip add 192.168.1.1 24

RouterB
system
sysname RouterB
int g 0/0/0
ip add 10.1.1.2 24
int g 0/0/1
ip add 192.168.2.1 24

RouterC
system
sysname RouterC
int g 0/0/0
ip add 192.168.1.2 24
int g 0/0/1
ip add 172.16.1.1 24

RouterD
system
sysname RouterD
int g 0/0/0
ip add 192.168.2.2 24
int g 0/0/1
ip add 172.16.2.1 24

RouterE
system
sysname RouterE
int g 0/0/0
ip add 172.16.1.2 24
int g 0/0/1
ip add 172.16.2.2 24

路由配置

RouterA
ospf 1 router-id 1.1.1.1
area 0
netw 10.1.1.1 0.0.0.0
netw 192.168.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
netw 192.168.2.1 0.0.0.0

RouterC
ospf 1 router-id 3.3.3.3
area 0
netw 192.168.1.2 0.0.0.0
netw 172.16.1.1 0.0.0.0

RouterD
ospf 1 router-id 4.4.4.4
area 0
netw 192.168.2.2 0.0.0.0
netw 172.16.2.1 0.0.0.0

RouterE
ospf 1 router-id 5.5.5.5
area 0
netw 172.16.1.2 0.0.0.0
netw 172.16.2.2 0.0.0.0

查看OSPF邻居状态

[RouterA]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        
 0.0.0.0          GigabitEthernet0/0/1             3.3.3.3          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        
 0.0.0.0          GigabitEthernet0/0/1             4.4.4.4          Full        
 ----------------------------------------------------------------------------
[RouterC]dis ospf peer brief 

	 OSPF Process 1 with Router ID 3.3.3.3
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             1.1.1.1          Full        
 0.0.0.0          GigabitEthernet0/0/1             5.5.5.5          Full        
 ----------------------------------------------------------------------------
[RouterD]dis ospf peer brief 

	 OSPF Process 1 with Router ID 4.4.4.4
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 0.0.0.0          GigabitEthernet0/0/1             5.5.5.5          Full        
 ----------------------------------------------------------------------------
[RouterE]dis ospf peer brief 

	 OSPF Process 1 with Router ID 5.5.5.5
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             3.3.3.3          Full        
 0.0.0.0          GigabitEthernet0/0/1             4.4.4.4          Full        
 ----------------------------------------------------------------------------

VRRP配置

RouterA
int g 0/0/0
vrrp vrid 1 vir 10.1.1.10
vrrp vrid 1 pri 120
vrrp vrid 1 preempt-mode timer delay 20

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

查看VRRP状态

[RouterA]dis vrrp
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Master
    Virtual IP : 10.1.1.10
    Master IP : 10.1.1.1
    PriorityRun : 120
    PriorityConfig : 120
    MasterPriority : 120
    Preempt : YES   Delay Time : 20 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 16:42:59 UTC-08:00
    Last change time : 2025-05-15 16:43:03 UTC-08:00

[RouterB]dis vrrp
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Backup
    Virtual IP : 10.1.1.10
    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 16:43:05 UTC-08:00
    Last change time : 2025-05-15 16:43:05 UTC-08:00

BFD配置

RouterA
bfd
q
bfd 1 bind peer-ip 172.16.1.2
discriminator local 1
discriminator remote 2
commit 

RouterE
bfd 1 bind peer-ip 192.168.1.1
discriminator local 2
discriminator remote 1
commit 

查看BFD状态

[RouterA]dis bfd ses all
--------------------------------------------------------------------------------
Local Remote     PeerIpAddr      State     Type        InterfaceName            
--------------------------------------------------------------------------------

1     2          172.16.1.2      Up        S_IP_PEER         -                  
--------------------------------------------------------------------------------
     Total UP/DOWN Session Number : 1/0
[RouterE]dis bfd ses all
--------------------------------------------------------------------------------
Local Remote     PeerIpAddr      State     Type        InterfaceName            
--------------------------------------------------------------------------------

2     1          192.168.1.1     Up        S_IP_PEER         -                  
--------------------------------------------------------------------------------
     Total UP/DOWN Session Number : 1/0

配置VRRP与BFD联动

RouterA
int g 0/0/0
vrrp vrid 1 track bfd-session 1 reduced 40

配置完所有相关命令后我们在RouterC与RouterE之间的链路down掉看看是否可以快速监测到链路故障实现VRRP主备切换

[RouterA]
May 15 2025 16:48:31-08:00 RouterA %%01BFD/4/STACHG_TODWN(l)[16]:BFD session cha
nged to Down. (SlotNumber=0, Discriminator=16777216, Diagnostic=NeighborDown, Ap
plications=VRRP, ProcessPST=False, BindInterfaceName=None, InterfacePhysicalStat
e=None, InterfaceProtocolState=None) 
[RouterA]
May 15 2025 16:48:31-08:00 RouterA %%01VRRP/4/STATEWARNINGEXTEND(l)[17]:Virtual 
Router state MASTER changed to BACKUP, because of priority calculation. (Interfa
ce=GigabitEthernet0/0/0, VrId=16777216, InetType=IPv4) 
[RouterA]
May 15 2025 16:48:31-08:00 RouterA VRRP/2/VRRPMASTERDOWN:OID 16777216.50331648.1
00663296.16777216.67108864.16777216.3674669056.83886080.419430400.2130706432.335
54432.503316480.16777216 The state of VRRP changed from master to other state. (
VrrpIfIndex=50331648, VrId=16777216, IfIndex=50331648, IPAddress=1.1.1.10, NodeN
ame=RouterA, IfName=GigabitEthernet0/0/0, CurrentState=Backup, ChangeReason=prio
rity calculation) 
[RouterB]
May 15 2025 16:48:32-08:00 RouterB VRRP/2/VRRPCHANGETOMASTER:OID 16777216.503316
48.100663296.16777216.33554432.16777216.1140850688.0.16777216 The status of VRRP
 changed to master. (VrrpIfIndex=50331648, VrId=16777216, IfIndex=50331648, IPAd
dress=2.1.1.10, NodeName=RouterB, IfName=GigabitEthernet0/0/0, ChangeReason=prio
rity calculation(GigabitEthernet0/0/0 up)) 
[RouterB]
May 15 2025 16:48:32-08:00 RouterB %%01VRRP/4/STATEWARNINGEXTEND(l)[14]:Virtual 
Router state BACKUP changed to MASTER, because of priority calculation. (Interfa
ce=GigabitEthernet0/0/0, VrId=16777216, InetType=IPv4) 

可以看到当上行链路故障时BFD会立刻监测到并发送日志告警信息。

[RouterA]dis vrrp
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Backup
    Virtual IP : 10.1.1.10
    Master IP : 10.1.1.2
    PriorityRun : 80
    PriorityConfig : 120
    MasterPriority : 100
    Preempt : YES   Delay Time : 20 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 : 1  Priority reduced : 40
    BFD-session state : DOWN
    Create time : 2025-05-15 16:42:59 UTC-08:00
    Last change time : 2025-05-15 16:48:31 UTC-08:00

当BFD监测到上行链路故障时,VRRP会降低自身40的优先级变为80,此时RouterB就成为了新的Master来承载数据流量转发。

[RouterB]dis vrrp
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Master
    Virtual IP : 10.1.1.10
    Master IP : 10.1.1.2
    PriorityRun : 100
    PriorityConfig : 100
    MasterPriority : 100
    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 16:43:05 UTC-08:00
    Last change time : 2025-05-15 16:48:32 UTC-08:00

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Fanmeang.

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

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

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

打赏作者

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

抵扣说明:

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

余额充值