拓扑如下图所示:
具体配置如下:
SW3:
先创建vlan10、20
vlan batch 10 20
然后在接口下划分trunk、access模式
interface Ethernet0/0/1
port link-type access
port default vlan 10
interface Ethernet0/0/2
port link-type access
port default vlan 20
interface Ethernet0/0/3
port link-type trunk
port trunk allow-pass vlan 10 20
interface Ethernet0/0/4
port link-type trunk
port trunk allow-pass vlan 10 20
配置mstp
stp mode mstp
stp region-configuration
region-name qgtest
instance 10 vlan 10
instance 20 vlan 20
active region-configuration
SW1:
先创建vlan10、20
vlan batch 10 20
配置链路聚合和trunk口
interface Eth-Trunk1
trunkport int g0/0/1
trunkport int g0/0/2
interface Eth-Trunk1
port link-type trunk
port trunk allow-pass vlan 10 20
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 10 20
配置mstp
stp mode mstp
stp region-configuration
region-name qgtest
instance 10 vlan 10
instance 20 vlan 20
active region-configuration
stp instance 10 root primary
stp instance 20 root secondary
配置VRRP
interface Vlanif10
ip address 192.168.10.253 255.255.255.0
vrrp vrid 10 virtual-ip 192.168.10.254
vrrp vrid 10 priority 120
interface Vlanif20
ip address 192.168.20.252 255.255.255.0
vrrp vrid 20 virtual-ip 192.168.20.254
vrrp vrid 20 priority 100
SW2:
先创建vlan10、20
vlan batch 10 20
配置链路聚合和trunk口
interface Eth-Trunk1
trunkport int g0/0/1
trunkport int g0/0/2
interface Eth-Trunk1
port link-type trunk
port trunk allow-pass vlan 10 20
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 10 20
配置mstp
stp mode mstp
stp region-configuration
region-name qgtest
instance 10 vlan 10
instance 20 vlan 20
active region-configuration
stp instance 20 root primary
stp instance 10 root secondary
配置VRRP
interface Vlanif20
ip address 192.168.20.253 255.255.255.0
vrrp vrid 20 virtual-ip 192.168.20.254
vrrp vrid 20 priority 120
interface Vlanif10
ip address 192.168.10.252 255.255.255.0
vrrp vrid 10 virtual-ip 192.168.10.254
vrrp vrid 10 priority 100
备注:如果SW1有上行接口和上行链路时,其中一个发生故障,VRRP默认是无法感知的,即主备状态无法切换,数据包无法发送出去,这是就要用到track功能。具体配置如下:
SW1/SW2:
vrrp 10 track int g0/0/3 reduced 30
假设G0/0/3为上行口,配置完这条命令之后,即当上行链路发生故障时,其优先级减少30,然后当前优先级小于Backup状态的三层交换机,则主备状态发生切换。