二、三层交换机STP的配置

二层交换配置STP

目标: 二层网络中有可能出现因为线路故障而导致的通信故障,通过冗余线路可以消除因为某一线路故障而导致的网络中断。
但是因为冗余线路的存在,又可能会出现广播风暴、相同帧的不断复制和MAC地址表不稳定。
• 配置Switch1为vlan1的主根,Switch2为vlan1的次根

方案:
为了保证在冗余环境下不会出广播风暴等问题,引入了生成树(STP)协议。通过生成树协议可以把冗余线路上的某一个端口置为阻塞(BLOCKING)状态,防止广播风暴的产生,当某一线路出现故障时,被阻塞的端口自动进入转发(FORWARDING)状态,保证网络的畅通性。
网络拓扑如下图所示:
二、三层交换机STP的配置_第1张图片
步骤:
步骤一:将三台交换机相连的端口配置为中继端口

tarena-sw1(config)#interface range f0/12 -13
tarena-sw1(config-if-range)#switchport mode trunk
tarena-sw2(config)#interface range f0/12, f0/23
tarena-sw2(config-if-range)#switchport mode trunk
tarena-sw3(config)#interface range f0/13 ,f0/23
tarena-sw3(config-if-range)#switchport mode trunk

步骤二:调整优先级设置tarena-sw1为根网桥
根网桥唯一的依据是BID最小。BID分为两个部分:优先级+MAC地址。比较BID时,先比较优先级,如果优先级相同才比较MAC地址。
优先级取值范围是0到65535,默认值为32768。在查看优先级时,即使是默认值看到的也不是32768,因为交换机的优先级采用系统优先级+VLAN编号的方式,所以查看到的VLAN1默认优先级是32769(系统优先级32768+VLAN编号1)。

tarena-sw1(config)# spanning-tree vlan 1 priority 28672 
tarena-sw1(config)#exit
tarena-sw1#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID   Priority    28673   //默认优先级为32768
             Address     0060.478B.607B
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    28673  (priority 24576 sys-id-ext 1)
             Address     0060.478B.607B
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20
Interface        Role   Sts   Cost      Prio.Nbr   Type
-----------    ------  --- --------   --------  ----------------------
Fa0/13           Desg    FWD    19        128.13     P2p
Fa0/12           Desg    FWD    19        128.12     P2p

查看到的结果,Root ID部分指的是根网桥信息,Bridge ID部分是当前所操作的交换机信息,如果二者一致表示当前操作的交换机就是根网桥。

三层交换配置STP

目标: 配置Switch1为vlan1的次根,Switch2为vlan1的次根。
配置Switch1为vlan2的次根,Switch2为vlan2的次根

方案:
如图网络拓扑如下图所示:
二、三层交换机STP的配置_第2张图片
步骤:
步骤一:将四台交换机相连的端口配置为中继端口,分别创建vlan2

SM1(config)#vlan 2
SM1(config)#exit
SM1(config)#interface range fastEthernet 0/1-3
SM1(config-if-range)#switchport trunk encapsulation dot1q 
SM1(config-if-range)#switchport mode trunk 
SM2(config)#vlan 2
SM2(config)#exit
SM2(config)#interface range fastEthernet 0/1-3
SM2(config-if-range)#switchport trunk encapsulation dot1q 
SM2(config-if-range)#switchport mode trunk
Switch1(config)#vlan 2
Switch1(config)#exit
Switch1(config)#interface range fastEthernet 0/1-2
Switch1(config-if-range)#switchport mode trunk
Switch2(config)#vlan 2
Switch2(config)#exit
Switch2(config)#interface range fastEthernet 0/1-2
Switch2(config-if-range)#switchport mode trunk

步骤二:设置SM1为vlan1的主根vlan2的次根,设置SM2为vlan2的主根vlan1的次根并查看

SM1(config)#spanning-tree vlan 1 root primary 
SM1(config)#spanning-tree vlan 2 root secondary
SM1#show spanning-tree 
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 24577
Address 00D0.972A.43E5
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 24577 (priority 24576 sys-id-ext 1)
Address 00D0.972A.43E5
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2 Desg FWD 19 128.2 P2p
Fa0/3 Desg FWD 19 128.3 P2p
Fa0/1 Desg FWD 19 128.1 P2p
VLAN0002
Spanning tree enabled protocol ieee
Root ID Priority 24578
Address 00E0.F9CE.7424
Cost 19
Port 3(FastEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 28674 (priority 28672 sys-id-ext 2)
Address 00D0.972A.43E5
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2 Desg FWD 19 128.2 P2p
Fa0/3 Root FWD 19 128.3 P2p
Fa0/1 Desg FWD 19 128.1 P2p
SM2(config)#spanning-tree vlan 1 root secondary 
SM2(config)#spanning-tree vlan 2 root primary 
SM2#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 24577
Address 00D0.972A.43E5
Cost 19
Port 3(FastEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 28673 (priority 28672 sys-id-ext 1)
Address 00E0.F9CE.7424
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2 Desg FWD 19 128.2 P2p
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/3 Root FWD 19 128.3 P2p
VLAN0002
Spanning tree enabled protocol ieee
Root ID Priority 24578
Address 00E0.F9CE.7424
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 24578 (priority 24576 sys-id-ext 2)
Address 00E0.F9CE.7424
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2 Desg FWD 19 128.2 P2p
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/3 Desg FWD 19 128.3 P2p

你可能感兴趣的:(思科,锐捷)