1 理解 STP 工作原理
1.1 问题
如何选择根网桥、根端口、指定端口、被阻塞的端口?
1.2 方案
使用 eNSP 搭建实全环境,如图 - 1 所示。
图 - 1
1.3 步骤
实现此案例需要按照如下步骤进行。
1)选择根网桥
- 网桥 ID 最小
- 选择根端口 (非根网桥)
- 此端口到达根网桥路径成本最低
- 此端口直连网桥 ID 最小
3)选择指定端口 (每根网线)
- 根网桥上所有端口都是指定端口
- 此端口所在交换机到达根网桥成本最低
- 此端口所在的换机的网桥 ID 最小
2 配置 STP
2.1 问题
首先查看当前根网桥,然后通过修改交换机的优先级来分配根网桥。
2.2 方案
使用 eNSP 搭建实验环境,如图 - 2 所示。
图 - 2
2.3 步骤
实现此案例需要按照如下步骤进行。
1)配置 STP
1. \[SW1\]stp mode stp
2. \[SW2\]stp mode stp
3. \[SW3\]stp mode stp
4. \[SW4\]stp mode stp
2)查看根网桥
1. \[SW1\]display stp
2. -------\[CIST Global Info\]\[Mode STP\]-------
3. CIST Bridge :32768.4c1f-cc59-0ca4
4. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
5. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
6. CIST Root/ERPC :32768.4c1f-cc16-2fc4 / 200000
7. CIST RegRoot/IRPC :32768.4c1f-cc16-2fc4 / 0
8. CIST RootPortId :128.2
9. BPDU-Protection :Disabled
10. TC or TCN received :106
11. TC count per hello :0
12. STP Converge Mode :Normal
13. Time since last TC :0 days 0h:9m:8s
14. Number of TC :12
15. Last TC occurred :Ethernet0/0/2
17. \[SW2\]display stp
18. -------\[CIST Global Info\]\[Mode STP\]-------
19. CIST Bridge :32768.4c1f-cc16-2fc4
20. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
21. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
22. CIST Root/ERPC :32768.4c1f-cc16-2fc4 / 0
23. CIST RegRoot/IRPC :32768.4c1f-cc16-2fc4 / 0
24. CIST RootPortId :0.0
25. BPDU-Protection :Disabled
26. TC or TCN received :23
27. TC count per hello :0
28. STP Converge Mode :Normal
29. Time since last TC :0 days 0h:9m:52s
30. Number of TC :13
31. Last TC occurred :Ethernet0/0/4
33. \[SW3\]display stp
34. -------\[CIST Global Info\]\[Mode STP\]-------
35. CIST Bridge :32768.4c1f-cc6d-7de5
36. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
37. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
38. CIST Root/ERPC :32768.4c1f-cc16-2fc4 / 400000
39. CIST RegRoot/IRPC :32768.4c1f-cc16-2fc4 / 0
40. CIST RootPortId :128.4
41. BPDU-Protection :Disabled
42. TC or TCN received :92
43. TC count per hello :0
44. STP Converge Mode :Normal
45. Time since last TC :0 days 0h:10m:26s
46. Number of TC :11
47. Last TC occurred :Ethernet0/0/4
49. \[SW4\]display stp
50. -------\[CIST Global Info\]\[Mode STP\]-------
51. CIST Bridge :32768.4c1f-cc5f-35c8
52. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
53. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
54. CIST Root/ERPC :32768.4c1f-cc16-2fc4 / 200000
55. CIST RegRoot/IRPC :32768.4c1f-cc16-2fc4 / 0
56. CIST RootPortId :128.2
57. BPDU-Protection :Disabled
58. TC or TCN received :49
59. TC count per hello :0
60. STP Converge Mode :Normal
61. Time since last TC :0 days 0h:11m:12s
62. Number of TC :13
63. Last TC occurred :Ethernet0/0/2
可以看出,交换机 SW2 是根网桥。
3)配置交换机 SW3 为根网桥
1. \[SW3\]stp priority 0
3. \[SW3\]display stp
4. -------\[CIST Global Info\]\[Mode STP\]-------
5. CIST Bridge :0.4c1f-cc6d-7de5
6. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
7. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
8. CIST Root/ERPC :0.4c1f-cc6d-7de5 / 0
9. CIST RegRoot/IRPC :0.4c1f-cc6d-7de5 / 0
10. CIST RootPortId :0.0
11. BPDU-Protection :Disabled
12. TC or TCN received :108
13. TC count per hello :0
14. STP Converge Mode :Normal
15. Time since last TC :0 days 0h:0m:14s
16. Number of TC :15
17. Last TC occurred :Ethernet0/0/3
此时,根网桥已经是交换机 SW3 了。
3 MSTP 配置实例
3.1 问题
1)PC1 属于 vlan 10,IP 地址为 192.168.10.1/24
2)PC2 属于 vlan 20,IP 地址为 192.168.20.1/24
3)配置 MSTP,实现 VLAN 10 的终端通信路径是:SW1-SW2
4)配置 MSTP,实现 VLAN 20 的终端通信路径是:SW3-SW4
3.2 方案
使用 eNSP 搭建实验环境,如图 - 3 所示。
图 - 3
3.3 步骤
实现此案例需要按照如下步骤进行。
1)配置 PC1/2/3/4 的 IP 地址
2)配置 SW1/2/3/4 的 VLAN 、Trunk、Access
1. <Huawei>undo terminal monitor
2. <Huawei>system-view
3. \[Huawei\]sysname SW1
4. \[SW1\]vlan batch 10 20
5. \[SW1\]interface gi0/0/12
6. \[SW1-GigabitEthernet0/0/12\]port link-type trunk
7. \[SW1-GigabitEthernet0/0/12\]port trunk allow-pass vlan all
8. \[SW1-GigabitEthernet0/0/12\]quit
9. \[SW1\]interface gi0/0/13
10. \[SW1-GigabitEthernet0/0/13\]port link-type trunk
11. \[SW1-GigabitEthernet0/0/13\]port trunk allow-pass vlan all
12. \[SW1-GigabitEthernet0/0/13\]quit
13. \[SW1\]interface gi0/0/1
14. \[SW1-GigabitEthernet0/0/1\]port link-type access
15. \[SW1-GigabitEthernet0/0/1\]port default vlan 10
16. \[SW1-GigabitEthernet0/0/1\]quit
18. <Huawei>undo terminal monitor
19. <Huawei>system-view
20. \[Huawei\]sysname SW2
21. \[SW2\]vlan batch 10 20
22. \[SW2\]interface gi0/0/12
23. \[SW2-GigabitEthernet0/0/12\]port link-type trunk
24. \[SW2-GigabitEthernet0/0/12\]port trunk allow-pass vlan all
25. \[SW2-GigabitEthernet0/0/12\]quit
26. \[SW2\]interface gi0/0/13
27. \[SW2-GigabitEthernet0/0/13\]port link-type trunk
28. \[SW2-GigabitEthernet0/0/13\]port trunk allow-pass vlan all
29. \[SW2-GigabitEthernet0/0/13\]quit
30. \[SW2\]interface gi0/0/1
31. \[SW2-GigabitEthernet0/0/1\]port link-type access
32. \[SW2-GigabitEthernet0/0/1\]port default vlan 10
33. \[SW2-GigabitEthernet0/0/1\]quit
35. <Huawei>undo terminal monitor
36. <Huawei>system-view
37. \[Huawei\]sysname SW3
38. \[SW3\]vlan batch 10 20
39. \[SW3\]interface gi0/0/12
40. \[SW3-GigabitEthernet0/0/12\]port link-type trunk
41. \[SW3-GigabitEthernet0/0/12\]port trunk allow-pass vlan all
42. \[SW3-GigabitEthernet0/0/12\]quit
43. \[SW3\]interface gi0/0/13
44. \[SW3-GigabitEthernet0/0/13\]port link-type trunk
45. \[SW3-GigabitEthernet0/0/13\]port trunk allow-pass vlan all
46. \[SW3-GigabitEthernet0/0/13\]quit
47. \[SW3\]interface gi0/0/1
48. \[SW3-GigabitEthernet0/0/1\]port link-type access
49. \[SW3-GigabitEthernet0/0/1\]port default vlan 20
50. \[SW3-GigabitEthernet0/0/1\]quit
52. <Huawei>undo terminal monitor
53. <Huawei>system-view
54. \[Huawei\]sysname SW4
55. \[SW4\]vlan batch 10 20
56. \[SW4\]interface gi0/0/12
57. \[SW4-GigabitEthernet0/0/12\]port link-type trunk
58. \[SW4-GigabitEthernet0/0/12\]port trunk allow-pass vlan all
59. \[SW4-GigabitEthernet0/0/12\]quit
60. \[SW4\]interface gi0/0/13
61. \[SW4-GigabitEthernet0/0/13\]port link-type trunk
62. \[SW4-GigabitEthernet0/0/13\]port trunk allow-pass vlan all
63. \[SW4-GigabitEthernet0/0/13\]quit
64. \[SW4\]interface gi0/0/1
65. \[SW4-GigabitEthernet0/0/1\]port link-type access
66. \[SW4-GigabitEthernet0/0/1\]port default vlan 20
67. \[SW4-GigabitEthernet0/0/1\]quit
3)配置 MSTP(SW1/2/3/4 的基本 MSTP 配置,都相同)
1. \[sw1\]stp mode mstp
2. \[sw1\]stp region-configuration
3. \[sw1-mst-region\]region-name HCIE
4. \[sw1-mst-region\]instance 1 vlan 10
5. \[sw1-mst-region\]instance 2 vlan 20
6. \[sw1-mst-region\]active region-configuration
4)配置 SW1 为 VLAN 10 的根交换机
1. \[sw1\]stp instance 1 priority 0
配置 SW3 为 VLAN 20 的根交换机
1. \[sw3\]stp instance 2 priority 0
4 MSTP 负载均衡
4.1 问题
1)PC1 属于 vlan 10 ,IP 地址为 192.168.10.1/24,网关为 192.168.10.254
2)PC2 属于 vlan 20 ,IP 地址为 192.168.20.1/24,网关为 192.168.20.254
3)确保 PC1 与 PC2 互通
4)合理配置 MSTP ,确保 PC1 与 PC2 之间的互通路径是最优的
4.2 方案
使用 eNSP 搭建实验环境,如图 - 4 所示。
图 - 4
4.3 步骤
实现此案例需要按照如下步骤进行。
1)配置 PC1/2 的 IP 地址
2)配置 SW1/2/3 的基本信息
- 创建 VLAN 10 和 20
- 配置交换机之间的链路为 Trunk,并允许 vlan 10 和 20
- 配置交换机与 PC / 路由器之间的链路为 Access,并加入到正确的 VLAN
3)配置 MSTP(SW1/2/3 的配置相同)
1. stp mode mstp
2. stp region-configuration
3. region-name HCIE
4. instance 1 vlan 10
5. instance 2 vlan 20
6. active region-configuration
7. quit
4)配置主根与次根
1. \[SW1\]stp instance 2 priority 4096
2. \[SW1\]stp instance 1 priority 8192
4. \[SW2\]stp instance 1 priority 4096
5. \[SW2\]stp instance 2 priority 8192
5)查看负载均衡
1. \[SW1\]display stp brief
2. MSTID Port Role STP State Protection
3. 1 Ethernet0/0/3 DESI FORWARDING NONE
4. 1 Ethernet0/0/10 ROOT FORWARDING NONE
5. 2 Ethernet0/0/1 DESI FORWARDING NONE
6. 2 Ethernet0/0/3 DESI FORWARDING NONE
7. 2 Ethernet0/0/10 DESI FORWARDING NONE
9. \[SW2\]display stp brief
10. MSTID Port Role STP State Protection
11. 1 Ethernet0/0/2 DESI FORWARDING NONE
12. 1 Ethernet0/0/4 DESI FORWARDING NONE
13. 1 Ethernet0/0/10 DESI FORWARDING NONE
14. 2 Ethernet0/0/4 DESI FORWARDING NONE
15. 2 Ethernet0/0/10 ROOT FORWARDING NONE
17. \[SW3\]display stp brief
18. MSTID Port Role STP State Protection
19. 1 Ethernet0/0/1 DESI FORWARDING NONE
20. 1 Ethernet0/0/3 ALTE DISCARDING NONE
21. 1 Ethernet0/0/4 ROOT FORWARDING NONE
22. 2 Ethernet0/0/2 DESI FORWARDING NONE
23. 2 Ethernet0/0/3 ROOT FORWARDING NONE
24. 2 Ethernet0/0/4 ALTE DISCARDING NONE
https://tts.tmooc.cn/ttsPage/NTD/NTDTN202109/TCNA/DAY01/CASE/01/index.html