解决局域网中配置静态网关出现单点失效现象的路由协议
每个VLAN或者几个VLAN拥有一颗生成树,基于实例的生成树
instance 1、instance 2 每个实例拥有一颗生成树
MSTP可以实现多VLAN 的负载分担,可以实现多厂商对接
当MSTP 和VRRP共同存在时,我们必须要做MSTP的区域设置以及实例优先级,网络中二层MSTP的VLAN主根桥和三层VRRP的master网关要放在同一台设备上
在下面的图中,我们把
VLAN10的网关设备设置为核心SW1,VLAN10的instance 1的根桥设置为核心SW1
VLAN20的网关设备设置为核心SW2,VLAN20的instance 2的根桥设置为核心SW2
system-view //进入全局配置模式
[Huawei]undo info-center enable //关闭信息告警提示
[Huawei]sysname SW1 //改名
[SW1]vlan batch 10 20 //创建VLAN10和VLAN20
[SW1]
system-view //进入全局配置模式
[Huawei]undo info-center enable //关闭信息告警提示
[Huawei]sysname SW2 //改名
[SW2]vlan batch 10 20 //创建VLAN10和VLAN20
[SW2]
system-view //进入全局配置模式
[Huawei]undo info-center enable //关闭信息告警提示
[Huawei]sysname SW3 //改名
[SW3]vlan batch 10 20 //创建VLAN10和VLAN20
[SW3]
[SW1]interface g0/0/1 //进入接口
[SW1-GigabitEthernet0/0/1]port link-type trunk //设置为trunk链路
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all //允许所有VLAN通过
[SW1-GigabitEthernet0/0/1]quit //退出
[SW1]interface g0/0/2 //进入接口
[SW1-GigabitEthernet0/0/2]port link-type trunk //设置为trunk链路
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan all //允许所有VLAN通过
[SW1-GigabitEthernet0/0/2]quit //退出
[SW1]
[SW2]interface g0/0/1 //进入接口
[SW2-GigabitEthernet0/0/1]port link-type trunk //设置为trunk链路
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all //允许所有VLAN通过
[SW2-GigabitEthernet0/0/1]quit //退出
[SW2]interface g0/0/2 //进入接口
[SW2-GigabitEthernet0/0/2]port link-type trunk //设置为trunk链路
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan all //允许所有VLAN通过
[SW2-GigabitEthernet0/0/2]quit //退出
[SW2]
[SW3]interface g0/0/1 //进入接口
[SW3-GigabitEthernet0/0/1]port link-type trunk //设置为trunk链路
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan all //允许所有VLAN通过
[SW3-GigabitEthernet0/0/1]quit //退出
[SW3]interface g0/0/2 //进入接口
[SW3-GigabitEthernet0/0/2]port link-type trunk //设置为trunk链路
[SW3-GigabitEthernet0/0/2]port trunk allow-pass vlan all //允许所有VLAN通过
[SW3-GigabitEthernet0/0/2]quit //退出
[SW3]
[SW3]interface g0/0/3 //进入接口
[SW3-GigabitEthernet0/0/3]port link-type access
[SW3-GigabitEthernet0/0/3]port default vlan 10
[SW3-GigabitEthernet0/0/3]quit //退出
[SW3]interface g0/0/4 //进入接口
[SW3-GigabitEthernet0/0/4]port link-type access
[SW3-GigabitEthernet0/0/4]port default vlan 20
[SW3-GigabitEthernet0/0/4]quit //退出
[SW3]
[SW1]interface vlan10 //进入VLAN10
[SW1-Vlanif10]ip address 192.168.10.254 24 //设置IP地址
[SW1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1 //配置虚拟网关IP地址
[SW1-Vlanif10]vrrp vrid 1 priority 105 //SW1作为VLAN10网关的主路由器,优先级改为105,优先级越高越优先
[SW1-Vlanif10]vrrp vrid 1 track interface g0/0/2 //发现g0/0/2口down时,会自动将优先级减10
[SW1-Vlanif10]quit //退出
[SW1]
[SW2]interface vlan10 //进入VLAN10
[SW2-Vlanif10]ip address 192.168.10.253 24 //设置IP地址
[SW2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1 //配置虚拟网关IP地址
[SW2-Vlanif10]quit //退出
[SW2]
[SW2]interface vlan 20 //进入VLAN20
[SW2-Vlanif20]ip address 192.168.20.254 24 //设置IP地址
[SW2-Vlanif20]vrrp vrid 1 virtual-ip 192.168.20.1 //配置虚拟网关IP地址
[SW2-Vlanif20]vrrp vrid 1 priority 105 //SW2作为VLAN20网关的主路由器,优先级改为105,优先级越高越优先
[SW2-Vlanif20]vrrp vrid 1 track interface g0/0/2 //发现g0/0/2口down时,会自动将优先级减10
[SW2-Vlanif20]quit //退出
[SW2]
[SW1]interface vlan 20 //进入VLAN20
[SW1-Vlanif20]ip address 192.168.20.253 24 //设置IP地址
[SW1-Vlanif20]vrrp vrid 1 virtual-ip 192.168.20.1 //配置虚拟网关IP地址
[SW1-Vlanif20]quit //退出
[SW1]
[SW1]dis vrrp brief //查看VRRP信息
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Master Vlanif10 Normal 192.168.10.1 //作为VLAN10的主网关
1 Backup Vlanif20 Normal 192.168.20.1 //作为VLAN20的备网关
----------------------------------------------------------------
Total:2 Master:1 Backup:1 Non-active:0
[SW2]dis vrrp brief //查看VRRP信息
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Backup Vlanif10 Normal 192.168.10.1 //作为VLAN10的备网关
1 Master Vlanif20 Normal 192.168.20.1 //作为VLAN20的主网关
----------------------------------------------------------------
Total:2 Master:1 Backup:1 Non-active:0
[SW1]stp region-configuration //进入MSTP配置模式
[SW1-mst-region]region-name huawei //配置MSTP域名,同一个域内的交换机域名必须相同(多个MSTP域相连,每个域被看做一台SW)
[SW1-mst-region]instance 1 vlan 10 //创建实例1,并将VLAN10加入实例1
[SW1-mst-region]instance 2 vlan 20 //创建实例2,并将VLAN20加入实例2
[SW1-mst-region]active region-configuration //激活以上配置,否则配置不生效也看不到
[SW1-mst-region]quit //退出
[SW1]
[SW2]stp region-configuration //进入MSTP配置模式
[SW2-mst-region]region-name huawei //配置MSTP域名,同一个域内的交换机域名必须相同(多个MSTP域相连,每个域被看做一台SW)
[SW2-mst-region]instance 1 vlan 10 //创建实例1,并将VLAN10加入实例1
[SW2-mst-region]instance 2 vlan 20 //创建实例2,并将VLAN20加入实例2
[SW2-mst-region]active region-configuration //激活以上配置,否则配置不生效也看不到
[SW2-mst-region]quit //退出
[SW2]
[SW3]stp region-configuration //进入MSTP配置模式
[SW3-mst-region]region-name huawei //配置MSTP域名,同一个域内的交换机域名必须相同(多个MSTP域相连,每个域被看做一台SW)
[SW3-mst-region]instance 1 vlan 10 //创建实例1,并将VLAN10加入实例1
[SW3-mst-region]instance 2 vlan 20 //创建实例2,并将VLAN20加入实例2
[SW3-mst-region]active region-configuration //激活以上配置,否则配置不生效也看不到
[SW3-mst-region]quit //退出
[SW3]
[SW1]stp instance 1 root primary //根据实例1把SW1设置为根桥
[SW2]stp instance 1 root secondary //根据实例1把SW2设置为备份根桥
[SW2]stp instance 2 root primary //根据实例2把SW2设置为根桥
[SW1]stp instance 2 root secondary //根据实例2把SW设置为备份根桥
[SW3]dis stp brief //查看STP(MSTP)信息
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING NONE
0 GigabitEthernet0/0/2 DESI FORWARDING NONE
0 GigabitEthernet0/0/3 DESI FORWARDING NONE
0 GigabitEthernet0/0/4 DESI FORWARDING NONE
1 GigabitEthernet0/0/1 ALTE DISCARDING NONE //实例1阻塞G0/0/1口
1 GigabitEthernet0/0/2 ROOT FORWARDING NONE
1 GigabitEthernet0/0/3 DESI FORWARDING NONE
2 GigabitEthernet0/0/1 ROOT FORWARDING NONE
2 GigabitEthernet0/0/2 ALTE DISCARDING NONE //实例2阻塞G0/0/20口
2 GigabitEthernet0/0/4 DESI FORWARDING NONE
PC>ping 192.168.10.1 //测试ping自己的网关
Ping 192.168.10.1: 32 data bytes, Press Ctrl_C to break
From 192.168.10.1: bytes=32 seq=1 ttl=255 time=31 ms
From 192.168.10.1: bytes=32 seq=2 ttl=255 time=31 ms
From 192.168.10.1: bytes=32 seq=3 ttl=255 time=31 ms
From 192.168.10.1: bytes=32 seq=4 ttl=255 time=47 ms
From 192.168.10.1: bytes=32 seq=5 ttl=255 time=47 ms //网关
--- 192.168.10.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/37/47 ms
[SW2]dis vrrp brief //查看VRRP信息
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Master Vlanif10 Normal 192.168.10.1 //核心SW1G0/0/2down,优先级自动减10,SW2替换成主设备
1 Master Vlanif20 Normal 192.168.20.1
----------------------------------------------------------------
Total:2 Master:2 Backup:0 Non-active:0