网络实验-VRRP

VRRP协议简述

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

实验目的

了解VRRP配置

网络拓扑

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

配置内容

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

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

VRRP配置

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

master
复制代码
#
interface GigabitEthernet0/0/0
 ip 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
 # 跟踪右侧接口,右侧接口故障后降低优先级,成为backup
 vrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 30
#
interface GigabitEthernet0/0/1
 ip address 10.20.30.50 255.255.255.0 
backup
复制代码
#
interface GigabitEthernet0/0/0
 ip address 192.168.55.200 255.255.255.0 
 vrrp vrid 1 virtual-ip 192.168.55.254
#
interface GigabitEthernet0/0/1
 ip address 10.30.40.60 255.255.255.0 

RIP

在三个路由器上配置。

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

可靠性验证

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

断开master右侧

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

复制代码
[R1]display vrrp
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Backup
    Virtual IP : 192.168.55.254
    Master IP : 192.168.55.200
    PriorityRun : 90
    PriorityConfig : 120
    MasterPriority : 100
    Preempt : YES   Delay Time : 100 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 IF : GigabitEthernet0/0/1   Priority reduced : 30
    IF state : DOWN
    Create time : 2025-05-11 09:56:45 UTC-08:00
    Last change time : 2025-05-11 11:05:36 UTC-08:00

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

复制代码
[R1]display vrrp
  GigabitEthernet0/0/0 | Virtual Router 1
    State : Backup
    Virtual IP : 192.168.55.254
    Master IP : 192.168.55.200
    PriorityRun : 120
    PriorityConfig : 120
    MasterPriority : 100
    Preempt : YES   Delay Time : 100 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 IF : GigabitEthernet0/0/1   Priority reduced : 30
    IF state : UP
    Create time : 2025-05-11 09:56:45 UTC-08:00
    Last change time : 2025-05-11 11:05:36 UTC-08:00

断开master左侧

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

  • master状态变为initial:

    [R1]display vrrp
    GigabitEthernet0/0/0 | Virtual Router 1
    State : Initialize
    Virtual IP : 192.168.55.254
    Master IP : 0.0.0.0
    PriorityRun : 120
    PriorityConfig : 120
    MasterPriority : 0
    Preempt : YES Delay Time : 100 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 IF : GigabitEthernet0/0/1 Priority reduced : 30
    IF state : UP
    Create time : 2025-05-11 09:56:45 UTC-08:00
    Last change time : 2025-05-11 11:12:01 UTC-08:00

  • 原backup上位成master:

    [R2]display vrrp
    GigabitEthernet0/0/0 | Virtual Router 1
    State : Master
    Virtual IP : 192.168.55.254
    Master IP : 192.168.55.200
    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-11 09:59:27 UTC-08:00
    Last change time : 2025-05-11 11:12:05 UTC-08:00

优化

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

相关推荐
24zhgjx-fuhao2 小时前
HTTP的配置
网络·网络协议·http
安卓开发者3 小时前
第14讲:HTTP网络请求 - Dio库的使用与封装
网络·网络协议·http
报错小能手3 小时前
计算机网络自顶向下方法33——网络层 路由器工作原理 输入端口处理和基于目的地转发 交换 输出端口处理
网络·计算机网络·智能路由器
scd02084 小时前
11.10dns作业
运维·服务器·网络
Yurko135 小时前
【计网】基于三层交换机和 RIP 协议的局域网组建
网络·学习·计算机网络·智能路由器
无序的浪5 小时前
网络初识~
网络
wzlsunice885 小时前
用vir-manager创建kvm虚拟机(创建网桥和配置网络等)
运维·网络
思茂信息6 小时前
CST License(Flexnet)设置与问题处理方法
服务器·网络·单片机·3d·php·1024程序员节·cst
m0_738120726 小时前
内网横向靶场——记录一次横向渗透(三)
开发语言·网络·安全·web安全·网络安全·php
Jerry2505097 小时前
微信小程序必要要安装SSL证书吗?小程序SSL详解
网络·网络协议·网络安全·微信小程序·小程序·https·ssl