华为eNSP配置VRRP协议实验
虚拟路由冗余协议(Virtual Router Redundancy Protocol,简称VRRP)是由IETF提出的解决局域网中配置静态网关出现单点失效现象的路由协议,是一种选择、容错、备份的路由协议,本次实验主要展现其特性。
操作方法
- 01
一、搭建本次实验的拓扑结构 五台路由器、两台交换机 R1-R5,S1-S2,R4、R5模拟电脑,S1、S2只是做透明转发
- 02
二、配置所有设备的接口信息 [R1]interface loopback 0[R1-LoopBack0]ip address 1.1.1.1 32[R1-LoopBack0]quit[R1]interface GigabitEthernet 0/0/0 [R1-GigabitEthernet0/0/0]ip address 10.0.123.1 24<Huawei>system-view Enter system view, return user view with Ctrl+Z.[Huawei]sysname R2[R2]interface GigabitEthernet 0/0/0[R2-GigabitEthernet0/0/0]ip address 10.0.123.2 24[R2-GigabitEthernet0/0/0]quit[R2]interface GigabitEthernet 0/0/1[R2-GigabitEthernet0/0/1]ip address 192.168.1.2 24<Huawei>system-view Enter system view, return user view with Ctrl+Z.[Huawei]sysname R3[R3]interface GigabitEthernet 0/0/0[R3-GigabitEthernet0/0/0]ip address 10.0.123.3 24[R3-GigabitEthernet0/0/0]quit[R3]interface GigabitEthernet 0/0/1[R3-GigabitEthernet0/0/1]ip address 192.168.1.3 24<Huawei>system-view Enter system view, return user view with Ctrl+Z.[Huawei]sysname R4[R4]interface GigabitEthernet 0/0/1[R4-GigabitEthernet0/0/1]ip address 192.168.1.4 24 [Huawei]sysname R5[R5]interface GigabitEthernet 0/0/1[R5-GigabitEthernet0/0/1]ip address 192.168.1.5 24
- 03
三、观察此时区域内的网络连通性 <R2>ping -c 1 192.168.1.3 PING 192.168.1.3: 56 data bytes, press CTRL_C to break Reply from 192.168.1.3: bytes=56 Sequence=1 ttl=255 time=100 ms --- 192.168.1.3 ping statistics --- 1 packet(s) transmitted 1 packet(s) received 0.00% packet loss round-trip min/avg/max = 100/100/100 ms <R2>ping -c 1 192.168.1.4 PING 192.168.1.4: 56 data bytes, press CTRL_C to break Reply from 192.168.1.4: bytes=56 Sequence=1 ttl=255 time=30 ms --- 192.168.1.4 ping statistics --- 1 packet(s) transmitted 1 packet(s) received 0.00% packet loss round-trip min/avg/max = 30/30/30 ms <R2>ping -c 1 192.168.1.5 PING 192.168.1.5: 56 data bytes, press CTRL_C to break Reply from 192.168.1.5: bytes=56 Sequence=1 ttl=255 time=30 ms --- 192.168.1.5 ping statistics --- 1 packet(s) transmitted 1 packet(s) received 0.00% packet loss
- 04
四、配置OSPF和静态路由协议 [R1]ospf 1 [R1-ospf-1]area 0[R1-ospf-1-area-0.0.0.0]network 10.0.123.0 0.0.0.255[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0[R2]ospf 1[R2-ospf-1]silent-interface GigabitEthernet 0/0/1[R2-ospf-1]area 0[R2-ospf-1-area-0.0.0.0]network 10.0.123.0 0.0.0.255[R2-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255[R3]ospf 1[R3-ospf-1]silent-interface GigabitEthernet 0/0/1[R3-ospf-1]area 0[R3-ospf-1-area-0.0.0.0]network 10.0.123.0 0.0.0.255[R3-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255[R4]ip route-static 0.0.0.0 0.0.0.0 192.168.1.1[R5]ip route-static 0.0.0.0 0.0.0.0 192.168.1.1
- 05
五、配置VRRP组和虚拟地址 [R2]interface GigabitEthernet 0/0/1[R2-GigabitEthernet0/0/1]vrrp vrid 1 virtual-ip 192.168.1.1 [R3]interface GigabitEthernet 0/0/1[R3-GigabitEthernet0/0/1]vrrp vrid 1 virtual-ip 192.168.1.1 配置完成后,此时若先开启R2的设备,R2变成master,R3变成slave,反之则是R3优先于R2
- 06
六、配置VRRP优先级,验证主备切换 [R2]interface GigabitEthernet 0/0/1[R2-GigabitEthernet0/0/1]vrrp vrid 1 priority 120 [R3]interface GigabitEthernet 0/0/1[R3-GigabitEthernet0/0/1]vrrp vrid 1 priority 110 优先级数值越大,优先级越高 切换验证: 关闭R2的G0/0/1端口,从R4上ping1.1.1.1
- 07
七、配置跟踪上行链路的特性 [R2]interface GigabitEthernet 0/0/1[R2-GigabitEthernet0/0/1]undo shutdown[R2-GigabitEthernet0/0/1]vrrp vrid 1 track interface GigabitEthernet 0/0/0 reduced 30 配置上行接口跟踪,设置惩戒值为30,当链路失效时,将优先级下降30,低于R3的优先级 [R2]interface GigabitEthernet 0/0/1[R2-GigabitEthernet0/0/1]vrrp vrid 1 preempt-mode timer delay 10 当链路恢复的时候,由于OSPF的收敛延时,此时配置回切的抢占延时提高运行效率
- 08
八、配置VRRP多组负载均衡 [R2]interface GigabitEthernet 0/0/1[R2-GigabitEthernet0/0/1]vrrp vrid 2 virtual-ip 192.168.1.254[R2-GigabitEthernet0/0/1]vrrp vrid 2 priority 110[R3]interface GigabitEthernet 0/0/1[R3-GigabitEthernet0/0/1]vrrp vrid 2 virtual-ip 192.168.1.254[R3-GigabitEthernet0/0/1]vrrp vrid 2 priority 120[R3-GigabitEthernet0/0/1]vrrp vrid 2 track interface GigabitEthernet0/0/0 reduced 30[R5]undo ip route-static 0.0.0.0 0.0.0.0 192.168.1.1 [R5]ip route-static 0.0.0.0 0.0.0.0 192.168.1.254
- 09
九、验证负载均衡 1、验证上行链路失效后的切换 关闭R2的G0/0/0端口 2、观察切换后的VRRP状态 根据图示看出R2的状态变成备份状态,R3切换后成为主链路