OBJECTIVE
The purpose of this post is to present an introduction to the example for configruing basic STP functions.
Networking Requirements
Network designers tend to deploy multiple physical links between two devices (one link is the master and the others are backups) to fulfill network redundancy requirements. Loops are bound to occur on such types of complex networks.
Loops will cause broadcast storms, thereby exhausting network resources and paralyzing the network. Loops also cause MAC address flapping that damages MAC address entries.
STP can be deployed on a network to eliminate loops by blocking some ports. On the network shown in Figure 1, after RouterA, SwitchA, SwitchB, SwitchC and SwitchD 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 an interface. These capabilities help prevent replication and circular propagation of packets on the network which in turn helps improve processing performance

Figure 1 - Networking diagram of basic STP configurations
Configuration Roadmap
The configuration roadmap is as follows:
1. Configure basic STP functions, including:
a. Configure the STP mode for the ring network.
b. Configure primary and secondary root bridges.
c. Set path costs for ports to block certain ports.
d. Enable STP to eliminate loops.
Enable STP globally.
Enable STP on all the interfaces except the interfaces connected to terminals.
STP is not required on the interfaces connected to terminals because these interfaces do not need to participate in STP calculation.
Procedure
1. Configure basic STP functions.
a. Configure the STP mode for the devices on the ring network.
# Configure the STP mode on RouterA.
<Huawei> system-view
[Huawei] sysname RouterA
[RouterA] stp mode stp
# Configure the STP mode on SwitchA, SwitchB, SwitchC and SwitchD.
b. Configure primary and secondary root bridges.
# Configure RouterA as the primary root bridge.
[RouterA] stp root primary
# Configure SwitchA as the secondary root bridge.
[Routera] stp root secondary
c. Set path costs for ports in each spanning tree to block certain ports
The values of path costs depend on path cost calculation methods. This example uses the Huawei proprietary calculation method and sets the path cost to 200000.
All switching devices on a network must use the same path cost calculation method. Refer to STP List of path costs to get standard of other calculation methods.
# On RouterA, configure the path cost calculation method as the Huawei proprietary method.
[RouterA] stp pathcost-standard legacy
# On SwitchA, SwitchB, SwitchC and SwitchD, configure the path cost calculation method as the Huawei proprietary method. (The detailed configuration is not provided here.)
# As shown in Figure 1, set the path cost of Eth0/0/4 on SwitchC and SwitchD to 200000. (The detailed configuration is not provided here.)
d. Enable STP to eliminate loops.
Disable STP on interfaces connected to PCs.
# Disable STP on interfaces connected to terminals for SwitchC and SwitchD. (The detailed configuration is not provided here.)
Enable STP globally.
# Enable STP globally on RouterA
[RouterA] stp enable
# Enable STP globally on other switching devices.
Enable STP on all the interfaces except the interfaces connected to terminals.
# Enable STP on RouterA Ethernet2/0/0 and Ethernet2/0/1
[RouterA] interface ethernet 2/0/0
[RouterA-Ethernet2/0/0] stp enable
[RouterA-Ethernet2/0/0] quit
[RouterA] interface ethernet 2/0/1
[RouterA-Ethernet2/0/1] stp enable
[RouterA-Ethernet2/0/1] quit
# Enable STP on all the interfaces except the interfaces connected to terminals for SwitchA, SwitchB, SwitchC and SwitchD.
2. Verify the configuration.
After the previous configurations, run the following commands to verify the configuration when the network is stable:
# Run the display stp brief command on RouterA to view the interface status and protection type. The displayed information is as follows:
[RouterA] display stp brief
MSTID Port Role STP State Protection
0 Ethernet2/0/0 DESI FORWARDING NONE
0 Ethernet2/0/1 DESI FORWARDING NONE
After RouterA is configured as a root bridge, Ethernet2/0/0 connected to SwitchA and Ethernet2/0/1 connected to SwitchB are elected as designated ports during spanning tree calculation.
Configuration Files
Configuration file of RouterA
#
sysname RouterA
#
stp mode stp
stp instance 0 root primary
stp pathcost-standard legacy
#
interface Ethernet2/0/0
#
interface Ethernet2/0/1
#
return
Configuration file of SwitchA
#
sysname SwitchA
#
stp mode stp
stp instance 0 root secondary
stp pathcost-standard legacy
#
interface Ethernet0/0/1
#
interface Ethernet0/0/2
#
interface Ethernet0/0/3
#
return
Configuration file of SwitchB
#
sysname SwitchB
#
stp mode stp
stp pathcost-standard legacy
#
interface Ethernet0/0/1
#
interface Ethernet0/0/2
#
interface Ethernet0/0/3
#
return
Configuration file of SwitchC
#
sysname SwitchC
#
stp mode stp
stp pathcost-standard legacy
#
interface Ethernet0/0/1
#
interface Ethernet0/0/2
stp disable
#
interface Ethernet0/0/3
stp disable
#
interface Ethernet0/0/4
stp instance 0 cost 200000
#
return
Configuration file of SwitchD
#
sysname SwitchD
#
stp mode stp
stp pathcost-standard legacy
#
interface Ethernet0/0/1
#
interface Ethernet0/0/2
stp disable
#
interface Ethernet0/0/3
stp disable
#
interface Ethernet0/0/4
stp instance 0 cost 200000
#
return
--- End



