Top

NTD TCNA DAY04

  1. 案例1:STP算法
  2. 案例2:配置STP
  3. 案例3:配置MSTP及负载均衡

1 案例1:STP算法

1.1 问题

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

1.2 方案

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

1.3 步骤

实现此案例需要按照如下步骤进行。
1)每个广播域选择根网桥(Root Bridge)

  • 每个非根网桥选择根端口(Root Ports)
  • 每个网段上选择指定端口(Designated Ports)

2)结果如图-2所示
TCNA DAY04 - 图2
图-2

2 案例2:配置STP

2.1 问题

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

2.2 方案

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

2.3 步骤

实现此案例需要按照如下步骤进行。
1)配置STP
[A]stp mode stp //设置生成树stp模式
[B]stp mode stp
[C]stp mode stp
[D]stp mode stp

2)查看根网桥
[A]dis stp //显示生成树信息
———-[CIST Global Info][Mode STP]———-
CIST Bridge :32768.4c1f-cc3b-03cb //自己的网桥ID
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.4c1f-cc17-3481 / 200000 //根网桥网桥ID
CIST RegRoot/IRPC :32768.4c1f-cc3b-03cb / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
TC or TCN received :106
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:9m:8s
Number of TC :12
Last TC occurred :Ethernet0/0/2

[B]dis stp
———-[CIST Global Info][Mode STP]———-
CIST Bridge :32768.4c1f-cc17-3481
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.4c1f-cc17-3481 / 0
CIST RegRoot/IRPC :32768.4c1f-cc17-3481 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :23
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:9m:52s
Number of TC :13
Last TC occurred :Ethernet0/0/4

[C]dis stp
———-[CIST Global Info][Mode STP]———-
CIST Bridge :32768.4c1f-cc50-3d65
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.4c1f-cc17-3481 / 400000
CIST RegRoot/IRPC :32768.4c1f-cc50-3d65 / 0
CIST RootPortId :128.4
BPDU-Protection :Disabled
TC or TCN received :92
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:10m:26s
Number of TC :11
Last TC occurred :Ethernet0/0/4

[D]dis stp
———-[CIST Global Info][Mode STP]———-
CIST Bridge :32768.4c1f-cc22-4507
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.4c1f-cc17-3481 / 200000
CIST RegRoot/IRPC :32768.4c1f-cc22-4507 / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
TC or TCN received :49
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:11m:12s
Number of TC :13
Last TC occurred :Ethernet0/0/2

可以看出,交换机B是根网桥。
3)配置交换机A为根网桥
[A]stp priority 4096 //设置交换机的网桥优先级为4096
[A]dis stp
———-[CIST Global Info][Mode STP]———-
CIST Bridge :4096 .4c1f-cc3b-03cb
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc3b-03cb / 0
CIST RegRoot/IRPC :4096 .4c1f-cc3b-03cb / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :108
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:14s
Number of TC :15
Last TC occurred :Ethernet0/0/3

此时,根网桥已经是交换机A了。

3 案例3:配置MSTP及负载均衡

3.1 问题

  1. 配置MSTP实现多生成树效果
  2. 配置A成为vlan 10 和 20 的主根,vlan 30 和 40 的次根
  3. 配置B成为vlan 30 和 40 的主根,vlan 10 和 20 的次根
  4. 查看配置信息

    3.2 方案

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

    3.3 步骤

    实现此案例需要按照如下步骤进行。
    1)基本配置
    [A]vlan batch 10 20 30 40
    [A]int e0/0/2
    [A-Ethernet0/0/2]port link-type trunk
    [A-Ethernet0/0/2]port trunk allow-pass vlan all
    [A]int e0/0/3
    [A-Ethernet0/0/3]port link-type trunk
    [A-Ethernet0/0/3]port trunk allow-pass vlan all

交换机B、C也同样配置。
2)配置MSTP
[A]stp region-configuration //进入生成树区域配置
[A-mst-region]region-name tedu //设置生成树区域名称
[A-mst-region]instance 1 vlan 10 20 //创建生成树实例并指定此实例允许的vlan
[A-mst-region]instance 2 vlan 30 40
[A-mst-region]active region-configuration //激活生此成树区域

3)查看配置:
[A-mst-region]dis this //显示当前配置信息
#
stp region-configuration
region-name tedu
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration
#
return

交换机B、C也同样配置。
4)配置主根与次根
[A]stp instance 1 priority 4096 //指定交换机A为instance 1的主根
[A]stp instance 2 priority 8192 //指定交换机A为instance 2的备根

[B]stp instance 2 priority 4096 //指定交换机B为instance 2的主根
[B]stp instance 1 priority 8192 //指定交换机B为instance 1的备根

5)验证
[A]dis stp instance 1 //在交换机A上显示第一个实例的生成树信息
———-[MSTI 1 Global Info]———-
MSTI Bridge ID :4096.4c1f-cc87-1de7 //自己的网桥ID
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 0 //根网桥的网桥ID
MSTI RootPortId :0.0
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :5
TC count per hello :0
Time since last TC :0 days 0h:3m:6s
Number of TC :4
Last TC occurred :Ethernet0/0/2
——[Port2(Ethernet0/0/2)][FORWARDING]——
Port Role :Designated Port //此端口为指定端口
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.2
Port Times :RemHops 20
TC or TCN send :4
TC or TCN received :3
——[Port3(Ethernet0/0/3)][FORWARDING]——
Port Role :Designated Port //此端口为指定端口
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2

[A]dis stp instance 2 //在交换机B上显示第二个实例的生成树信息
———-[MSTI 2 Global Info]———-
MSTI Bridge ID :8192.4c1f-cc87-1de7
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 200000
MSTI RootPortId :128.2
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:3m:49s
Number of TC :4
Last TC occurred :Ethernet0/0/2
——[Port2(Ethernet0/0/2)][FORWARDING]——
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.1
Port Times :RemHops 20
TC or TCN send :4
TC or TCN received :3
——[Port3(Ethernet0/0/3)][FORWARDING]——
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 19
TC or TCN send :2
TC or TCN received :1

[B]dis stp instance 1 //在交换机B上显示第一个实例的生成树信息
———-[MSTI 1 Global Info]———-
MSTI Bridge ID :8192.4c1f-cc0d-76bc //自己的网桥ID
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 200000 //根网桥的网桥ID
MSTI RootPortId :128.1
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :0
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:5m:26s
Number of TC :4
Last TC occurred :Ethernet0/0/3
——[Port1(Ethernet0/0/1)][FORWARDING]——
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.2
Port Times :RemHops 20
TC or TCN send :3
TC or TCN received :4
——[Port3(Ethernet0/0/3)][FORWARDING]——
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 19
TC or TCN send :1
TC or TCN received :0

[B]dis stp instance 2 //在交换机B上显示第二个实例的生成树信息
———-[MSTI 2 Global Info]———-
MSTI Bridge ID :4096.4c1f-cc0d-76bc //自己的网桥ID
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 0 //根网桥的网桥ID
MSTI RootPortId :0.0
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :0
TC received :6
TC count per hello :0
Time since last TC :0 days 0h:6m:4s
Number of TC :5
Last TC occurred :Ethernet0/0/3
——[Port1(Ethernet0/0/1)][FORWARDING]——
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.1
Port Times :RemHops 20
TC or TCN send :3
TC or TCN received :4
——[Port3(Ethernet0/0/3)][FORWARDING]——
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2

[C]dis stp instance 1 //在交换机C上显示第一个实例的生成树信息
———-[MSTI 1 Global Info]———-
MSTI Bridge ID :32768.4c1f-ccb8-32b8
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 200000
MSTI RootPortId :128.1
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :3
TC count per hello :0
Time since last TC :0 days 0h:6m:58s
Number of TC :3
Last TC occurred :Ethernet0/0/1
——[Port1(Ethernet0/0/1)][FORWARDING]——
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
——[Port2(Ethernet0/0/2)][DISCARDING]——
Port Role :Alternate Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 19
TC or TCN send :0
TC or TCN received :1

[C]dis stp instance 2 //在交换机C上显示第二个实例的生成树信息
———-[MSTI 2 Global Info]———-
MSTI Bridge ID :32768.4c1f-ccb8-32b8
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 200000
MSTI RootPortId :128.2
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:7m:32s
Number of TC :4
Last TC occurred :Ethernet0/0/2
——[Port1(Ethernet0/0/1)][DISCARDING]——
Port Role :Alternate Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 19
TC or TCN send :1
TC or TCN received :2
——[Port2(Ethernet0/0/2)][FORWARDING]——
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2

6)查看负载均衡
[A]dis stp bri //显示生成树的摘要信息
MSTID Port Role STP State Protection
0 Ethernet0/0/2 ROOT FORWARDING NONE
0 Ethernet0/0/3 DESI FORWARDING NONE
1 Ethernet0/0/2 DESI FORWARDING NONE
1 Ethernet0/0/3 DESI FORWARDING NONE
2 Ethernet0/0/2 ROOT FORWARDING NONE
2 Ethernet0/0/3 DESI FORWARDING NONE

[B]dis stp bri
MSTID Port Role STP State Protection
0 Ethernet0/0/1 DESI FORWARDING NONE
0 Ethernet0/0/3 DESI FORWARDING NONE
1 Ethernet0/0/1 ROOT FORWARDING NONE
1 Ethernet0/0/3 DESI FORWARDING NONE
2 Ethernet0/0/1 DESI FORWARDING NONE
2 Ethernet0/0/3 DESI FORWARDING NONE

[C]dis stp bri
MSTID Port Role STP State Protection
0 Ethernet0/0/1 ALTE DISCARDING NONE
0 Ethernet0/0/2 ROOT FORWARDING NONE
1 Ethernet0/0/1 ROOT FORWARDING NONE
1 Ethernet0/0/2 ALTE DISCARDING NONE
2 Ethernet0/0/1 ALTE DISCARDING NONE
2 Ethernet0/0/2 ROOT FORWARDING NONE

C上VLAN 10、VLAN 20的流量通过Ethernet0/0/1口到A,VLAN 30、VLAN 40的流量通过Ethernet0/0/2口到B,实现了链路的负载。