1、 客户机和路由器配置ip地址
R1:
[Huawei]sysname R1
[R1]int e0/0/0
[R1-Ethernet0/0/0]ip add 10.1.10.254 24
[R1-Ethernet0/0/0]undo shutdown
[R1-Ethernet0/0/0]int e0/0/1
[R1-Ethernet0/0/1]ip add 10.1.20.254 24
[R1-Ethernet0/0/1]undo shutdown
[R1-Ethernet0/0/1]quit
2、 配置vlan和trunk
S1:
[Huawei]sysname S1
[S1]vlan batch 10 20
[S1]int g0/0/2
[S1-GigabitEthernet0/0/2]port link-type trunk
[S1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[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 hybrid
[S1-GigabitEthernet0/0/3]port hybrid untagged vlan 10
[S1-GigabitEthernet0/0/3]port hybrid pvid vlan 10
[S1-GigabitEthernet0/0/3]quit
S2:
[Huawei]sysname S2
[S2]vlan batch 10 20
[S2]int g0/0/2
[S2-GigabitEthernet0/0/2]port link-type trunk
[S2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[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 hybrid
[S2-GigabitEthernet0/0/3]port hybrid untagged vlan 20
[S2-GigabitEthernet0/0/3]port hybrid pvid vlan 20
[S2-GigabitEthernet0/0/3]quit
S3:
[Huawei]sysname S3
[S3]vlan batch 10 20
[S3]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
[S3-GigabitEthernet0/0/4]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]quit
配置MSTP
S1
[S1]stp mode mstp
[S1]stp region-configuration
[S1-mst-region]region-name huawei
[S1-mst-region]revision-level 1
[S1-mst-region]instance 1 vlan 10
[S1-mst-region]instance 2 vlan 20
[S1-mst-region]active region-configuration
[S1-mst-region]quit
[S1]stp instance 1 root primary
[S1]stp instance 2 root secondary
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-mst-region]quit
[S2]stp instance 1 root secondary
[S2]stp instance 2 root primary
S3
[S3]stp mode mstp
[S3]stp region-configuration
[S3-mst-region]reg
[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
[S3-mst-region]quit
验证:
[S3]display stp brief