Top

  1. 理解 STP 工作原理
  2. 配置 STP
  3. MSTP 配置实例
  4. MSTP 负载均衡

1 理解 STP 工作原理

1.1 问题

如何选择根网桥、根端口、指定端口、被阻塞的端口?

1.2 方案

使用 eNSP 搭建实全环境,如图 - 1 所示。

CASE - 图1

图 - 1

1.3 步骤

实现此案例需要按照如下步骤进行。

1)选择根网桥

  • 网桥 ID 最小
  1. 选择根端口 (非根网桥)
  • 此端口到达根网桥路径成本最低
  • 此端口直连网桥 ID 最小

3)选择指定端口 (每根网线)

  • 根网桥上所有端口都是指定端口
  • 此端口所在交换机到达根网桥成本最低
  • 此端口所在的换机的网桥 ID 最小

2 配置 STP

2.1 问题

首先查看当前根网桥,然后通过修改交换机的优先级来分配根网桥。

2.2 方案

使用 eNSP 搭建实验环境,如图 - 2 所示。

CASE - 图2

图 - 2

2.3 步骤

实现此案例需要按照如下步骤进行。

1)配置 STP

  1. 1. \[SW1\]stp mode stp
  2. 2. \[SW2\]stp mode stp
  3. 3. \[SW3\]stp mode stp
  4. 4. \[SW4\]stp mode stp

2)查看根网桥

  1. 1. \[SW1\]display stp
  2. 2. -------\[CIST Global Info\]\[Mode STP\]-------
  3. 3. CIST Bridge :32768.4c1f-cc59-0ca4
  4. 4. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  5. 5. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  6. 6. CIST Root/ERPC :32768.4c1f-cc16-2fc4 / 200000
  7. 7. CIST RegRoot/IRPC :32768.4c1f-cc16-2fc4 / 0
  8. 8. CIST RootPortId :128.2
  9. 9. BPDU-Protection :Disabled
  10. 10. TC or TCN received :106
  11. 11. TC count per hello :0
  12. 12. STP Converge Mode :Normal
  13. 13. Time since last TC :0 days 0h:9m:8s
  14. 14. Number of TC :12
  15. 15. Last TC occurred :Ethernet0/0/2
  16. 17. \[SW2\]display stp
  17. 18. -------\[CIST Global Info\]\[Mode STP\]-------
  18. 19. CIST Bridge :32768.4c1f-cc16-2fc4
  19. 20. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  20. 21. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  21. 22. CIST Root/ERPC :32768.4c1f-cc16-2fc4 / 0
  22. 23. CIST RegRoot/IRPC :32768.4c1f-cc16-2fc4 / 0
  23. 24. CIST RootPortId :0.0
  24. 25. BPDU-Protection :Disabled
  25. 26. TC or TCN received :23
  26. 27. TC count per hello :0
  27. 28. STP Converge Mode :Normal
  28. 29. Time since last TC :0 days 0h:9m:52s
  29. 30. Number of TC :13
  30. 31. Last TC occurred :Ethernet0/0/4
  31. 33. \[SW3\]display stp
  32. 34. -------\[CIST Global Info\]\[Mode STP\]-------
  33. 35. CIST Bridge :32768.4c1f-cc6d-7de5
  34. 36. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  35. 37. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  36. 38. CIST Root/ERPC :32768.4c1f-cc16-2fc4 / 400000
  37. 39. CIST RegRoot/IRPC :32768.4c1f-cc16-2fc4 / 0
  38. 40. CIST RootPortId :128.4
  39. 41. BPDU-Protection :Disabled
  40. 42. TC or TCN received :92
  41. 43. TC count per hello :0
  42. 44. STP Converge Mode :Normal
  43. 45. Time since last TC :0 days 0h:10m:26s
  44. 46. Number of TC :11
  45. 47. Last TC occurred :Ethernet0/0/4
  46. 49. \[SW4\]display stp
  47. 50. -------\[CIST Global Info\]\[Mode STP\]-------
  48. 51. CIST Bridge :32768.4c1f-cc5f-35c8
  49. 52. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  50. 53. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  51. 54. CIST Root/ERPC :32768.4c1f-cc16-2fc4 / 200000
  52. 55. CIST RegRoot/IRPC :32768.4c1f-cc16-2fc4 / 0
  53. 56. CIST RootPortId :128.2
  54. 57. BPDU-Protection :Disabled
  55. 58. TC or TCN received :49
  56. 59. TC count per hello :0
  57. 60. STP Converge Mode :Normal
  58. 61. Time since last TC :0 days 0h:11m:12s
  59. 62. Number of TC :13
  60. 63. Last TC occurred :Ethernet0/0/2

可以看出,交换机 SW2 是根网桥。

3)配置交换机 SW3 为根网桥

  1. 1. \[SW3\]stp priority 0
  2. 3. \[SW3\]display stp
  3. 4. -------\[CIST Global Info\]\[Mode STP\]-------
  4. 5. CIST Bridge :0.4c1f-cc6d-7de5
  5. 6. Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  6. 7. Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
  7. 8. CIST Root/ERPC :0.4c1f-cc6d-7de5 / 0
  8. 9. CIST RegRoot/IRPC :0.4c1f-cc6d-7de5 / 0
  9. 10. CIST RootPortId :0.0
  10. 11. BPDU-Protection :Disabled
  11. 12. TC or TCN received :108
  12. 13. TC count per hello :0
  13. 14. STP Converge Mode :Normal
  14. 15. Time since last TC :0 days 0h:0m:14s
  15. 16. Number of TC :15
  16. 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 所示。

CASE - 图3

图 - 3

3.3 步骤

实现此案例需要按照如下步骤进行。

1)配置 PC1/2/3/4 的 IP 地址

2)配置 SW1/2/3/4 的 VLAN 、Trunk、Access

  1. 1. <Huawei>undo terminal monitor
  2. 2. <Huawei>system-view
  3. 3. \[Huawei\]sysname SW1
  4. 4. \[SW1\]vlan batch 10 20
  5. 5. \[SW1\]interface gi0/0/12
  6. 6. \[SW1-GigabitEthernet0/0/12\]port link-type trunk
  7. 7. \[SW1-GigabitEthernet0/0/12\]port trunk allow-pass vlan all
  8. 8. \[SW1-GigabitEthernet0/0/12\]quit
  9. 9. \[SW1\]interface gi0/0/13
  10. 10. \[SW1-GigabitEthernet0/0/13\]port link-type trunk
  11. 11. \[SW1-GigabitEthernet0/0/13\]port trunk allow-pass vlan all
  12. 12. \[SW1-GigabitEthernet0/0/13\]quit
  13. 13. \[SW1\]interface gi0/0/1
  14. 14. \[SW1-GigabitEthernet0/0/1\]port link-type access
  15. 15. \[SW1-GigabitEthernet0/0/1\]port default vlan 10
  16. 16. \[SW1-GigabitEthernet0/0/1\]quit
  17. 18. <Huawei>undo terminal monitor
  18. 19. <Huawei>system-view
  19. 20. \[Huawei\]sysname SW2
  20. 21. \[SW2\]vlan batch 10 20
  21. 22. \[SW2\]interface gi0/0/12
  22. 23. \[SW2-GigabitEthernet0/0/12\]port link-type trunk
  23. 24. \[SW2-GigabitEthernet0/0/12\]port trunk allow-pass vlan all
  24. 25. \[SW2-GigabitEthernet0/0/12\]quit
  25. 26. \[SW2\]interface gi0/0/13
  26. 27. \[SW2-GigabitEthernet0/0/13\]port link-type trunk
  27. 28. \[SW2-GigabitEthernet0/0/13\]port trunk allow-pass vlan all
  28. 29. \[SW2-GigabitEthernet0/0/13\]quit
  29. 30. \[SW2\]interface gi0/0/1
  30. 31. \[SW2-GigabitEthernet0/0/1\]port link-type access
  31. 32. \[SW2-GigabitEthernet0/0/1\]port default vlan 10
  32. 33. \[SW2-GigabitEthernet0/0/1\]quit
  33. 35. <Huawei>undo terminal monitor
  34. 36. <Huawei>system-view
  35. 37. \[Huawei\]sysname SW3
  36. 38. \[SW3\]vlan batch 10 20
  37. 39. \[SW3\]interface gi0/0/12
  38. 40. \[SW3-GigabitEthernet0/0/12\]port link-type trunk
  39. 41. \[SW3-GigabitEthernet0/0/12\]port trunk allow-pass vlan all
  40. 42. \[SW3-GigabitEthernet0/0/12\]quit
  41. 43. \[SW3\]interface gi0/0/13
  42. 44. \[SW3-GigabitEthernet0/0/13\]port link-type trunk
  43. 45. \[SW3-GigabitEthernet0/0/13\]port trunk allow-pass vlan all
  44. 46. \[SW3-GigabitEthernet0/0/13\]quit
  45. 47. \[SW3\]interface gi0/0/1
  46. 48. \[SW3-GigabitEthernet0/0/1\]port link-type access
  47. 49. \[SW3-GigabitEthernet0/0/1\]port default vlan 20
  48. 50. \[SW3-GigabitEthernet0/0/1\]quit
  49. 52. <Huawei>undo terminal monitor
  50. 53. <Huawei>system-view
  51. 54. \[Huawei\]sysname SW4
  52. 55. \[SW4\]vlan batch 10 20
  53. 56. \[SW4\]interface gi0/0/12
  54. 57. \[SW4-GigabitEthernet0/0/12\]port link-type trunk
  55. 58. \[SW4-GigabitEthernet0/0/12\]port trunk allow-pass vlan all
  56. 59. \[SW4-GigabitEthernet0/0/12\]quit
  57. 60. \[SW4\]interface gi0/0/13
  58. 61. \[SW4-GigabitEthernet0/0/13\]port link-type trunk
  59. 62. \[SW4-GigabitEthernet0/0/13\]port trunk allow-pass vlan all
  60. 63. \[SW4-GigabitEthernet0/0/13\]quit
  61. 64. \[SW4\]interface gi0/0/1
  62. 65. \[SW4-GigabitEthernet0/0/1\]port link-type access
  63. 66. \[SW4-GigabitEthernet0/0/1\]port default vlan 20
  64. 67. \[SW4-GigabitEthernet0/0/1\]quit

3)配置 MSTP(SW1/2/3/4 的基本 MSTP 配置,都相同)

  1. 1. \[sw1\]stp mode mstp
  2. 2. \[sw1\]stp region-configuration
  3. 3. \[sw1-mst-region\]region-name HCIE
  4. 4. \[sw1-mst-region\]instance 1 vlan 10
  5. 5. \[sw1-mst-region\]instance 2 vlan 20
  6. 6. \[sw1-mst-region\]active region-configuration

4)配置 SW1 为 VLAN 10 的根交换机

  1. 1. \[sw1\]stp instance 1 priority 0

配置 SW3 为 VLAN 20 的根交换机

  1. 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 所示。

CASE - 图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. 1. stp mode mstp
  2. 2. stp region-configuration
  3. 3. region-name HCIE
  4. 4. instance 1 vlan 10
  5. 5. instance 2 vlan 20
  6. 6. active region-configuration
  7. 7. quit

4)配置主根与次根

  1. 1. \[SW1\]stp instance 2 priority 4096
  2. 2. \[SW1\]stp instance 1 priority 8192
  3. 4. \[SW2\]stp instance 1 priority 4096
  4. 5. \[SW2\]stp instance 2 priority 8192

5)查看负载均衡

  1. 1. \[SW1\]display stp brief
  2. 2. MSTID Port Role STP State Protection
  3. 3. 1 Ethernet0/0/3 DESI FORWARDING NONE
  4. 4. 1 Ethernet0/0/10 ROOT FORWARDING NONE
  5. 5. 2 Ethernet0/0/1 DESI FORWARDING NONE
  6. 6. 2 Ethernet0/0/3 DESI FORWARDING NONE
  7. 7. 2 Ethernet0/0/10 DESI FORWARDING NONE
  8. 9. \[SW2\]display stp brief
  9. 10. MSTID Port Role STP State Protection
  10. 11. 1 Ethernet0/0/2 DESI FORWARDING NONE
  11. 12. 1 Ethernet0/0/4 DESI FORWARDING NONE
  12. 13. 1 Ethernet0/0/10 DESI FORWARDING NONE
  13. 14. 2 Ethernet0/0/4 DESI FORWARDING NONE
  14. 15. 2 Ethernet0/0/10 ROOT FORWARDING NONE
  15. 17. \[SW3\]display stp brief
  16. 18. MSTID Port Role STP State Protection
  17. 19. 1 Ethernet0/0/1 DESI FORWARDING NONE
  18. 20. 1 Ethernet0/0/3 ALTE DISCARDING NONE
  19. 21. 1 Ethernet0/0/4 ROOT FORWARDING NONE
  20. 22. 2 Ethernet0/0/2 DESI FORWARDING NONE
  21. 23. 2 Ethernet0/0/3 ROOT FORWARDING NONE
  22. 24. 2 Ethernet0/0/4 ALTE DISCARDING NONE

https://tts.tmooc.cn/ttsPage/NTD/NTDTN202109/TCNA/DAY01/CASE/01/index.html