Configuring Spanning Tree Path Cost

When a loop occurs in the network topology, STP path cost can be used to determine the spanning-tree states of the ports. Path cost is obtained from the speed of the interface. A user configures lower path cost for an interface if the port needs to be selected first, or the user configures higher path cost if the port needs to be selected last for putting it into forwarding state.

Path cost is used to determine the topology only if the loop in the network cannot be resolved using only the Bridge IDs. If all ports have same path cost values, then the spanning tree first puts the lowest numbered port into forwarding state.

Refer to Figure Spanning Tree Topology for topology. After the topology stabilizes and switch A is elected as Root, the ports of all switches, except Port 2 of switch C, are in forwarding state. Port 2 of Switch C is an alternate port and is in discarding state.

This example configures the path cost associated with port 0/1 to 2000.

  1. Execute the following commands in the switch C.

    Type the following:

    • Enter the Global Configuration Mode.
    iS5comm# configure terminal
    • Specify the interface for which the path cost is to be configured.
    iS5comm(config)# interface gigabitethernet 0/1
    Note:

    Valid interfaces include physical interfaces and port-channel logical interfaces (port-channel port-channel-number).

    • Configure the cost for the interface.

    For cost, the range is 1 to 200000000 and the default value is derived from the media speed of the interface.

    iS5comm(config-if)# spanning-tree vlan 1 cost 2000
    Note:

    Observation after configuring the Path Cost for port 1 in Switch C. Port 2 of Switch B is the Alternate Port and Port 2 of Switch C is a Designated Port.

    • Return to the Privileged EXEC Mode.
    iS5comm(config-if)#end
  2. View the spanning tree information by executing the following show command.

    Type the following:

    iS5comm# show spanning-tree vlan 1
    In Switch B
    Spanning-tree for VLAN 1
    Root Id         Priority 32769
    Address    00:03:02:03:04:01
    Cost       200000
    Port       2
    Hello Time 2 Sec, Max Age 20 Sec, Forward Delay 15 Sec
    
    
    Spanning Tree Enabled Protocol PVRST
    Bridge Id       Priority 32769
    Address 00:01:02:03:04:01
    Hello Time 2 sec, Max Age 20 sec, Forward Delay 15 sec
    Name    Role       State       Cost    Prio   Type
    ----    ----       -----       ----    ----   -----
    Gi0/1   Root       Forwarding  200000  128    SharedLan
    Gi0/2   Alternate  Forwarding  200000  128    SharedLan
    In Switch C
    Spanning-tree for VLAN 1
    Root Id         Priority 32769
    Address    00:03:02:03:04:01
    Cost       200000
    Port       2
    Hello Time 2 Sec, Max Age 20 Sec, Forward Delay 15 Sec
    
    
    Spanning Tree Enabled Protocol PVRST
    Bridge Id       Priority 32769
    Address 00:01:02:03:04:01
    Hello Time 2 sec, Max Age 20 sec, Forward Delay 15 sec
    Name    Role        State        Cost    Prio   Type
    ----    ----        -----        ----    ----   -----
    Gi0/1   Root        Discarding   2000    128    SharedLan
    Gi0/2   Designated  Forwarding   200000  128    SharedLan
    Note:

    Execute the no spanning-tree vlan <vlan-id> cost Interface Configuration mode command to set the default value of the Spanning Tree Path Cost

    iS5comm(config-if)# no spanning-tree vlan <vlan-id>  cost