This example shows how to configure basic STP functions.
Networking Requirements
On a complex network, loops are inevitable. With the requirement for network redundancy backup, network designers tend to deploy multiple physical links between two devices, one of which is the master and the others are the backup. Loops are likely or bound to occur in such a situation.
Loops will cause broadcast storms, thereby exhausting network resources and paralyzing the network. Loops also cause flapping of MAC address tables and thus damages MAC address entries.
STP can be deployed on a network to eliminate loops by blocking some ports. On the network shown in Figure 13-6, after Device A, Device B, Device C, and Device D running STP discover loops on the network by exchanging information with each other, they trim the ring topology into a loop-free tree topology by blocking a certain port. In this manner, replication and circular propagation of packets are prevented on the network and the switching devices are released from processing duplicated packets, thereby improving their processing performance.
Configuration Roadmap
- Configure basic STP functions, including:
Configure the STP mode for the ring network.
Configure primary and secondary root bridges.
Set path costs for ports to block certain ports.
- Enable STP to eliminate loops, including:
Enable STP globally.
Enable STP on all the interfaces except the interfaces connected to terminals.
NOTE:
STP is not required on the interfaces connected to terminals because these interfaces do not need to participate in STP calculation.
Data Preparation
GE interface number, as shown in Figure 13-6
Primary root bridge Device A and secondary root bridge Device D
Path cost of a port to be blocked (20000 is used in this example)
Procedure
- Configure basic STP functions.
Configure the STP mode for the devices on the ring network.
# Configure the STP mode on Device A.
<HUAWEI> system-view[~HUAWEI] sysname DeviceA[*HUAWEI] stp mode stp[*HUAWEI] commit
# Configure the STP mode on Device B.
<HUAWEI> system-view[~HUAWEI] sysname DeviceB[*HUAWEI] stp mode stp[*HUAWEI] commit
# Configure the STP mode on Device C.
<HUAWEI> system-view[~HUAWEI] sysname DeviceC[*HUAWEI] stp mode stp[*HUAWEI] commit
# Configure the STP mode on Device D.
<HUAWEI> system-view[~HUAWEI] sysname DeviceD[*HUAWEI] stp mode stp[*HUAWEI] commit
Configure primary and secondary root bridges.
# Configure Device A as a primary root bridge.
[~DeviceA] stp root primary[*DeviceA] commit
# Configure Device D as a secondary root bridge.
[~DeviceD] stp root secondary[*DeviceD] commit
Set path costs for ports in each spanning tree to block certain ports.
NOTE:
The values of path costs depend on path cost calculation methods. Use the Huawei proprietary calculation method as an example to set the path costs of the ports to be blocked to 20000.
All switching devices on a network must use the same path cost calculation method.
# On Device A, configure the path cost calculation method as the Huawei proprietary method.
[~DeviceA] stp pathcost-standard legacy[*DeviceA] commit
# On Device B, configure the path cost calculation method as the Huawei proprietary method.
[~DeviceB] stp pathcost-standard legacy[*DeviceB] commit
# On Device C, configure the path cost calculation method as the Huawei proprietary method and set the path cost of GE 0/1/1 to 20000.
[~DeviceC] stp pathcost-standard legacy[*DeviceC] interface gigabitethernet 0/1/1[*DeviceC-GigabitEthernet0/1/1] stp cost 20000[*DeviceC-GigabitEthernet0/1/1] commit[~DeviceC-GigabitEthernet0/1/1] quit
# On Device D, configure the path cost calculation method as the Huawei proprietary method.
[~DeviceD] stp pathcost-standard legacy[*DeviceD] commit
Enable STP to eliminate loops.
Disable STP on interfaces connected to PCs.
# Disable STP on GE 0/1/2 on Device B.
[~DeviceB] interface gigabitethernet 0/1/2[~DeviceB-GigabitEthernet0/1/2] stp disable[*DeviceB-GigabitEthernet0/1/2] commit[~DeviceB-GigabitEthernet0/1/2] quit
# Disable STP on GE 0/1/2 on Device C.
[~DeviceC] interface gigabitethernet 0/1/2[~DeviceC-GigabitEthernet0/1/2] stp disable[*DeviceC-GigabitEthernet0/1/2] commit[~DeviceC-GigabitEthernet0/1/2] quit
Enable STP globally.
# Enable STP globally on Device A.
[~DeviceA] stp enable[*DeviceA] commit
# Enable STP globally on Device B.
[~DeviceB] stp enable[*DeviceB] commit
# Enable STP globally on Device C.
[~DeviceC] stp enable[*DeviceC] commit
# Enable STP globally on Device D.
[~DeviceD] stp enable[*DeviceD] commit
Enable STP on all the interfaces except the interfaces connected to terminals.
# Enable STP on GE 0/1/1 and GE 0/1/2 on Device A.
[~DeviceA] interface gigabitethernet 0/1/1[~DeviceA-GigabitEthernet0/1/1] undo shutdown[*DeviceA-GigabitEthernet0/1/1] portswitch[*DeviceA-GigabitEthernet0/1/1] stp enable[*DeviceA-GigabitEthernet0/1/1] quit[*DeviceA] interface gigabitethernet 0/1/2[*DeviceA-GigabitEthernet0/1/2] undo shutdown[*DeviceA-GigabitEthernet0/1/2] portswitch[*DeviceA-GigabitEthernet0/1/2] stp enable[*DeviceA-GigabitEthernet0/1/2] commit[~DeviceA-GigabitEthernet0/1/2] quit
# Enable STP on GE 0/1/1 and GE 0/1/3 on Device B.
[~DeviceB] interface gigabitethernet 0/1/1[~DeviceB-GigabitEthernet0/1/1] undo shutdown[*DeviceB-GigabitEthernet0/1/1] portswitch[*DeviceB-GigabitEthernet0/1/1] stp enable[*DeviceB-GigabitEthernet0/1/1] quit[*DeviceB] interface gigabitethernet 0/1/3[*DeviceB-GigabitEthernet0/1/3] undo shutdown[*DeviceB-GigabitEthernet0/1/3] portswitch[*DeviceB-GigabitEthernet0/1/3] stp enable[*DeviceB-GigabitEthernet0/1/3] commit[~DeviceB-GigabitEthernet0/1/3] quit
# Enable STP on GE 0/1/1 and GE 0/1/3 on Device C.
[~DeviceC] interface gigabitethernet 0/1/1[~DeviceC-GigabitEthernet0/1/1] undo shutdown[*DeviceC-GigabitEthernet0/1/1] portswitch[*DeviceC-GigabitEthernet0/1/1] stp enable[*DeviceC-GigabitEthernet0/1/1] quit[*DeviceC] interface gigabitethernet 0/1/3[*DeviceC-GigabitEthernet0/1/3] undo shutdown[*DeviceC-GigabitEthernet0/1/3] portswitch[*DeviceC-GigabitEthernet0/1/3] stp enable[*DeviceC-GigabitEthernet0/1/3] commit[~DeviceC-GigabitEthernet0/1/3] quit
# Enable STP on GE 0/1/1 and GE 0/1/2 on Device D.
[~DeviceD] interface gigabitethernet 0/1/1[~DeviceD-GigabitEthernet0/1/1] undo shutdown[*DeviceD-GigabitEthernet0/1/1] portswitch[*DeviceD-GigabitEthernet0/1/1] stp enable[*DeviceD-GigabitEthernet0/1/1] quit[*DeviceD] interface gigabitethernet 0/1/2[*DeviceD-GigabitEthernet0/1/2] undo shutdown[*DeviceD-GigabitEthernet0/1/2] portswitch[*DeviceD-GigabitEthernet0/1/2] stp enable[*DeviceD-GigabitEthernet0/1/2] commit[~DeviceD-GigabitEthernet0/1/2] quit