Example for Configuring Basic STP Functions

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 1, after DeviceA, DeviceB, DeviceC, and DeviceD 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 devices are released from processing duplicated packets, thereby improving their processing performance.

Figure 1 Networking diagram of configuring basic STP functions

Interfaces 1 through 3 in this example represent GE 0/1/1, GE 0/1/2, and GE 0/1/3, respectively.



Configuration Roadmap

The configuration roadmap is as follows:
  1. Configure basic STP functions, including:
    1. Configure the STP mode for the ring network.

    2. Configure primary and secondary root bridges.

    3. Set path costs for ports to block certain ports.

    4. Enable STP to eliminate loops, including:
      • 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.

Data Preparation

To complete the configuration, you need the following data.
  • GE interface number, as shown in Figure 1

  • Primary root bridge DeviceA and secondary root bridge DeviceD

  • Path cost of a port to be blocked (20000 is used in this example)

Procedure

  1. Configure basic STP functions.

    1. Configure the STP mode for the devices on the ring network.

      # Configure the STP mode on DeviceA.

      <HUAWEI> system-view
      [~HUAWEI] sysname DeviceA
      [*HUAWEI] stp mode stp
      [*HUAWEI] commit

      # Configure the STP mode on DeviceB.

      <HUAWEI> system-view
      [~HUAWEI] sysname DeviceB
      [*HUAWEI] stp mode stp
      [*HUAWEI] commit

      # Configure the STP mode on DeviceC.

      <HUAWEI> system-view
      [~HUAWEI] sysname DeviceC
      [*HUAWEI] stp mode stp
      [*HUAWEI] commit

      # Configure the STP mode on DeviceD.

      <HUAWEI> system-view
      [~HUAWEI] sysname DeviceD
      [*HUAWEI] stp mode stp
      [*HUAWEI] commit
    2. Configure primary and secondary root bridges.

      # Configure DeviceA as a primary root bridge.

      [~DeviceA] stp root primary
      [*DeviceA] commit

      # Configure DeviceD as a secondary root bridge.

      [~DeviceD] stp root secondary
      [*DeviceD] commit
    3. Set path costs for ports in each spanning tree to block certain ports.

      • 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 devices on a network must use the same path cost calculation method.

      # On DeviceA, configure the path cost calculation method as the Huawei proprietary method.

      [~DeviceA] stp pathcost-standard legacy
      [*DeviceA] commit

      # On DeviceB, configure the path cost calculation method as the Huawei proprietary method.

      [~DeviceB] stp pathcost-standard legacy
      [*DeviceB] commit

      # On DeviceC, 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 DeviceD, configure the path cost calculation method as the Huawei proprietary method.

      [~DeviceD] stp pathcost-standard legacy
      [*DeviceD] commit
    4. Enable STP to eliminate loops.

      • Disable STP on interfaces connected to PCs.

        # Disable STP on GE 0/1/2 on DeviceB.

        [~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 DeviceC.

        [~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 DeviceA.

        [~DeviceA] stp enable
        [*DeviceA] commit

        # Enable STP globally on DeviceB.

        [~DeviceB] stp enable
        [*DeviceB] commit

        # Enable STP globally on DeviceC.

        [~DeviceC] stp enable
        [*DeviceC] commit

        # Enable STP globally on DeviceD.

        [~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 DeviceA.

        [~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 DeviceB.

        [~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 DeviceC.

        [~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 DeviceD.

        [~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

  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 DeviceA to view the interface status and protection type. The displayed information is as follows:

    [~DeviceA] display stp brief
     MSTID  Port                        Role  STP State     Protection
       0    GigabitEthernet0/1/1        DESI  FORWARDING      NONE
       0    GigabitEthernet0/1/2        DESI  FORWARDING      NONE

    After DeviceA is configured as a root bridge, GE 0/1/2 and GE 0/1/1 connected to DeviceB and DeviceD respectively are elected as designated ports in spanning tree calculation.

    # Run the display stp interface gigabitethernet 0/1/1 brief command on DeviceB to view status of GE 0/1/1. The displayed information is as follows:

    [~DeviceB] display stp interface gigabitethernet 0/1/1 brief
     MSTID  Port                        Role  STP State     Protection
       0    GigabitEthernet0/1/1        DESI  FORWARDING    NONE      

    GE 0/1/1 is elected as a designated port in spanning tree calculation and is in the Forwarding state.

    # Run the display stp interface gigabitethernet 0/1/3 brief command on DeviceC to view status of GE 0/1/3. The displayed information is as follows:

    [~DeviceC] display stp interface gigabitethernet 0/1/3 brief
     MSTID  Port                        Role  STP State     Protection
       0    GigabitEthernet0/1/3        ROOT  FORWARDING      NONE      

    GE 0/1/3 is elected as a designated port in spanning tree calculation and is in the Forwarding state.

    # Run the display stp command on DeviceD to view the interface status and protection type. The displayed information is as follows:

    [~DeviceD] display stp
    -------[CIST Global Info][Mode STP]-------
    CIST Bridge         :4096 .00e0-fc12-3456
    Bridge Times        :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
    CIST Root/ERPC      :0    .00e0-fc12-3456 / 20000
    CIST RegRoot/IRPC   :4096 .00e0-fc12-3456 / 0
    CIST RootPortId     :128.1
    BPDU-Protection     :Disabled
    CIST Root Type      :SECONDARY root
    TC or TCN received  :4
    TC count per hello  :0
    STP Converge Mode   :Normal
    Time since last TC :0 days 0h:5m:44s
    ----[Port1(GigabitEthernet0/1/1)][FORWARDING]----
     Port Protocol       :enabled
     Port Role           :Root Port
     Port Priority       :128
     Port Cost(Dot1T )   :Config=auto / Active=20000
     Desg. Bridge/Port   :0.00e0-fc12-3456 / 128.1
     Port Edged          :Config=default / Active=disabled
     Point-to-point      :Config=auto / Active=true
     Transit Limit       :147 packets/hello-time
     Protection Type     :None
     Port Stp Mode       :STP
     Port Protocol Type  :Config=auto / Active=dot1s
     BPDU Encapsulation  :Config=stp / Active=stp
     PortTimes           :Hello 2s MaxAge 20s FwDly 15s RemHop 0
     TC or TCN send  :4
     TC or TCN received  :2
     BPDU Sent           :5
              TCN: 0, Config: 0, RST: 5, MST: 0
     BPDU Received       :177
              TCN: 0, Config: 0, RST: 177, MST: 0
    ----[Port2(GigabitEthernet0/1/2)][FORWARDING]----
     Port Protocol       :enabled
     Port Role           :Designated Port
     Port Priority       :128
     Port Cost(Dot1T )   :Config=auto / Active=20000
     Desg. Bridge/Port   :4096.00e0-fc12-3456 / 128.2
     Port Edged          :Config=default / Active=disabled
     Point-to-point      :Config=auto / Active=true
     Transit Limit       :147 packets/hello-time
     Protection Type     :None
     Port Stp Mode       :STP
     Port Protocol Type  :Config=auto / Active=dot1s
     BPDU Encapsulation  :Config=stp / Active=stp
     PortTimes           :Hello 2s MaxAge 20s FwDly 15s RemHop 20
     TC or TCN send  :2
     TC or TCN received  :2
     BPDU Sent           :165
              TCN: 0, Config: 0, RST: 165, MST: 0
     BPDU Received       :2
              TCN: 0, Config: 0, RST: 2, MST: 0

Configuration Files

  • Configuration file of DeviceA

    #
    sysname DeviceA                                                                
    #                                                                               
     stp mode stp                                                                  
     stp instance 0 root primary                                                    
     stp pathcost-standard legacy                                                   
     stp enable                                                                     
    #                                                                               
    interface GigabitEthernet0/1/1                                                  
     portswitch
     undo shutdown
    #                                                                               
    interface GigabitEthernet0/1/2                                                  
     portswitch
     undo shutdown
    #
    return
  • Configuration file of DeviceB

    #                                                                               
    sysname DeviceB                                                                
    #                                                                               
     stp mode stp                                                                  
     stp pathcost-standard legacy                                                   
     stp enable                                                                     
    #                                                                               
    interface GigabitEthernet0/1/1                                                  
     portswitch
     undo shutdown
    #                                                                               
    interface GigabitEthernet0/1/2                                                  
     stp disable                                                                    
    #                                                                               
    interface GigabitEthernet0/1/3                                                  
     portswitch
     undo shutdown
    #                                                                               
    return                    
  • Configuration file of DeviceC

    #                                                                               
    sysname DeviceC                                                                
    #                                                                               
     stp mode stp                                                                  
     stp pathcost-standard legacy                                                   
     stp enable                                                                     
    #                                                                               
    interface GigabitEthernet0/1/1                                                  
     portswitch
     undo shutdown
     stp instance 0 cost 20000                                                      
    #                                                                               
    interface GigabitEthernet0/1/2                                                  
     stp disable                                                                    
    #                                                                               
    interface GigabitEthernet0/1/3                                                  
     portswitch
     undo shutdown
    #                                                                               
    return           
    #
  • Configuration file of DeviceD

    #                                                                               
    sysname DeviceD                                                                
    #                                                                               
     stp mode stp                                                                  
     stp instance 0 root secondary                                                  
     stp pathcost-standard legacy                                                   
     stp enable                                                                     
    #                                                                               
    interface GigabitEthernet0/1/1                                                  
     undo shutdown
     portswitch
    #                                                                               
    interface GigabitEthernet0/1/2                                                  
     undo shutdown
     portswitch
    #                                                                               
    return                        
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
Next topic >