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.
RSTP can be deployed on a network to eliminate loops by blocking ports. In Figure 1, a loop exists on the network, and SwitchA, SwitchB, SwitchC, and SwitchD are all running RSTP. These devices exchange BPDUs to discover the loops and block the appropriate ports in order to trim the ring topology into a loop-free tree topology, improving packet processing performance.
Configure the RSTP mode for the switches on the ring network.
Configure the root bridge and secondary root bridge.
Set a path cost for the ports to be blocked.
Enable RSTP to eliminate loops. Because ports connected to the PCs do not participate in RSTP calculation, configure both of these ports as edge ports.
Configure RSTP protection functions. For example, configure root protection on designated ports of the root bridge.
Configure the RSTP mode for the switches on the ring network.
# Configure the RSTP mode on SwitchA.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] stp mode rstp
# Configure the RSTP mode on SwitchB.
<HUAWEI> system-view [HUAWEI] sysname SwitchB [SwitchB] stp mode rstp
# Configure the RSTP mode on SwitchC.
<HUAWEI> system-view [HUAWEI] sysname SwitchC [SwitchC] stp mode rstp
# Configure the RSTP mode on SwitchD.
<HUAWEI> system-view [HUAWEI] sysname SwitchD [SwitchD] stp mode rstp
Configure the root bridge and secondary root bridge.
# Configure SwitchA as the root bridge.
[SwitchA] stp root primary
# Configure SwitchD as the secondary root bridge.
[SwitchD] stp root secondary
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
# On SwitchB, set the path cost calculation method to the Huawei proprietary method.
[SwitchB] stp pathcost-standard legacy
# On SwitchC, set the path cost of GigabitEthernet0/0/1 to 20000.
[SwitchC] stp pathcost-standard legacy [SwitchC] interface gigabitethernet 0/0/1 [SwitchC-GigabitEthernet0/0/1] stp cost 20000 [SwitchC-GigabitEthernet0/0/1] quit
# On SwitchD, set the path cost calculation method to the Huawei proprietary method.
[SwitchD] stp pathcost-standard legacy
Enable RSTP to eliminate loops.
Configure the ports connected to PCs both as edge ports.
# Configure GigabitEthernet0/0/2 on SwitchB as an edge port.
[SwitchB] interface gigabitethernet 0/0/2 [SwitchB-GigabitEthernet0/0/2] stp edged-port enable [SwitchB-GigabitEthernet0/0/2] quit
(Optional) Configure BPDU protection on SwitchB.
[SwitchB] stp bpdu-protection
# Configure GigabitEthernet0/0/2 on SwitchC as an edge port.
[SwitchC] interface gigabitethernet 0/0/2 [SwitchC-GigabitEthernet0/0/2] stp edged-port enable [SwitchC-GigabitEthernet0/0/2] quit
(Optional) Configure BPDU protection on SwitchC.
[SwitchC] stp bpdu-protection
If edge ports are connected to network devices that have STP enabled and BPDU protection is enabled, the edge ports will be shut down and their attributes remain unchanged after they receive BPDUs.
Enable RSTP globally.
# Enable RSTP globally on SwitchA.
[SwitchA] stp enable
# Enable RSTP globally on SwitchB.
[SwitchB] stp enable
# Enable RSTP globally on SwitchC.
[SwitchC] stp enable
# Enable RSTP globally on SwitchD.
[SwitchD] stp enable
# Enable root protection on GE0/0/1 on SwitchA.
[SwitchA] interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1] stp root-protection [SwitchA-GigabitEthernet0/0/1] quit
# Enable root protection on GE0/0/2 on SwitchA.
[SwitchA] interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2] stp root-protection [SwitchA-GigabitEthernet0/0/2] quit
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 check the port roles and states.
[SwitchA] display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING ROOT 0 GigabitEthernet0/0/2 DESI FORWARDING ROOT
After SwitchA is configured as the root bridge, GigabitEthernet0/0/2 connected to SwitchB and GigabitEthernet0/0/1 connected to SwitchD are elected as designated ports through spanning tree calculation. Root protection is enabled on the designated ports.
# Run the display stp interface gigabitethernet 0/0/1 brief command on SwitchB to check the role and state of GigabitEthernet0/0/1.
[SwitchB] display stp interface gigabitethernet 0/0/1 brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE
GigabitEthernet0/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.
[SwitchC] display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 ALTE DISCARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING BPDU 0 GigabitEthernet0/0/3 ROOT FORWARDING NONE
GE0/0/1 is elected as an alternate port and is in Discarding state.
GE0/0/3 is elected as a root port and is in Forwarding state.
SwitchA configuration file
# sysname SwitchA # stp mode rstp stp instance 0 root primary stp pathcost-standard legacy # interface GigabitEthernet0/0/1 stp root-protection # interface GigabitEthernet0/0/2 stp root-protection # return
SwitchB configuration file
# sysname SwitchB # stp mode rstp stp bpdu-protection stp pathcost-standard legacy # interface GigabitEthernet0/0/2 stp edged-port enable # return
SwitchC configuration file
# sysname SwitchC # stp mode rstp stp bpdu-protection stp pathcost-standard legacy # interface GigabitEthernet0/0/1 stp instance 0 cost 20000 # interface GigabitEthernet0/0/2 stp edged-port enable # return
SwitchD configuration file
#
sysname SwitchD
#
stp mode rstp
stp instance 0 root secondary
stp pathcost-standard legacy
#
return