虚拟路由冗余协议VRRP(Virtual Router Redundancy Protocol)是通过把几台路由设备联合组成一台虚拟的路由设备,将虚拟路由设备的IP地址作为用户的默认网关实现与外部网络通信。当网关设备发生故障时,VRRP机制能够选举新的网关设备承担数据流量,从而保障网络的可靠通信。本文将介绍如何在华为路由器上配置vrrp协议实现网关的冗余。拓扑如下图所示:
具体配置如下:
R1:
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.254 24
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.13.1 24
R2:
[R2-GigabitEthernet0/0/0]ip add
[R2-GigabitEthernet0/0/0]ip address 192.168.1.253 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add
[R2-GigabitEthernet0/0/1]ip address 192.168.23.1 24
R3:
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ip ad
[R3-GigabitEthernet0/0/0]ip address 192.168.13.2 24
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ip ad
[R3-GigabitEthernet0/0/0]ip address 192.168.13.2 24
[R3-LoopBack1]ip address 10.0.0.1 24
R1、R2配置vrrp,并监控g0/0/1:
[R1-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.250
[R1-GigabitEthernet0/0/0]vrrp vrid 1 track interface g0/0/1 reduced 50
[R2-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.250
[R2-GigabitEthernet0/0/0]vrrp vrid 1 track interface g0/0/1 reduced 51
R1、R2、R3配置静态路由,确保全网互通:
[R1]ip route-static 10.0.0.1 255.255.255.0 192.168.13.2
[R2]ip route-static 10.0.0.1 255.255.255.0 192.168.23.2
[R3]ip route-static 192.168.1.0 255.255.255.0 192.168.13.1
[R3]ip route-static 192.168.1.0 255.255.255.0 192.168.23.1
测试:
R1上查看vrrp:
R2上查看vrrp:
在PC上测试:
模拟R2->R3线路故障,将R3的G0/0/0口shutdown,测试路由:
在PC上跟踪路由:
R2上看vrrp:
如上图所示,vrrp自动切换R2为master路由,链路备份成功。