Example for Configuring STP
Networking Requirements
On a complex network, multiple physical links are often deployed between two devices for link redundancy (one as the active link and the others as standby links). However, redundant links may cause loops on the network, which result in broadcast storms and unstable MAC address entries.
STP can be deployed on a network to eliminate loops by blocking ports. In Figure 9-17, a loop exists on the network, and SwitchA, SwitchB, SwitchC, and SwitchD are all running STP. These devices exchange STP BPDUs to discover loops and block some ports to prune the network into a loop-free tree network, improving packet processing performance.
Configuration Roadmap
Configure the STP mode for the devices on the ring network.
Configure the root bridge and secondary root bridge.
Set a path cost for the ports to be blocked.
- Enable STP to eliminate loops.
The ports connected to servers do not participate in STP calculation. Disable STP on these ports.
Verify the configuration.
Procedure
- Configure the STP mode for the devices on the ring network. The configurations on SwitchB, SwitchC, and SwitchD are similar to the configurations on SwitchA, and are not mentioned here.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] stp mode stp [*SwitchA] commit
- Configure the root bridge and secondary root bridge.
# Configure SwitchA as the root bridge.
[~SwitchA] stp root primary [*SwitchA] commit
# Configure SwitchB as the secondary root bridge.
[~SwitchB] stp root secondary [*SwitchB] commit
- Set a path cost for the ports to be blocked.
The path cost value range depends on path cost calculation methods, which must be the same on all switches. This example uses the Huawei proprietary calculation method.
# On SwitchA, set the path cost calculation method to the Huawei proprietary method.
[~SwitchA] stp pathcost-standard legacy [*SwitchA] commit
# On SwitchB, set the path cost calculation method to the Huawei proprietary method.
[~SwitchB] stp pathcost-standard legacy [*SwitchB] commit
# Set the path cost of 10GE1/0/1 on SwitchC to 20000.
[~SwitchC] stp pathcost-standard legacy [*SwitchC] interface 10ge 1/0/1 [*SwitchC-10GE1/0/1] stp cost 20000 [*SwitchC-10GE1/0/1] commit [~SwitchC-10GE1/0/1] quit
# On SwitchD, set the path cost calculation method to the Huawei proprietary method.
[~SwitchD] stp pathcost-standard legacy [*SwitchD] commit
- Enable STP to eliminate loops.
Disable STP on the port connected to the server.
# Disable STP on 10GE1/0/2 of SwitchB.
[~SwitchB] interface 10ge 1/0/2 [~SwitchB-10GE1/0/2] stp disable [*SwitchB-10GE1/0/2] commit [~SwitchB-10GE1/0/2] quit
# Disable STP on 10GE1/0/2 of SwitchC.
[~SwitchC] interface 10ge 1/0/2 [~SwitchC-10GE1/0/2] stp disable [*SwitchC-10GE1/0/2] commit [~SwitchC-10GE1/0/2] quit
Enable STP globally on devices.
[~SwitchA] stp enable [*SwitchA] commit
[~SwitchB] stp enable [*SwitchB] commit
[~SwitchC] stp enable [*SwitchC] commit
[~SwitchD] stp enable [*SwitchD] commit
- Verify the configuration.
After the preceding configuration is complete and the network becomes stable, perform the following operations to verify the configuration:
# Run the display stp brief command on SwitchA to view the port roles and states. The following information is displayed:
[~SwitchA] display stp brief MSTID Port Role STP State Protection Cost Edged 0 10GE1/0/1 DESI forwarding none 2 disable 0 10GE1/0/2 DESI forwarding none 2 disable
After SwitchA is configured as the root bridge, 10GE1/0/2 and 10GE1/0/1 connected to SwitchB and SwitchD respectively are elected as designated ports through spanning tree calculation.
# Run the display stp interface 10GE 1/0/1 brief command on SwitchB to view the role and state of 10GE1/0/1. The following information is displayed:
[~SwitchB] display stp interface 10ge 1/0/1 brief MSTID Port Role STP State Protection Cost Edged 0 10GE1/0/1 DESI forwarding none 2 disable
10GE1/0/1 is elected as a designated port and is in Forwarding state.
# Run the display stp brief command on SwitchC to check the port roles and states. The following information is displayed:
[~SwitchC] display stp brief MSTID Port Role STP State Protection Cost Edged 0 10GE1/0/1 ALTE discarding none 20000 disable 0 10GE1/0/3 ROOT forwarding none 2 disable
10GE1/0/1 is elected as an alternate port and is in Discarding state.
10GE1/0/3 is elected as a root port and is in Forwarding state.
Configuration Files
SwitchA configuration file
# sysname SwitchA # stp mode stp stp instance 0 root primary stp pathcost-standard legacy # return
SwitchB configuration file
# sysname SwitchB # stp mode stp stp instance 0 root secondary stp pathcost-standard legacy # interface 10GE1/0/2 stp disable # return
SwitchC configuration file
# sysname SwitchC # stp mode stp stp pathcost-standard legacy # interface 10GE1/0/1 stp instance 0 cost 20000 # interface 10GE1/0/2 stp disable # return
SwitchD configuration file
# sysname SwitchD # stp mode stp stp pathcost-standard legacy # return