欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 焦点 > 网络实验-VRRP

网络实验-VRRP

2025/5/17 16:24:18 来源:https://blog.csdn.net/hehao1999/article/details/147869766  浏览:    关键词:网络实验-VRRP

VRRP协议简述

VRRP(虚拟路由冗余协议)通过虚拟IP地址(VIP,virtual ip)来实现冗余。在正常情况下,Master路由器会响应VIP的ARP请求,并处理所有发往VIP的流量。Backup路由器则处于待命状态,只有在Master路由器故障时才会接管VIP。

实验目的

了解VRRP配置

网络拓扑

在AR1和AR2左侧接口配置VRRP, AR1、AR2或其连线出现故障时,只要有正常连接都可以通信。
VRRP路由拓扑

配置内容

vrrp协议在标准协议模式下,一个VRRP组最多支持16个设备(包括Master和Backup路由器)。这个限制适用于大多数设备,但不同设备和配置可能会有所不同。——kimi

这里只配置一个vrrp组,组中配置两个成员。

VRRP配置

VRRP协议使用广播或多播消息(没有配置多播路由协议的时候和广播也是一样只能在二层网络内传播)来通告Master路由器的状态。因此,配置VRRP的一组路由器接口必须在同一个二层网络中,虚拟IP地址与配置VRRP的接口必须在同一个子网。

master
#
interface GigabitEthernet0/0/0ip address 192.168.55.100 255.255.255.0 # vrrp vrid 1 virtual-ip 192.168.55.254# 默认优先级为100, 值越大权重越高vrrp vrid 1 priority 120# 抢占时间,为master故障后,恢复连接到重新成为master的时间配置vrrp vrid 1 preempt-mode timer delay 100# 跟踪右侧接口,右侧接口故障后降低优先级,成为backupvrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 30
#
interface GigabitEthernet0/0/1ip address 10.20.30.50 255.255.255.0 
backup
#
interface GigabitEthernet0/0/0ip address 192.168.55.200 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.55.254
#
interface GigabitEthernet0/0/1ip address 10.30.40.60 255.255.255.0 

RIP

在三个路由器上配置。

#
rip 1
# 默认情况下,RIP协议会自动汇总路由,这可能导致一些问题,特别是在使用VLSM(可变长子网掩码)的网络中。取消自动汇总后,RIP协议会发送更详细的路由信息。undo summaryversion 2network 192.168.55.0network 10.0.0.0

可靠性验证

正常连接时,ping测试主机可以通信。关闭master路由右侧接口或断开右侧连接或关闭右侧路由器的G0/0/0接口或其他影响master路由部分的通信的操作时,通信正常。

断开master右侧

右侧

VRRP配置跟踪右侧接口,发现右侧接口down, 降低优先级为90低于原backup 100成为backup。原backup成为master。

[R1]display vrrpGigabitEthernet0/0/0 | Virtual Router 1State : BackupVirtual IP : 192.168.55.254Master IP : 192.168.55.200PriorityRun : 90PriorityConfig : 120MasterPriority : 100Preempt : YES   Delay Time : 100 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledTrack IF : GigabitEthernet0/0/1   Priority reduced : 30IF state : DOWNCreate time : 2025-05-11 09:56:45 UTC-08:00Last change time : 2025-05-11 11:05:36 UTC-08:00

恢复接口为up后, 优先级恢复为120, 但配置了抢占时间100s, 状态仍为backup。

[R1]display vrrpGigabitEthernet0/0/0 | Virtual Router 1State : BackupVirtual IP : 192.168.55.254Master IP : 192.168.55.200PriorityRun : 120PriorityConfig : 120MasterPriority : 100Preempt : YES   Delay Time : 100 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledTrack IF : GigabitEthernet0/0/1   Priority reduced : 30IF state : UPCreate time : 2025-05-11 09:56:45 UTC-08:00Last change time : 2025-05-11 11:05:36 UTC-08:00

断开master左侧

vrrp协议中状态有initial、master、backup三种

左侧

  • master状态变为initial:
[R1]display vrrpGigabitEthernet0/0/0 | Virtual Router 1State : InitializeVirtual IP : 192.168.55.254Master IP : 0.0.0.0PriorityRun : 120PriorityConfig : 120MasterPriority : 0Preempt : YES   Delay Time : 100 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledTrack IF : GigabitEthernet0/0/1   Priority reduced : 30IF state : UPCreate time : 2025-05-11 09:56:45 UTC-08:00Last change time : 2025-05-11 11:12:01 UTC-08:00
  • 原backup上位成master:
[R2]display vrrpGigabitEthernet0/0/0 | Virtual Router 1State : MasterVirtual IP : 192.168.55.254Master IP : 192.168.55.200PriorityRun : 100PriorityConfig : 100MasterPriority : 100Preempt : 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-11 09:59:27 UTC-08:00Last change time : 2025-05-11 11:12:05 UTC-08:00

优化

正常连接时只有master链路使用,网络利用率不高。可在内网通过划分vlan配置不同业务,在路由配置子接口接收不同业务,将对应业务的子接口配置到一个vrrp组。通过设置不同业务的vrrp组master到不同路由器实现负载均衡。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com