MSTP生成树协议

2025-03-25T07:43:22.png
我们将pc1和pc2不同网段的vlan,而这两条走的路线不同;但需要两个不同vlan互相访问对方的pc。通过MSTP生成树进行操作

首先配置各自的vlan

# LSW3配置
vlan batch 10 20
int g0/0/3
port link-type access
port default vlan 10
int g0/0/4
port link-type access
port default vlan 20
# 配置完终端vlan后是配置trunk
int g0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
int g0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20
# LSW1配置
vlan batch 10 20
int g0/0/3
port link-type trunk
port trunk allow-pass vlan 10 20
int g0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
int g0/0/2
port link-type hybrid 
port hybrid untagged vlan 10
port hybrid  pvid  vlan 10
# LSW2配置
vlan batch 10 20
int g0/0/3
port link-type trunk
port trunk allow-pass vlan 10 20
int g0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20
int g0/0/1
port link-type hybrid 
port hybrid untagged vlan 10
port hybrid  pvid  vlan 10

然后配置MSTP树协议

# LSW1配置mstp
stp mo mstp                    
stp region-configuration                
region-name lv                     
revision-level 1                     
instance 1 vlan 10                    
instance 2 vlan 20                     
active region-configuration                      
quit                     
stp instance 1 root primary                      
stp instance 2 root secondary                  
# LSW2配置mstp
stp mo mstp                    
stp region-configuration                
region-name lv                     
revision-level 1                     
instance 1 vlan 10                    
instance 2 vlan 20                     
active region-configuration                      
quit                     
stp instance 1 root  secondary                     
stp instance 2 root  primary   
# LSW3配置mstp
stp mo mstp                    
stp region-configuration                
region-name lv                     
revision-level 1                     
instance 1 vlan 10                    
instance 2 vlan 20                     
active region-configuration                      
quit                     

最后配置路由直连

int g0/0/0
ip add 10.1.10.254 24
int g0/0/1
ip add 10.1.20.254 24

2025-03-25T08:05:48.png
2025-03-25T08:05:58.png
pc1和pc2相互ping,可以互相访问了。但在线路的选择上面,可能会出现timeout超时。

VRRP

2025-03-26T09:12:56.png
虚拟路由冗余协议VRRP通过几台路由器设备组成一台虚拟的路由设备,将虚拟路由设备的IP地址作为用户的默认网关实现与外部网络通信。当网关设备发生故障时,VRRP机制能够选举新的网关设备承担数据流量,从儿童保障网络的可靠通信。

# LSW1 vlan配置
vlan batch 1 11
int g0/0/2
port link-type access
port def vlan 1
int g0/0/1
port link-type access
port def vlan 11
int vlan 1
ip add 10.1.1.253 24
int vlan 11
ip add 10.1.11.1 24
# LSW2 vlan配置
vlan batch 1 12
int g0/0/1
port link-type access
port def vlan 1
int g0/0/2
port link-type access
port def vlan 12
int vlan 1
ip add 10.1.1.253 24
int vlan 11
ip add 10.1.12.1 24
# vrrp配置LSW1
int vlan 1
vrrp vrid 1 virtual-ip 10.1.1.254 
# vrrp配置LSW2
int vlan 1
vrrp vrid 1 virtual-ip 10.1.1.254 
# R1路由器直连
int e0/0/1
ip add 10.1.11.2 24
int e0/0/2
ip add 10.1.12.2 24

2025-03-26T09:36:02.png