前言:

VRRP虚拟路由冗余协议对共享多存取访问介质(如以太网)上终端IP设备的默认网关(Default Gateway)进行冗余备份,从而在其中一台路由设备宕机时,备份路由设备及时接管转发工作,向用户提供透明的切换,提高网络服务质量,无疑提出了了一个很好的解决方案。

实验环境:

这里我们用一台华为s3526交换机模拟INTERNET   两个防火墙  两台Quidway S2403H-HI交换机作为局域网连接设备

实验目的:

设置VRRP实现链路的互相备份  

vlan 10的电脑都从1.1.1.1访问INTERNET,当1.1.1.1网络断掉的时候从2.2.2.1访问INTERNET

Vlan 20的电脑都从2.2.2.1访问INTERNET,当2.2.2.1网络断掉的时候从1.1.1.1访问INTERNET

wps_clip_image-10223

一.基本接口配置

s3526交换机的配置

<H3C>system-view

[H3C]sysname isp

配置接口ip地址

[isp]int eth0/0

[isp-Ethernet0/0]ip add 1.1.1.1 24

[isp-Ethernet0/0]int eth0/4

[isp-Ethernet0/4]ip add 2.2.2.1 24

添加区域

[isp-Ethernet0/4]quit

[isp]firewall zone untrust 开启非信任区域

[isp-zone-untrust]add interface eth0/4 把接口添加到区域

[isp]firewall zone trust  开启信任区域

[isp-zone-trust]add interface eth0/0把接口添加到区域

[isp]interface LoopBack1 因为是试验环境,并没有连接到INTERNET,把广域网接口配成loopback

[isp-LoopBack1]ip add 3.3.3.3 24

<isp>dis ip routing-table

wps_clip_image-9861

fw1的配置

<H3C>system-view

[H3C]sysname fw1

[fw1]undo insulate  取消端口隔离

接口ip地址配置

[fw1]int eth0/4

[fw1-Ethernet0/4]ip add 1.1.1.2 24

[fw1-Ethernet0/4]int eth0/0

[fw1-Ethernet0/0]undo ip address (eth0/0取消ip)

[fw1-Ethernet0/0]quit

[fw1]int eth0/0.10 拆分子接口

[fw1-Ethernet0/0.10]vlan-type dot1q vid 10 打标签

[fw1-Ethernet0/0.10]ip add 192.168.10.1 24

[fw1-Ethernet0/0.10]qu

[fw1]int eth0/0.20        

[fw1-Ethernet0/0.20]vlan-type dot1q vid 20 打标签

[fw1-Ethernet0/0.20]ip add 192.168.20.1 24

[fw1-Ethernet0/0.20]qu

[fw1]firewall zone trust 开启信任区域

[fw1-zone-trust]add interface Ethernet 0/0.10 添加接口到区域

[fw1-zone-trust]add interface Ethernet 0/0.20 添加接口到区域

[fw1-zone-trust]quit

[fw1]firewall zone untrust  开启一个非信任区域

[fw1-zone-untrust]add interface eth0/4 添加子接口到区域

[fw1]ping 1.1.1.1

wps_clip_image-15566

[fw1]ip route-static 0.0.0.0 0 1.1.1.1 设置外网默认路由

设置动态nat

[fw1]acl number 2000   创建访问控制列表

[fw1-acl-basic-2000]rule 10 permit source any

[fw1-acl-basic-2000]qu

[fw1]interface eth0/4

[fw1-Ethernet0/4]nat outbound

[fw1-Ethernet0/4]nat outbound 2000

fw2的配置:

<H3C>system-view

[H3C]sysname fw2

[fw2]undo insulate 取消端口隔离

配置接口ip地址

[fw2]interface eth0/4

[fw2-Ethernet0/4]ip add 2.2.2.2 24

[fw2-Ethernet0/4]int eth0/0

[fw2-Ethernet0/0]undo ip address

拆分子接口

[fw2-Ethernet0/0]int eth0/0.10

[fw2-Ethernet0/0.10]vlan-type dot1q vid 10 打标签

[fw2-Ethernet0/0.10]ip add 192.168.10.2 24

[fw2-Ethernet0/0.10]int eth0/0.20        

[fw2-Ethernet0/0.20]vlan-type dot1q vid 20 打标签

[fw2-Ethernet0/0.20]ip add 192.168.20.2 24

[fw2-Ethernet0/0.20]quit

添加区域

[fw2]firewall zone untrust 开启非信任区域

[fw2-zone-untrust]add interface eth0/4 添加接口到区域

[fw2-zone-untrust]quit

[fw2]firewall zone trust  开启信任区域

[fw2-zone-trust]add interface eth0/0.10 添加接口到区域

[fw2-zone-trust]add interface eth0/0.20 添加接口到区域

<fw2>dis ip routing-table

wps_clip_image-15559

<fw2>system-view

[fw2]ip route-static 0.0.0.0 0 2.2.2.1 配置外网默认路由

[fw2]ping 2.2.2.1   测试与外网的连通性

wps_clip_image-18832

配置nat

[fw2]acl number 2000 设置访问控制列表

[fw2-acl-basic-2000]rule 10 permit source any 设置规则

[fw2-acl-basic-2000]int eth0/4

[fw2-Ethernet0/4]nat outbound 2000

SW1的配置

<Quidway>system-view

[Quidway]sysname sw1

[sw1]stp enable  启动生成树协议

划分vlan并添加接口到vlan

[sw1]vlan 10

[sw1-vlan10]port e1/0/10

[sw1-vlan10]vlan 20

[sw1-vlan20]port e1/0/20

设置trunk链路

[sw1-vlan20]int e1/0/24

[sw1-Ethernet1/0/24]port link-type trunk 设置链路类型为trunk

[sw1-Ethernet1/0/24]port trunk permit vlan all 语序所有vlan通过

[sw1-Ethernet1/0/24]int e1/0/1               

[sw1-Ethernet1/0/1]port link-type trunk      设置链路类型为trunk

[sw1-Ethernet1/0/1]port trunk permit vlan all 允许所有vlan通过

[sw1-Ethernet1/0/1]int e1/0/2

[sw1-Ethernet1/0/2]port link-type trunk      设置链路类型为trunk

[sw1-Ethernet1/0/2]port trunk permit vlan all 允许所有vlan通过

[sw1-Ethernet1/0/2]quit

设置链路聚合

[sw1]link-aggregation group 1 mode manual  设置链路聚合组方式手工

[sw1]int e1/0/1

[sw1-Ethernet1/0/1]port link-aggregation group 1 把e1/0/1加入聚合组1

[sw1-Ethernet1/0/1]int e1/0/2                     

[sw1-Ethernet1/0/2]port link-aggregation group 1 把e1/0/2加入聚合组1

查看聚合状态

[sw1-Ethernet1/0/2]dis link-aggregation verbose

wps_clip_image-15750

[sw1-Ethernet1/0/2]dis stp brief

此时不显示e1/0/2口了,因为链路聚合之后e1/0/1和e1/0/2被认为是一条链路

wps_clip_image-4452

sw2的配置:

<Quidway>system-view

[Quidway]sysname sw2

[sw2]stp enable  启动生成树协议

创建vlan并把接口添加到vlan

[sw2]vlan 10

[sw2-vlan10]port e1/0/10

[sw2-vlan10]vlan 20

[sw2-vlan20]port e1/0/20

[sw2-vlan20]int e1/0/24

[sw2-Ethernet1/0/24]port link-type trunk  设置链路类型为trunk

[sw2-Ethernet1/0/24]port trunk permit vlan all 允许所有vlan通过

[sw2-Ethernet1/0/24]int e1/0/1

[sw2-Ethernet1/0/1]port link-type trunk  设置链路类型为trunk

[sw2-Ethernet1/0/1]port trunk permit vlan all 允许所有vlan通过

[sw2-Ethernet1/0/1]int e1/0/2               

[sw2-Ethernet1/0/2]port link-type trunk    设置链路类型为trunk

[sw2-Ethernet1/0/2]port trunk permit vlan all 允许所有vlan通过

[sw2-Ethernet1/0/2]quit

[sw2]link-aggregation group 1 mode manual   设置链路聚合组方式手工

[sw2]int e1/0/1

[sw2-Ethernet1/0/1]port link-aggregation group 1  把e1/0/1加入聚合组1

[sw2-Ethernet1/0/1]int e1/0/2                  

[sw2-Ethernet1/0/2]port link-aggregation group 1 把e1/0/2加入聚合组1

[sw2-Ethernet1/0/2]dis link-aggregation verbose 查看链路聚合状态

wps_clip_image-19065

[sw2-Ethernet1/0/2]dis stp brief

wps_clip_image-30043

测试连通性

wps_clip_image-21952

wps_clip_image-10020

二.设置vrrp备份

fw2的VRRP配置

[fw2]vrrp ping-enable  可以让你ping通虚拟ip(不配置也不影响正常通信)

[fw2]int eth0/0.10

[fw2-Ethernet0/0.10]vrrp vrid 10 virtual-ip 192.168.10.254   编号为10组的虚拟ip

wps_clip_image-23088

[fw2-Ethernet0/0.10]int eth0/0.20

[fw2-Ethernet0/0.20]vrrp vrid 20 virtual-ip 192.168.20.254  编号为20组的虚拟ip

wps_clip_image-3733

[fw2-Ethernet0/0.20]vrrp vrid 20 priority 120 设置优先级

[fw2-Ethernet0/0.20]vrrp vrid 20 track eth0/4 reduced 30 跟踪eth0/4,当eth0/4变化的时候vrid为20的组优先级减少30(120-30<fw1的优先级100)

[fw2]dis vrrp

wps_clip_image-32567

fw1的VRRP配置

[fw1]vrrp ping-enable  可以让你ping通虚拟ip(不配置也不影响正常通信)

[fw1]int eth0/0.10

[fw1-Ethernet0/0.10]vrrp vrid 10 virtual-ip 192.168.10.254 编号为10组的虚拟ip

[fw1-Ethernet0/0.10]vrrp vrid 10 priority 120   设置优先级

[fw1-Ethernet0/0.10]vrrp vrid 10 track eth0/4 reduced 30 跟踪eth0/4,当eth0/4变化的时候vrid为20的组优先级减少30

[fw1-Ethernet0/0.10]int eth0/0.20

[fw1-Ethernet0/0.20]vrrp vrid  20 virtual-ip 192.168.20.254  编号为20组的虚拟ip

[fw1-Ethernet0/0.20]dis vrrp

wps_clip_image-24722

三.测试

这里用一台交换机模拟pc进行测试

<Quidway>system-view

[Quidway]sysname pc20

[pc20]int Vlan-interface 1

[pc20-Vlan-interface1]ip add 192.168.20.100 255.255.255.0配置ip地址

[pc20-Vlan-interface1]quit

[pc20]ip route-static 0.0.0.0 0 192.168.20.254

[pc20]ping 192.168.20.254 (ping虚拟网关通行正常)

wps_clip_image-19627

[pc20]ping 3.3.3.3 (说明外网连接正常)

wps_clip_image-6674

[pc20]tracert 3.3.3.3(监控连接外网的路径)

wps_clip_image-30269

Pc10设置

<Quidway>system-view

[Quidway]sysname pc 10

[pc 10]int Vlan-interface 1

[pc 10-Vlan-interface1]ip add 192.168.10.100 255.255.255.0

[pc 10]ip route-static 0.0.0.0 0 192.168.10.254

[pc 10]ping 192.168.10.254

wps_clip_image-26697

[pc 10]ping 3.3.3.3  

wps_clip_image-17264

[pc 10]tracert 3.3.3.3

wps_clip_image-3915

[pc 10]ping -c 20000 192.168.20.100(扩展的ping,表示ping192.168.20.100   20000次

)

当fw1上的e0/0断掉的时候

wps_clip_image-56

丢了两次包然后马上又连上了

当fw2上的e0/0断掉的时候

wps_clip_image-10917

同样丢了两次包然后马上又连上了

当fw2上的e0/0断掉的时候

[pc 10]ping 3.3.3.3

wps_clip_image-949

[pc 10]tracert 3.3.3.3

wps_clip_image-10227

[pc 10]ping -c 5000 3.3.3.3

当fw1的e0/4断掉的时候

wps_clip_image-20609

wps_clip_image-662

丢包后自动连上

wps_clip_image-6855

此时是从192.168.10.2(既从2.2.2.1出去的)

wps_clip_image-29146

wps_clip_image-19677

wps_clip_image-7564

当fw2的eth0/4断掉的时候情况大致相同。