1.配置终端设备的IP地址
略!
2.在交换机S1、交换机S2上分别创建VLAN2、VLAN3和VLAN10
[S1]vlan batch 2 3 10
[S2]vlan batch 2 3 10
3.在交换机S1和S2上配置Hybrid接口
S1交换机的配置如下:
[S1]int g0/0/2
[S1-GigabitEthernet0/0/2]port link-type hybrid
//配置接口模式为Hybrid(默认就是Hybrid接口)
[S1-GigabitEthernet0/0/2]port hybrid pvid vlan 1
//配置接口的PVID为1(默认也是)
[S1-GigabitEthernet0/0/2]port hybrid untagged vlan 1 2
//将VLAN1、VLAN2加入untag列表
[S1-GigabitEthernet0/0/2]int g0/0/3
[S1-GigabitEthernet0/0/3]port link-type hybrid
[S1-GigabitEthernet0/0/3]port hybrid pvid vlan 1
[S1-GigabitEthernet0/0/3]port hybrid untagged vlan 1 2
[S1-GigabitEthernet0/0/3]int g0/0/4
[S1-GigabitEthernet0/0/4]port link-type hybrid
[S1-GigabitEthernet0/0/4]port hybrid pvid vlan 10
[S1-GigabitEthernet0/0/4]port hybrid untagged vlan 3 10
[S1-GigabitEthernet0/0/4]int g0/0/1
[S1-GigabitEthernet0/0/1]port link-type hybrid
[S1-GigabitEthernet0/0/1]port hybrid pvid vlan 1
[S1-GigabitEthernet0/0/1]port hybrid untagged vlan 1 2
[S1-GigabitEthernet0/0/1]port hybrid tagged vlan 3 10
//将VLAN3、VLAN10添加到tag列表中
S2交换机的配置如下:
[S2-GigabitEthernet0/0/3]int g0/0/1
[S2-GigabitEthernet0/0/1]port link-type hybrid
[S2-GigabitEthernet0/0/1]port hybrid pvid vlan 1
[S2-GigabitEthernet0/0/1]port hybrid untagged vlan 1 2
[S2-GigabitEthernet0/0/1]port hybrid tagged vlan 3 10
[S2]int g0/0/2
[S2-GigabitEthernet0/0/2]port link-type hybrid
[S2-GigabitEthernet0/0/2]port hybrid pvid vlan 2
[S2-GigabitEthernet0/0/2]port hybrid untagged vlan 1 2
[S2-GigabitEthernet0/0/2]int g0/0/3
[S2-GigabitEthernet0/0/3]port link-type hybrid
[S2-GigabitEthernet0/0/3]port hybrid pvid vlan 3
[S2-GigabitEthernet0/0/3]port hybrid untagged vlan 3 10
4.验证网络通信
PC1的测试如下:
实验二 :(MSTP配置)
5.MSTP的端口状态
MSTP的端口有以下三种:
Forwarding:在这种状态下,端口既转发用户流量,又接收/发送BPDU报文,称为转发状态;
Learning:这是一种过渡状态。在Learning状态下,交换机会根据收到的用户流量,学习MAC地址表,但不转发用户流量,所以称为学习状态。Learning状态的端口接收/发送BPDU报文,但不转发用户流量;
Discarding:在这种状态下,端口只接收BPDU报文,称为丢弃状态
1.所有交换机启用MSTP协议,区域名称改为huawei,修改版本级别为1;
2.利用MSTP协议VLAN10和VLAN20的互访;
3.VLAN10的流量走向:PC1→S3→S1→R1;
4.VLAN20的流量走向:PC2→S3→S2→R1;
(1)配置客户端及路由器IP地址
配置客户端地址过程过程略!配置路由器地址如下
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 10.1.10.254 24
[R1-GigabitEthernet0/0/1]int g0/0/0
[R1-GigabitEthernet0/0/2]ip add 10.1.20.254 24
//华为设备接口默认是开启的,也可以使用undo shutdown开启一下!
2)配置VLAN及Trunk
本次实验中,客户机与交换机连接口为Access接口,二层交换机与交换机连接口为Trunk接口,二层交换机和路由器连接口为Hybrid接口。常识:路由器不可以识别带VLAN标签的数据帧。
S1的配置如下:
[S1]vlan batch 10 20
[S1]int g0/0/2
[S1-GigabitEthernet0/0/2]port link-type hybrid
[S1-GigabitEthernet0/0/2]port hybrid untagged vlan 10
[S1-GigabitEthernet0/0/2]port hybrid pvid vlan 10
[S1-GigabitEthernet0/0/2]int g0/0/1
[S1-GigabitEthernet0/0/1]port link-type trunk
[S1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[S1-GigabitEthernet0/0/1]int g0/0/3
[S1-GigabitEthernet0/0/3]port link-type trunk
[S1-GigabitEthernet0/0/3]port trunk allow-pass vlan all
//基础指令这里就不介绍什么意思了!
S2的配置如下:
[S2]vlan batch 10 20
[S2]int g0/0/2
[S2-GigabitEthernet0/0/2]port link-type hybrid
[S2-GigabitEthernet0/0/2]port hybrid untagged vlan 20
[S2-GigabitEthernet0/0/2]port hybrid pvid vlan 20
[S2-GigabitEthernet0/0/2]int g0/0/1
[S2-GigabitEthernet0/0/1]port link-type trunk
[S2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[S2-GigabitEthernet0/0/1]int g0/0/3
[S2-GigabitEthernet0/0/3]port link-type trunk
[S2-GigabitEthernet0/0/3]port trunk allow-pass vlan all
S3的配置如下:
[S3]vlan batch 10 20
[S3]int g0/0/1
[S3-GigabitEthernet0/0/1]port link-type trunk
[S3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[S3-GigabitEthernet0/0/1]int g0/0/2
[S3-GigabitEthernet0/0/2]port link-type trunk
[S3-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[S3-GigabitEthernet0/0/2]int g0/0/3
[S3-GigabitEthernet0/0/3]port link-type access
[S3-GigabitEthernet0/0/3]port default vlan 10
[S3-GigabitEthernet0/0/3]int g0/0/4
[S3-GigabitEthernet0/0/4]port link-type access
[S3-GigabitEthernet0/0/4]port default vlan 20
(3)配置MSTP
根据实验要求,实验命令如下:
S1的配置如下:
[S1]stp mode mstp
//将交换机配置成MSTP模式
[S1]stp region-configuration
//进入MSTP配置模式
[S1-mst-region]region-name huawei
//配置域名为huawei
[S1-mst-region]revision-level 1
//配置版本等级为1
[S1-mst-region]instance 1 vlan 10
//将VLAN10加入实例1中
[S1-mst-region]instance 2 vlan 20
//将VLAN20加入实例2中
[S1-mst-region]active region-configuration
//激活配置(必须配置)
[S1-mst-region]quit
[S1]stp instance 1 root primary
//配置此交换机为实例1的主根
[S1]stp instance 2 root secondary
//配置此交换机为实例2的备根
S2的配置如下:
[S2]stp mode mstp
[S2]stp region-configuration
[S2-mst-region]region-name huawei
[S2-mst-region]revision-level 1
[S2-mst-region]instance 1 vlan 10
[S2-mst-region]instance 2 vlan 20
[S2-mst-region]active region-configuration
[S2]stp instance 1 root secondary
[S2]stp instance 2 root primary
//命令与S1基本相似,这里就不多说了!
S3的配置如下:
[S3]stp mode mstp
[S3]stp region-configuration
[S3-mst-region]region-name huawei
[S3-mst-region]revision-level 1
[S3-mst-region]instance 1 vlan 10
[S3-mst-region]instance 2 vlan 20
[S3-mst-region]active region-configuration
(4)验证
在S3上使用一下命令查看效果!
[S3]display stp brief
//查看STP接口角色及状态信息
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 ROOT FORWARDING NONE
1 GigabitEthernet0/0/2 ALTE DISCARDING NONE
//运行实例1时,g0/0/2接口阻塞
1 GigabitEthernet0/0/3 DESI FORWARDING NONE
2 GigabitEthernet0/0/1 ALTE DISCARDING NONE
//运行实例2时,g0/0/1接口阻塞
2 GigabitEthernet0/0/2 ROOT FORWARDING NONE
2 GigabitEthernet0/0/4 DESI FORWARDING NONE
可以自行验证效果!PC1和PC2是可以通信的,不管任何交换机之间任意一条线路故障,也不会影响通信(模拟线路故障后,稍微等一下再测试通信)