拓扑如下图所示:
具体配置如下:
SW3:
先创建vlan10,20
vlan 10
vlan 20
然后在接口下划分trunk、access模式
interface Ethernet0/3
switchport mode access
switchport access vlan 10
interface Ethernet1/0
switchport mode access
switchport access vlan 20
int range e0/1 , e0/2
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan 10,20
配置mstp
spanning-tree mode mstp
spanning-tree mst configuration
name qgtest
revision 123
instance 10 vlan 10
instance 20 vlan 20
SW1:
先创建vlan10,20
vlan 10
vlan 20
配置链路聚合和trunk口
interface range e0/2 , e0/0 , e0/1
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan 10,20
interface range e0/2 , e0/0
channel-group 1 mode on
配置mstp
spanning-tree mode mstp
spanning-tree mst configuration
name qgtest
revision 123
instance 10 vlan 10
instance 20 vlan 20
spanning-tree mst 10 root primary
spanning-tree mst 20 root sec
配置vrrp
interface Vlan10
ip address 192.168.10.253 255.255.255.0
vrrp 10 ip 192.168.10.254
vrrp 10 priority 200
interface Vlan20
ip address 192.168.20.252 255.255.255.0
vrrp 20 ip 192.168.20.254
vrrp 20 priority 100
SW2:
先创建vlan10,20
vlan 10
vlan 20
配置链路聚合和trunk口
interface range e0/2 , e0/0 , e0/1
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan 10,20
interface range e0/2 , e0/0
channel-group 1 mode on
配置mstp
spanning-tree mode mstp
spanning-tree mst configuration
name qgtest
revision 123
instance 10 vlan 10
instance 20 vlan 20
spanning-tree mst 20 root primary
spanning-tree mst 10 root sec
配置vrrp
interface Vlan20
ip address 192.168.20.253 255.255.255.0
vrrp 20 ip 192.168.20.254
vrrp 20 priority 200
interface Vlan10
ip address 192.168.10.252 255.255.255.0
vrrp 10 ip 192.168.10.254
vrrp 10 priority 100
备注:如果SW1有上行接口和上行链路时,其中一个发生故障,VRRP默认是无法感知的,即主备状态无法切换,数据包无法发送出去,这是就要用到track功能。具体配置如下:
SW1/SW2:
vrrp 10 track 1 decrement 150
track 1 int g0/0/3 line-protocol
假设G0/0/3为上行口,配置完这条命令之后,即当上行链路发生故障时,其优先级减少150,然后当前优先级小于Backup状态的三层交换机,则主备状态发生切换。