华为配置VRRP负载分担示例

组网需求

如图1所示,HostA和HostC通过Switch双归属到SwitchA和SwitchB。为减轻SwitchA上数据流量的承载压力,HostA以SwitchA为默认网关接入Internet,SwitchB作为备份网关;HostC以SwitchB为默认网关接入Internet,SwitchA作为备份网关,以实现流量的负载均衡。

说明

请确保该场景下互联接口的STP处于未使能状态。同时将互连接口退出VLAN1,避免形成环路。因为在使能STP的环形网络中,如果用交换机的VLANIF接口构建三层网络,会导致某个端口被阻塞,从而导致三层业务不能正常运行。

配置思路

采用VRRP负载分担实现流量的负载均衡,配置思路如下:

  1. 配置各设备接口IP地址及路由协议,使各设备间网络层连通。
  2. 在SwitchA和SwitchB上创建VRRP备份组1和VRRP备份组2,在备份组1中,配置SwitchA为Master设备,SwitchB为Backup设备;在备份组2中,配置SwitchB为Master设备,SwitchA为Backup设备,实现流量的负载均衡。

操作步骤

配置设备间的网络互连

# 配置设备各接口的IP地址,以SwitchA为例。SwitchB和SwitchC的配置与SwitchA类似

[zhonwanghzhi]interface GigabitEthernet 0/0/1
[zhonwanghzhi-GigabitEthernet0/0/1]port link-type hybrid 
[zhonwanghzhi-GigabitEthernet0/0/1]port hybrid pvid vlan 300
[zhonwanghzhi-GigabitEthernet0/0/1]port hybrid untagged vlan 300
[zhonwanghzhi-GigabitEthernet0/0/1]quit
[zhonwanghzhi]interface GigabitEthernet 0/0/2
[zhonwanghzhi-GigabitEthernet0/0/2]port link-type 
[zhonwanghzhi-port-group-link-type]quit
[zhonwanghzhi]interface GigabitEthernet 0/0/2	
[zhonwanghzhi-GigabitEthernet0/0/2]port link-type hybrid 
[zhonwanghzhi-GigabitEthernet0/0/2]port hybrid pvid vlan 100
[zhonwanghzhi-GigabitEthernet0/0/2]port hybrid untagged vlan 100
[zhonwanghzhi-GigabitEthernet0/0/2]quit
[zhonwanghzhi]
[zhonwanghzhi]interface Vlanif 100
[zhonwanghzhi-Vlanif100]ip address 10.1.1.1 24
[zhonwanghzhi-Vlanif100]quit
[zhonwanghzhi]interface Vlanif 300
[zhonwanghzhi-Vlanif300]ip address 192.168.1.1 24
[zhonwanghzhi-Vlanif300]quit
[zhonwanghzhi]

# 配置Switch的二层转发功能。


[zhongwanzhi]interface GigabitEthernet 0/0/1
[zhongwanzhi-GigabitEthernet0/0/1]port link-type hybrid 
[zhongwanzhi-GigabitEthernet0/0/1]port hybrid pvid vlan 100
[zhongwanzhi-GigabitEthernet0/0/1]port hybrid untagged vlan 100
[zhongwanzhi-GigabitEthernet0/0/1]quit
[zhongwanzhi]interface GigabitEthernet 0/0/2
[zhongwanzhi-GigabitEthernet0/0/2]port link-type hybrid 
[zhongwanzhi-GigabitEthernet0/0/2]port hybrid pvid vlan 100
[zhongwanzhi-GigabitEthernet0/0/2]port hybrid untagged vlan 100
[zhongwanzhi-GigabitEthernet0/0/2]quit
[zhongwanzhi]

# 配置SwitchA、SwitchB和SwitchC间采用OSPF协议进行互连。以SwitchA为例,SwitchB和SwitchC的配置与SwitchA类似

[zhonwanghzhi]ospf 1
[zhonwanghzhi-ospf-1]area 0
[zhonwanghzhi-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[zhonwanghzhi-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[zhonwanghzhi-ospf-1-area-0.0.0.0]quit
[zhonwanghzhi-ospf-1]quit

配置VRRP备份组

# 在SwitchA和SwitchB上创建VRRP备份组1,配置SwitchA的优先级为120,抢占延时为20秒,作为Master设备;SwitchB的优先级为缺省值,作为Backup设备。

SwitchA

[zhongwanzhi]interface Vlanif 100	
[zhongwanzhi-Vlanif100]vrrp vrid 1 virtual-ip 10.1.1.111
[zhongwanzhi-Vlanif100]vrrp vrid 1 priority 120
[zhongwanzhi-Vlanif100]vrrp vrid 1 preempt-mode timer delay 20
[zhongwanzhi-Vlanif100]quit

SwitchB

[zhonwanghzhib]interface Vlanif 100
[zhonwanghzhib-Vlanif100]vrrp vrid 1 virtual-ip 10.1.1.111
[zhonwanghzhib-Vlanif100]quit

# 在SwitchA和SwitchB上创建VRRP备份组2,配置SwitchB的优先级为120,抢占延时为20秒,作为Master设备;SwitchA的优先级为缺省值,作为Backup设备。

SwitchA

[zhonwanghzhi]interface Vlanif 100
[zhonwanghzhi-Vlanif100]vrrp vrid 2 virtual-ip 10.1.1.112
[zhonwanghzhi-Vlanif100]vrrp vrid 2 priority 120	
[zhonwanghzhi-Vlanif100]vrrp vrid 2 preempt-mode timer delay 20
[zhonwanghzhi-Vlanif100]quit

SwitchB

[zhonwanghzhib]interface Vlanif 100
[zhonwanghzhib-Vlanif100]vrrp vrid 1 virtual-ip 10.1.2.112
[zhonwanghzhib-Vlanif100]quit

验证配置结果

# 完成上述配置后,在SwitchA上执行display vrrp命令,可以看到SwitchA在备份组1中作为Master设备,在备份组2中作为Backup设备。

<zhonwanghzhi>display vrrp
  Vlanif100 | Virtual Router 1
    State : Master
    Virtual IP : 10.1.1.111
    Master IP : 10.1.1.1
    PriorityRun : 100
    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
    Create time : 2023-12-15 16:49:27 UTC-08:00
    Last change time : 2023-12-15 16:49:30 UTC-08:00

  Vlanif100 | Virtual Router 2
    State : 
    Virtual IP : 10.1.1.112
    Master IP : 10.1.1.2
    PriorityRun : 110
    PriorityConfig : 110
    MasterPriority : 110
    Preempt : YES   Delay Time : 20 s
    TimerRun : 1 s
    TimerConfig : 1 s
    Auth type : NONE
    Virtual MAC : 0000-5e00-0102
    Check TTL : YES
    Config type : normal-vrrp
    Create time : 2023-12-15 16:56:51 UTC-08:00
    Last change time : 2023-12-15 16:56:55 UTC-08:00

相关推荐

  1. 华为-配置OSPF负载分担实验

    2023-12-16 06:02:01       31 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-16 06:02:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-16 06:02:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-16 06:02:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-16 06:02:01       18 阅读

热门阅读

  1. 二进制to十六进制

    2023-12-16 06:02:01       42 阅读
  2. 密码管理器:方便与安全并存的选择

    2023-12-16 06:02:01       39 阅读
  3. 抓取网页姓和名,生成假数据

    2023-12-16 06:02:01       43 阅读
  4. Elasticsearch磁盘占用大于95%时将所有索引置为只读

    2023-12-16 06:02:01       42 阅读
  5. go-zero开发入门之gateway深入研究1

    2023-12-16 06:02:01       34 阅读
  6. lua安装

    lua安装

    2023-12-16 06:02:01      44 阅读
  7. Vue中实现分布式动态路由的基本实现步骤介绍

    2023-12-16 06:02:01       36 阅读
  8. RabbitMQ 命令

    2023-12-16 06:02:01       44 阅读
  9. Python录制和绘制音频

    2023-12-16 06:02:01       45 阅读