Ethernet Technology Basics · Topic 4 of 5

STP Configuration and Advanced Spanning Tree

Learn VRP STP commands, RSTP port roles and states, proposal and agreement, edge ports, BPDU and root protection, and MSTP instances for H12-811.

  • 5 min
In a nutshell
  • stp root primary sets priority 0; stp root secondary sets 4096.
  • RSTP roles: root, designated, alternate, backup, plus edge ports.
  • RSTP states: Discarding, Learning, Forwarding.

What it is

Basic STP configuration on a Huawei switch means choosing the spanning tree mode, deciding which switch is root, and tuning costs and priorities so the blocked ports are the ones you expect.

Advanced spanning tree protocols fix STP's slow convergence and single tree. RSTP (IEEE 802.1w) converges in seconds, and MSTP (IEEE 802.1s) runs several spanning tree instances so different VLANs can use different paths. Huawei switches run MSTP by default and enable spanning tree by default.

STP802.1D, about 30 sRSTP802.1w, fast convergenceMSTP802.1s, instances map VLANs

How it works

Basic STP commands

[SW1] stp mode stp
[SW1] stp priority 4096
[SW2] stp root secondary
[SW3] interface GigabitEthernet0/0/2
[SW3-GigabitEthernet0/0/2] stp cost 50000
[SW3-GigabitEthernet0/0/2] stp port priority 32
CommandEffect
stp mode stp, rstp or mstpSets the mode; default is mstp
stp priority 4096Sets the bridge priority, a multiple of 4096
stp root primaryMakes the switch root by setting priority 0
stp root secondaryMakes the switch backup root by setting priority 4096
stp cost 50000Sets the port's path cost
stp port priority 32Sets the port priority, a multiple of 16
stp enable or stp disableTurns spanning tree on or off

Check the result with display stp brief, which lists each port's role, state and protection.

<SW3> display stp brief
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        ROOT  FORWARDING      NONE
   0    GigabitEthernet0/0/2        ALTE  DISCARDING      NONE

display stp shows the full detail: the bridge ID, the root ID, root path cost and timers.

RSTP port roles and states

RoleMeaning
Root portBest path to the root, as in STP
Designated portForwards toward a segment, as in STP
Alternate portBlocked backup for the root port; its best BPDU comes from another switch
Backup portBlocked backup for a designated port; it receives BPDUs from its own switch on the same segment
Edge portConnects a terminal, goes straight to forwarding, does not take part in the calculation

RSTP reduces the five STP states to three.

STP statesRSTP state
Disabled, Blocking, ListeningDiscarding
LearningLearning
ForwardingForwarding

How RSTP converges quickly

  • Proposal and agreement (P/A). On a point-to-point full-duplex link, a designated port sends a proposal. The downstream switch syncs by blocking its other non-edge designated ports and returns an agreement, so the link forwards at once instead of waiting 30 s.
  • Edge ports. A port set with stp edged-port enable goes to forwarding immediately. If it receives a BPDU, it loses edge status and joins the calculation.
  • Fast root port change. When the root port fails, the alternate port becomes root port and forwards at once.
  • Every switch sends BPDUs. RSTP switches send their own BPDUs every Hello Time, and treat BPDUs missed for three Hello intervals as a lost neighbor (Huawei multiplies this by a timer factor, stp timer-factor).
Designated portsends proposalDownstream switchsyncs other portsAgreement returnedLink forwardsno 30 s wait

In RSTP, a topology change is flushed through the network with TC BPDUs, and only non-edge ports clear their learned MAC entries.

Protection features

FeatureCommandProtects against
BPDU protectionstp bpdu-protection (system view)An edge port receiving BPDUs; the port is shut down
Root protectionstp root-protection (interface)A designated port receiving a better BPDU that would move the root
Loop protectionstp loop-protection (interface)A root or alternate port that stops receiving BPDUs and would wrongly start forwarding

MSTP

STP and RSTP build one tree for all VLANs, so a blocked link carries no traffic at all. MSTP groups switches into an MST region with the same region name, revision level and VLAN-to-instance mapping. Each MSTI (instance) has its own root and its own blocked ports, so VLAN 10 and VLAN 20 can use different links.

[SW1] stp region-configuration
[SW1-mst-region] region-name RG1
[SW1-mst-region] instance 1 vlan 10
[SW1-mst-region] instance 2 vlan 20
[SW1-mst-region] active region-configuration
[SW1-mst-region] quit
[SW1] stp instance 1 root primary
[SW1] stp instance 2 root secondary

By default every VLAN maps to instance 0, the CIST. MSTP is backward compatible with STP and RSTP.

A worked example

PCs on SW3 GE0/0/3 to GE0/0/20 must not wait 30 s at boot, and nobody should plug a rogue switch in there. The engineer sets stp mode rstp everywhere, sets those ports with stp edged-port enable, and enables stp bpdu-protection on SW3.

If a user connects a switch that sends BPDUs to GE0/0/5, that edge port is shut down instead of letting the rogue device join the tree.

How the exam asks about this

  • "Which RSTP port role is a backup of the root port?" → The alternate port.
  • "Which STP states map to the RSTP Discarding state?" → Disabled, Blocking and Listening.
  • "What is the default spanning tree mode on a Huawei switch?" → MSTP.

What to remember for the exam

  • stp root primary sets priority 0; stp root secondary sets 4096.
  • RSTP roles: root, designated, alternate, backup, plus edge ports.
  • RSTP states: Discarding, Learning, Forwarding.
  • Edge ports forward at once; BPDU protection shuts down an edge port that gets a BPDU.
  • MSTP maps VLANs to instances; all VLANs start in instance 0.
Watch out

An alternate port backs up the root port, and a backup port backs up a designated port on the same switch. The exam swaps these two definitions.

Common mistakes

Assuming the default mode is STP. Huawei switches run MSTP by default. You set stp mode stp or stp mode rstp to change it.

Configuring edge ports toward switches. An edge port toward another switch can briefly create a loop. Use edge ports only toward terminals.

Mismatching MSTP region settings. If the region name, revision level or VLAN mapping differ, the switches are in different regions and behave unexpectedly.

Check yourself

  • Which command makes a switch the backup root bridge, and what priority does it set?

    stp root secondary, which sets the bridge priority to 4096.

  • What happens when an edge port with BPDU protection enabled receives a BPDU?

    The port is shut down, so the device sending BPDUs cannot join the spanning tree.

  • Why does MSTP let VLANs use different links?

    Each MST instance has its own root and blocked ports, and VLANs are mapped to different instances.

Topic 4 of 5 in Ethernet Technology Basics

Test yourself on Ethernet Technology Basics

The full Huawei HCIA-Datacom H12-811 question bank has 600 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Huawei. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.