1、局域网内的主机通过二层交换机接入两台网关设备Device A和Device B,Device A和Device B构成一台虚拟路由器,为网关提供冗余备份,以提高网关设备的可靠性。这种组网方式虽然可以防止网关的单点故障,但是仍然存在以下问题:不能防御所有的链路故障。例如,链路a和链路c同时发生故障时,局域网内的主机将无法与外界通信。链路a或链路b出现故障时,即使Master正常工作,也会导致Backup接收不到Master发送的VRRP通告报文,从而错误地认为Master出现故障,进行Master和Backup状态切换。则Device B接收不到Device A的通告报文,使得Device B成
2、为Master,流量通过链路b链路c这条路径转发。通过在Device A和Device B之间增加心跳线,避免链路a或链路b出现故障、网关正常工作时错误地进行Master和Backup状态切换。在VRRP与MSTP配合使用的组网方式中,心跳线链路e通常为聚合链路,以提高可靠性。3配置前提本文档不严格与具体软、硬件版本对应,如果使用过程中与产品实际情况有差异,请参考相关产品手册,或以设备实际情况为准。本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。4配置举例4.1组
3、网需求局域网中采用VRRP技术进行网关设备的备份,提高网关的可靠性。当一台网关设备出现故障时,局域网内的主机仍然可以通过另一台网关设备访问外部网络。在网关设备工作正常时,区域A用户通过网关设备Switch A进行数据转发;区域B用户通过网关设备Switch B进行数据转发,实现流量的负载分担。当网关设备的上行链路出现故障时,降低该网关设备的优先级,以避免该网关设备成为Master,导致流量转发中断。局域网内进行二层链路的冗余备份,保证网关设备下行链路故障时,流量转发不会中断。使用MSTP技术避免二层网络中出现环路。网关设备通过核心层的出口设备Switch E与Internet连接。通常情况下,
4、核心层会部署多台出口设备,以提高网络的可靠性。为了简化配置过程,本文仅以一台出口设备为例,说明出口设备的配置方法。多台出口设备时,配置方法与此类似。图1-4VRRP与MSTP综合配置组网图设备接口IP地址Switch AVlan-int10110.1.1.2/24Switch B10.1.1.3/24Vlan-int10210.2.1.2/2410.2.1.3/24Vlan-int1000100.0.0.2/24Vlan-int2000200.0.0.2/24Virtual IP 110.1.1.1/24Virtual IP 210.2.1.1/24Switch E100.0.0.1/2420
5、0.0.0.1/24Vlan-int300030.0.0.1/244.2配置思路实现上述组网需求,需要进行如下配置:Switch A、Switch B上分别创建两个VRRP备份组。配置Switch A在备份组1内具有更高的优先级,即正常情况下Switch A作为备份组1的Master设备;配置Switch B在备份组2内具有更高的优先级,即正常情况下Switch B作为备份组2的Master设备。区域A内的主机将备份组1的虚拟IP地址设置为网关,区域B内的主机将备份组2的虚拟IP地址设置为网关。从而保证在网关设备工作正常时,区域A用户通过网关设备Switch A进行数据转发,区域B用户通过网关
6、设备Switch B进行数据转发,实现流量的负载分担。Switch A、Switch B上分别配置VRRP备份组监视上行接口,当上行接口出现故障时,降低路由器在备份组中的优先级。Switch A、Switch B和二层交换机之间启用MSTP多实例,并在各实例中指定根桥和备份根桥。在Switch A、Switch B和Switch E之间配置OSPF路由协议。Switch A和Switch B通过OSPF发布区域A和区域B所在网段的路由,以实现区域A与区域B内主机与外部网络的三层互通。并在Switch A和Switch B上合理配置路由的Cost值,以便内网访问外网、外网访问内网的双向流量通过同
7、一台设备处理。Switch A和Switch B之间的链路采用聚合链路,以提高心跳线的可靠性。4.3配置步骤4.3.1设备A的配置#配置端口Ethernet1/1属于VLAN 1000、Ethernet1/3属于VLAN 102、Ethernet1/4属于VLAN 101。 system-viewSwitchA vlan1000SwitchA-vlan1000 port ethernet 1/1SwitchA-vlan1000 quitSwitchA vlan 101SwitchA-vlan101 port ethernet 1/4SwitchA-vlan101 quitSwitchA vla
8、n 102SwitchA-vlan102 port ethernet 1/3SwitchA-vlan102 quit创建二层聚合接口1。SwitchA interface bridge-aggregation 1SwitchA-Bridge-Aggregation1 quit分别将端口Ethernet1/2和Ethernet1/5加入到聚合组1中。SwitchA interface ethernet 1/2SwitchA-Ethernet1/2 port link-aggregation group 1SwitchA-Ethernet1/2 quitSwitchA interface ethe
9、rnet 1/5SwitchA-Ethernet1/5 port link-aggregation group 1SwitchA-Ethernet1/5 quit配置二层聚合接口1为Trunk端口,并允许VLAN 101和102的报文通过。SwitchA-Bridge-Aggregation1 port link-type trunkSwitchA-Bridge-Aggregation1 port trunk permit vlan 101 to 102SwitchA-Bridge-Aggregation1 undo port trunk permit vlan 1SwitchA-Bridge
10、-Aggregation1 port trunk pvid vlan 101配置上行接口IP地址。SwitchA interface vlan-interface 1000SwitchA-Vlan-interface1000 ip address 100.0.0.2 24SwitchA-Vlan-interface1000 quit创建Track项1,监视上行接口的物理状态。SwitchA track 1 interface vlan-interface 1000创建VRRP备份组1,配置Switch A在备份组1中的优先级为110。SwitchA interface vlan-interfa
11、ce 101SwitchA-Vlan-interface101 ip address 10.1.1.2 24SwitchA-Vlan-interface101 vrrp vrid 1 virtual-ip 10.1.1.1SwitchA-Vlan-interface101 vrrp vrid 1 priority 110配置VRRP备份组1监视Track项1的状态。当Track项状态为Negative(即上行接口的物理状态为down)时,Switch A在备份组1的优先级降低20,使得Switch B的优先级高于Switch A,Switch B成为Master。SwitchA-Vlan-in
12、terface101 vrrp vrid 1 track 1 reduced 20SwitchA-Vlan-interface101 quit创建VRRP备份组2。SwitchA interface vlan-interface 102SwitchA-Vlan-interface102 ip address 10.2.1.2 24SwitchA-Vlan-interface102 vrrp vrid 1 virtual-ip 10.2.1.1SwitchAVlan-interface102 quit配置MSTP。SwitchA stp region-configurationSwitchA-m
13、st-region region-name vrrpSwitchA-mst-region instance 1 vlan 101SwitchA-mst-region instance 2 vlan 102SwitchA-mst-region active region-configurationSwitchA-mst-region quitSwitchA stp instance 1 root primarySwitchA stp instance 2 root secondarySwitchA stp enable在上行接口上关闭STP功能。SwitchA interface etherne
14、t 1/1SwitchA-Ethernet1/1 undo stp enableSwitchA-Ethernet1/1 quit配置OSPF发布网段路由。SwitchA ospfSwitchA-ospf-1 area 0SwitchA-ospf-1-area-0.0.0.0 network 100.0.0.0 0.0.0.255SwitchA-ospf-1-area-0.0.0.0 network 10.1.1.0 0.0.0.255SwitchA-ospf-1-area-0.0.0.0 network 10.2.1.0 0.0.0.255SwitchA-ospf-1-area-0.0.0.0
15、 quitSwitchA-ospf-1 quit配置接口Vlan-int102的路由Cost值为5,以便外网访问区域B的报文优先通过Switch B转发。SwitchA-Vlan-interface102 ospf cost 5SwitchA-Vlan-interface102 quit4.3.2设备B的配置配置端口Ethernet1/1属于VLAN 2000、Ethernet1/3属于VLAN 102、Ethernet1/4属于VLAN 101。SwitchBSwitchB vlan 2000SwitchB-vlan2000 port ethernet 1/1SwitchB-vlan2000
16、 quitSwitchB vlan 101SwitchB-vlan101 port ethernet 1/4SwitchB-vlan101 quitSwitchB vlan 102SwitchB-vlan102 port ethernet 1/3SwitchB-vlan102 quitSwitchB interface bridge-aggregation 1SwitchB-Bridge-Aggregation1 quitSwitchB interface ethernet 1/2SwitchB-Ethernet1/2 port link-aggregation group 1SwitchB-
17、Ethernet1/2 quitSwitchB interface ethernet 1/5SwitchB-Ethernet1/5 port link-aggregation group 1SwitchB-Ethernet1/5 quitSwitchB-Bridge-Aggregation1 port link-type trunkSwitchB-Bridge-Aggregation1 port trunk permit vlan 101 to 102SwitchB-Bridge-Aggregation1 undo port trunk permit vlan 1SwitchB-Bridge-
18、Aggregation1 port trunk pvid vlan 101SwitchB interface vlan-interface 2000SwitchB-Vlan-interface2000 ip address 200.0.0.2 24SwitchB-Vlan-interface2000 quitSwitchB track 1 interface vlan-interface 2000创建VRRP备份组1。SwitchB interface vlan-interface 101SwitchB-Vlan-interface101 ip address 10.1.1.3 24Switc
19、hB-Vlan-interface101 vrrp vrid 1 virtual-ip 10.1.1.1SwitchBVlan-interface101 quit创建VRRP备份组2,配置Switch B在备份组2中的优先级为110。SwitchB interface vlan-interface 102SwitchB-Vlan-interface102 ip address 10.2.1.3 24SwitchB-Vlan-interface102 vrrp vrid 1 virtual-ip 10.2.1.1SwitchB-Vlan-interface102 vrrp vrid 1 prio
20、rity 110配置VRRP备份组2监视Track项1的状态。当Track项状态为Negative(即上行接口的物理状态为down)时,Switch B在备份组2的优先级降低20,使得Switch A的优先级高于Switch B,Switch A成为Master。SwitchB-Vlan-interface102 vrrp vrid 1 track 1 reduced 20SwitchB-Vlan-interface102 quitSwitchB stp region-configurationSwitchB-mst-region region-name vrrpSwitchB-mst-reg
21、ion instance 1 vlan 101SwitchB-mst-region instance 2 vlan 102SwitchB-mst-region active region-configurationSwitchB-mst-region quitSwitchB stp instance 2 root primarySwitchB stp instance 1 root secondarySwitchB stp enableSwitchB interface ethernet 1/1SwitchB-Ethernet1/1 undo stp enableSwitchB-Etherne
22、t1/1 quitSwitchB ospfSwitchB-ospf-1 area 0SwitchB-ospf-1-area-0.0.0.0 network 200.0.0.0 0.0.0.255SwitchB-ospf-1-area-0.0.0.0 network 10.1.1.0 0.0.0.255SwitchB-ospf-1-area-0.0.0.0 network 10.2.1.0 0.0.0.255SwitchB-ospf-1-area-0.0.0.0 quitSwitchB-ospf-1 quit配置接口Vlan-int101的路由Cost值为5,以便外网访问区域A的报文优先通过Sw
23、itch A转发。SwitchB-Vlan-interface102 ospf cost 54.3.3设备C的配置配置VLAN 101。SwitchCSwitchC vlan 101SwitchC-vlan101 port ethernet 1/1 to ethernet 1/3SwitchC-vlan101 quitSwitchC stp region-configurationSwitchC-mst-region region-name vrrpSwitchC-mst-region instance 1 vlan 101SwitchC-mst-region instance 2 vlan
24、102SwitchC-mst-region active region-configurationSwitchC-mst-region quitSwitchC stp enable4.3.4设备D的配置配置VLAN 102。SwitchDSwitchD vlan 102SwitchD-vlan102 port ethernet 1/1 to ethernet 1/3SwitchD-vlan102 quitSwitchD stp region-configurationSwitchD-mst-region region-name vrrpSwitchD-mst-region instance 1
25、 vlan 101SwitchD-mst-region instance 2 vlan 102SwitchD-mst-region active region-configurationSwitchD-mst-region quitSwitchD stp enable4.3.5设备E的配置配置VLAN 1000。SwitchESwitchE vlan 1000SwitchE-vlan1000 port ethernet 1/1SwitchE-vlan1000 quit配置接口Vlan-int1000的IP地址。SwitchE interface vlan-interface 1000SwitchE-Vlan-interface1000