Configuring Spanning Tree Protocol Costs on a Cisco Switch

The purpose of the Spanning Tree Protocol (STP) is to prevent loops on a switched or bridged network. STP is enabled on Catalyst 1900 series switches by default. In fact, one instance of Spanning Tree is enabled for each and every VLAN.

In earlier articles we examined some of the default settings relating to the Spanning Tree Protocol, including bridge priorities, port costs, and port priorities. These settings can all be changed from their default values if required.

The cost or priority of a switch interface is changed using the spantree command from interface configuration mode. Notice that the cost associated with a port can range between 1 and 65536, while the priority of a port can be set to any number between 0 and 255.

Cisco1912#config t
Enter configuration commands, one per line. End with CNTL/Z
Cisco1912(config)#interface f0/27
Cisco1912(config-if)#spantree ?
cost Change an interface's spanning tree path cost
priority Change an interface's spanning tree priority
start-forwarding Allow a change from blocking to forwarding
Cisco1912(config-if)#spantree cost ?
<1-65535> Change an interface's spanning tree path cost
Cisco1912(config-if)#spantree priority ?
<0-255> Change an interface's spanning tree priority

In order to simplify the configuration of Spanning Tree on a switch, global settings are configured using what are known as Spanning Tree templates. These templates include settings such as bridge priority, hello interval, and so forth. On a Cisco 1900 switch, up to four templates can be defined. Ultimately, these templates can be applied to different VLANs, allowing you to configure STP settings once for many different VLANs. By default, all VLANs have the first Spanning Tree template applied, as shown below.

Cisco1912#show span?
Spantree spantree-option spantree-template
Cisco1912#show spantree-template 1

Bridge Template 1
Bridge Priority : 32768 (8000 hex)
Max age when operating as root : 20 second(s)
Hello time when operating as root : 2 second(s)
Forward delay when operating as root : 15 second(s)
VLANs assigned to option : 1-1005

Some of the default values shown above should look familiar. Notice that the default bridge priority is set to 32768, and that the hello interval is set to 2 seconds by default.
If you wanted a particular switch to become the root bridge, it would be a good idea to lower its priority value. This is accomplished using the spantree-template 1 priority command, as shown below. In this case, I have set the priority value to 1000.

Cisco1912#config t
Enter configuration commands, one per line. End with CNTL/Z
Cisco1912(config)#spantree-template 1 ?
forwarding-time Set a Spanning Tree FORWARD Interval
hello-time Set a Spanning Tree HELLO Interval
max-age Set a Spanning Tree MAX AGE Interval
priority Set a Spanning Tree PRIORITY
vlan Assign up to ten VLANs to a bridge template
Cisco1912(config)#spantree-template 1 priority 1000
Cisco1912(config)#exit
Cisco1912#show spantree-template 1

Bridge Template 1
Bridge Priority : 1000 (3E8 hex)
Max age when operating as root : 20 second(s)
Hello time when operating as root : 2 second(s)
Forward delay when operating as root : 15 second(s)
VLANs assigned to option : 1-1005

There may of course be times where you want to turn Spanning Tree off, for example if your network topology is loop-free. This is accomplished by issuing the no spantree command from global configuration mode, followed by the VLAN number for which you want Spanning Tree disabled. To re-enable Spanning Tree, simply remove the no option.

Cisco1912(config)#no spantree 100
Cisco1912(config)#spantree 100

Author: Dan DiNicolo

Dan DiNicolo is a freelance author, consultant, trainer, and the managing editor of 2000Trainers.com. He is the author of the CCNA Study Guide found on this site, as well as many books including the PC Magazine titles Windows XP Security Solutions and Windows Vista Security Solutions. Click here to contact Dan.