1.1 问题
配置接口IP地址
如图配置VRRP虚拟网关和优先级
验证每个网关的状态
1.2 方案
搭建实验环境,如图-1所示。
图-1
1.3 步骤
实现此案例需要按照如下步骤进行。
1)配置终端设备 PC1
PC1 IP 地址: 192.168.1.1255.255.255.0192.168.1.254 //后期通过 VRRP 形成的 虚拟网关IP
2)配置 SW1
system-view //进入系统视图
[Huawei]sysname SW1 //修改设备名称为 SW1
[SW1] vlan 10 //创建 vlan 10
[SW1-vlan10]quit
[SW1]interface GigabitEthernet 0/0/1 //SW1 与 R1 的互联接口
[SW1-GigabitEthernet0/0/1]port link-type access //配置链路类型为 access
[SW1-GigabitEthernet0/0/1]port default vlan 10 //将端口加入 vlan 10
[SW1-GigabitEthernet0/0/1]quit
[SW1]interface gi0/0/2 //SW1 与 R2 的互联接口
[SW1-GigabitEthernet0/0/2]port link-type access //配置链路类型为 access
[SW1-GigabitEthernet0/0/2]port default vlan 10 //将端口加入 vlan 10
[SW1-GigabitEthernet0/0/2]quit
[SW1]interface gi0/0/3 //SW1 与 PC1 的互联接口
[SW1-GigabitEthernet0/0/3]port link-type access //配置链路类型为 access
[SW1-GigabitEthernet0/0/3]port default vlan 10 //将端口加入 vlan 10
[SW1-GigabitEthernet0/0/3]quit
3)配置R1
system-view
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0 //R1与SW1 的互联接口
[R1-GigabitEthernet0/0/0]ip address 192.168.1.251 24
[R1-GigabitEthernet0/0/0]quit
4)配置R2
system-view
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/0 //R2与SW1 的互联接口
[R2-GigabitEthernet0/0/0]ip address 192.168.1.252 24
[R2-GigabitEthernet0/0/0]quit
5)配置R1 的 VRRP
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.254 //设置虚拟网关
[R1-GigabitEthernet0/0/0]vrrp vrid 1 priority 200 //设置 VRRP 优先级为 200
6)配置 R2 的 VRRP
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.254 //设置虚拟网关
7)查看VRRP信息
[R1]display vrrp brief //查看 R1 在 VRRP 中的状态,是主(Master)网关
Total:1 Master:1 Backup:0 Non-active:0
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Master GE0/0/0 Normal 192.168.1.254
[R2]display vrrp brief //查看 R2 在 VRRP 中的状态,是备份(Backup)网关
Total:1 Master:0 Backup:1 Non-active:0
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Backup GE0/0/0 Normal 192.168.1.254
8)测试终端与网关的连通性
PC1:Ping 192.168.1.254 -t //PC1 访问自己的网关- 可以访问成功,数据包发向主网关 R1 (在R1上抓包可以验证)- 断开 R1 的 Gi0/0/0 接口,依然可以访问成功;数据包发向网关 R2- R1 的 Gi0/0/0 接口修复成功,数据包再次发向网关 R1