VRRP 与 BFD 联动实现快速切换

写在前面:本人是一名计算机系大二的学生,会不定时的将我的学习笔记分享给大家!如果需要更多的学习资源可以通过我的GitHub自行下载!

实验topo

vrrp联动

实验要求

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

实验步骤

1、配置设备间的网络互连

[RA]
#
sy
sysname RA 
#
interface GigabitEthernet0/0/1
ip address 10.1.1.1 255.255.255.0
#
ospf 1  //配置ospf进行互连
a 0
net    10.1.1.0  0.0.0.255
#
[RB]
#
sy
sysname RB
 #
interface GigabitEthernet0/0/2
ip address 10.1.1.2 255.255.255.0
#
ospf 1
a 0
net   10.1.1.0   0.0.0.255
#

配置二层穿透功能

[Switch]
#
sysname Switch
#
vlan batch 100
#
interface GigabitEthernet0/0/1
port hybrid pvid vlan 100
port hybrid untagged vlan 100  //剥离tag,三层无法剥离tag
#
interface GigabitEthernet0/0/2
port hybrid pvid vlan 100
port hybrid untagged vlan 100
#

2、配置vrrp主备备份

[RA]
#
int  g0/0/1
vrrp vrid 1 virtual-ip 10.1.1.3
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 20
#
[RB]
#
interface GigabitEthernet0/0/2
vrrp vrid 1 virtual-ip 10.1.1.3
#

3、配置BFD会话

[RA]
#
bfd
#
bfd atob bind peer-ip 10.1.1.2 interface GigabitEthernet0/0/1
discriminator local 1
discriminator remote 2
min-tx-interval 50
min-rx-interval 50
commit 
#
[RouterB] 
#
bfd
#
bfd btoa bind peer-ip 10.1.1.1 interface GigabitEthernet0/0/2
discriminator remote 1
min-tx-interval 50
min-rx-interval 50
commit
#

验证状态

<RA> display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName 
--------------------------------------------------------------------------------
1 2 10.1.1.2 Up S_IP_IF GigabitEthernet0/0/1
--------------------------------------------------------------------------------
 Total UP/DOWN Session Number : 1/0

4、配置BDF联动

  • 在 RouterB 上配置 VRRP 与 BFD 联动,当 BFD 会话状态 Down 时,RouterB 的优先级增
    加 40。
[RB]
#
interface   g0/0/1
vrrp  vrid   1  track  bfd-sesion 2  increased  40
q
#

5、验证配置结果

<RA> display vrrp
 GigabitEthernet2/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 : 20 s 
 TimerRun : 1 s 
 TimerConfig : 1 s
 Auth Type : NONE
 Virtual Mac : 0000-5e00-0101
 Check TTL : YES
 Config type : normal-vrrp
 Create time : 2020-06-14 12:32:56
 Last change time : 2020-06-14  12:33:00
<RouterB> display vrrp
GigabitEthernet2/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
Track BFD : 2 Priority increased : 40
BFD-Session State: UP
Create time : 2020-06-14 12:32:56
Last change time : 2020-06-14 12:32:56

模拟故障
在r1上执行shutdown命令,用display vrrp查看。

[RA]
#
int   g0/0/1
shutdown
#
[RA] display vrrp
 GigabitEthernet2/0/0 | Virtual Router 1
 State : Initialize
 Virtual IP : 10.1.1.3
 Master IP : 0.0.0.0
 PriorityRun : 120
 PriorityConfig : 120
 MasterPriority : 0
 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
<RB> display vrrp
 GigabitEthernet2/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
 Track BFD : 2 Priority increased : 40  //增加40 
 BFD-Session State: DOWN   //可以看到这里的状态是关闭的!
 

配置文件

  • RA 的配置文件
#
sysname RA #
bfd
#
interface GigabitEthernetg0/0/1
ip address 10.1.1.1 255.255.255.0
vrrp vrid 1 virtual-ip 10.1.1.3
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 20
#
bfd atob bind peer-ip 10.1.1.2 interface GigabitEthernet0/0/1
discriminator local 1
discriminator remote 2
min-tx-interval 50
min-rx-interval 50
commit 
#
return
  • RB 的配置文件
#
sysname RouterB #
bfd
#
interface GigabitEthernet0/0/2
ip address 10.1.1.2 255.255.255.0
vrrp vrid 1 virtual-ip 10.1.1.3
vrrp vrid 1 track bfd-session 2 increased 40
#
bfd btoa bind peer-ip 10.1.1.1 interface GigabitEthernet0/0/2
discriminator local 2
discriminator remote 1
min-tx-interval 50
min-rx-interval 50
commit
#
return
  • Switch 的配置文件
#
sysname Switch
#
vlan batch 100
#
interface GigabitEthernet0/0/1
port hybrid pvid vlan 100
port hybrid untagged vlan 100
#
interface GigabitEthernet0/0/2
port hybrid pvid vlan 100
port hybrid untagged vlan 100
#
return

本文均属肉肉原创,如有不详或错误,欢迎指出!

本文作者肉肉
版权声明:博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!

原文地址:https://www.cnblogs.com/linwenye/p/13269862.html