拓扑
配置步骤
SW3:
#
sysname SW3
#
vlan 10
description pc4 //PC4网段
#
vlan 20
description pc6 //PC6网段
#
interface GigabitEthernet1/0/19 //配置trunk链路放通业务vlan
port link-mode bridge
port link-type trunk
undo port trunk permit vlan 1
port trunk permit vlan 10 20
#
interface GigabitEthernet1/0/9 //配置trunk链路放通业务vlan
port link-mode bridge
port link-type trunk
undo port trunk permit vlan 1
port trunk permit vlan 10 20
#
interface GigabitEthernet1/0/1 //配置acces接口,放通业务vlan
port link-mode bridge
port access vlan 10
#
interface GigabitEthernet1/0/2 //配置acces接口,放通业务vlan
port link-mode bridge
port access vlan 20
#
SW1:
#
sysname SW1
#
vlan 10
#
vlan 11
#
vlan 20
#
interface GigabitEthernet1/0/1 //在接口上应用vlan虚接口,关闭stp功能
port link-mode bridge
port access vlan 11
combo enable fiber
undo stp enable
#
interface GigabitEthernet1/0/19 / //配置trunk链路放通业务vlan
port link-mode bridge
port link-type trunk
undo port trunk permit vlan 1
port trunk permit vlan 10 20
combo enable fiber
#
interface GigabitEthernet1/0/20 //配置trunk链路放通业务vlan
port link-mode bridge
port link-type trunk
undo port trunk permit vlan 1
port trunk permit vlan 10 20
combo enable fiber
#
SW2:
#
sysname SW2
#
vlan 10
#
vlan 20
#
vlan 21
#
#
interface GigabitEthernet1/0/2 //在接口上应用vlan虚接口,关闭stp功能
port link-mode bridge
port access vlan 21
combo enable fiber
undo stp enable
#
interface GigabitEthernet1/0/9 //配置trunk链路放通业务vlan
port link-mode bridge
port link-type trunk
undo port trunk permit vlan 1
port trunk permit vlan 10 20
combo enable fiber
#
interface GigabitEthernet1/0/20 //配置trunk链路放通业务vlan
port link-mode bridge
port link-type trunk
undo port trunk permit vlan 1
port trunk permit vlan 10 20
combo enable fiber
#
第二步,配置MSTP
SW1、SW2、SW3配置相同:
SW1:
#
stp region-configuration //配置两个实例,并配置激活
region-name h3c
instance 1 vlan 10
instance 2 vlan 20
active region-configuration
#
SW2:
#
stp region-configuration //配置两个实例,并配置激活
region-name h3c
instance 1 vlan 10
instance 2 vlan 20
active region-configuration
#
SW3:
#
stp region-configuration //配置两个实例,并配置激活
region-name h3c
instance 1 vlan 10
instance 2 vlan 20
active region-configuration
#
B、主备根
Sw1:
#
stp instance 0 to 1 root primary //sw1实例1为主根
stp instance 2 root secondary //sw1实例2为备根
stp global enable
#
SW2:
#
stp instance 2 root primary //sw2实例1为主根
stp instance 0 to 1 root secondary //sw2实例1为备根
stp global enable
#
查看mstp配置是否正确
第三步配置VRRP
SW1:
#
interface Vlan-interface10 //进入vlan10虚接口配置ip地址
ip address 10.1.10.2 255.255.255.0
vrrp vrid 10 virtual-ip 10.1.10.1 //配置10.1.10.1为虚拟网关
vrrp vrid 10 priority 120 //配置优先级为120
#
interface Vlan-interface20 //进入vlan20虚接口配置ip地址
ip address 10.1.20.2 255.255.255.0
vrrp vrid 20 virtual-ip 10.1.20.1 //配置10.1.20.1为虚拟网关
#
SW2:
#
interface Vlan-interface10 //进入vlan10虚接口配置ip地址
ip address 10.1.10.3 255.255.255.0
vrrp vrid 10 virtual-ip 10.1.10.1 //配置10.1.10.1为虚拟网关
#
interface Vlan-interface20 //进入vlan20虚接口配置ip地址
ip address 10.1.20.3 255.255.255.0
vrrp vrid 20 virtual-ip 10.1.20.1 //配置10.1.20.1为虚拟网关
vrrp vrid 20 priority 120 //配置优先级为120
#
查看vrrp状态
Ping路由器loopback接口测试
把SW1链路断开,发现主备切换
再次ping,能通链路走SW2