VRRP虚拟路由实现主备设备负载分担
VRRP虚拟路由实现主备设备负载分担
Tips:
- 负载分担实际就是,设置2组冗余路由协议,配置两个虚拟网关,让pc走不同冗余网关,实现负载分担。
- 效果:避免冗余网关的资源浪费。
本次实验模拟vrrp协议配置,实现主备负载均衡
AR1配置如下:
<Huawei>sy
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.2 24 //配置接口ip
[Huawei-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.1 //配置vrrp1,配置虚拟网关ip
[Huawei-GigabitEthernet0/0/0]vrrp vrid 1 priority 120 //配置vrrp1优先级120,默认100越大越优
[Huawei-GigabitEthernet0/0/0]vrrp vrid 1 preempt-mode timer delay 5 //配置vrrp1 延迟抢占 计时器设置5
[Huawei-GigabitEthernet0/0/0]vrrp vrid 1 track interface g0/0/1 reduced 20 //配置跟踪上联端口,减少优先级20
[Huawei-GigabitEthernet0/0/0]vrrp vrid 2 virtual-ip 192.168.1.254 //配置vrrp2,配置虚拟网关ip
[Huawei-GigabitEthernet0/0/0]vrrp vrid 2 priority 110 //配置vrrp 2 优先级设置110
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.2.1 24 //配置端口ip,作为网关ip
AR2配置如下:
<Huawei>sy
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.3 24 //配置接口ip
[Huawei-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.1 //配置vrrp 1 设置虚拟网关ip
[Huawei-GigabitEthernet0/0/0]vrrp vrid 1 priority 110 //配置vrrp 1优先级设置110
[Huawei-GigabitEthernet0/0/0]vrrp vrid 2 virtual-ip 192.168.1.254 //配置vrrp 2,设置虚拟网关ip
[Huawei-GigabitEthernet0/0/0]vrrp vrid 2 priority 120 //配置vrrp 2优先级120
[Huawei-GigabitEthernet0/0/0]vrrp vrid 2 preempt-mode timer delay 5 //配置vrrp 2延迟抢占 计时器参数设置5
[Huawei-GigabitEthernet0/0/0]vrrp vrid 2 track interface g0/0/1 reduced 20 //配置vrrp 2 跟踪上联端口 减少优先级参数20
[Huawei-GigabitEthernet0/0/0]q
[Huawei]dhcp enable //使能dhcp
[Huawei]ip pool hy //创建地址池
[Huawei-ip-pool-hy]network 192.168.1.4 mask 24 //设置地址池分配ip及掩码位数
[Huawei-ip-pool-hy]gateway-list 192.168.1.1 //配置地址池网关ip
[Huawei-ip-pool-hy]gateway-list 192.168.1.254 //配置地址池备用网关ip
[Huawei-ip-pool-hy]dns-list 192.168.1.1 //配置dns
[Huawei-ip-pool-hy]dns-list 192.168.1.254 //配置备用dns
[Huawei-ip-pool-hy]excluded-ip-address 192.168.1.2 //配置不参与分配的ip
[Huawei-ip-pool-hy]excluded-ip-address 192.168.1.3
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select global //接口使能dhcp
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.2.1 24 //配置网关ip
左边AR1上联端口断开对比测试效果如下:流量正常负载,且主设备断开连接正常通信
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]shutdown //关闭端口