TechKnowSurge
Cisco CCNA 2.5 Cisco CCNA 5.7
VideoNetworkFree

DEMO: STP

Spanning Tree Protocol (STP) configuration commands control root bridge election, port priority, PortFast, and BPDU Guard across VLANs in a switched network. These settings ensure loop prevention while optimizing convergence time and network stability.

Complete this video to capture a CTF flag worth 1 point.

About this video

Spanning Tree Protocol operates automatically on Cisco switches, but a handful of configuration commands give administrators precise control over root bridge placement, port behavior, and loop protection. The show spanning-tree summary command provides a quick snapshot of per-VLAN STP status, including PortFast and BPDU Guard states, while the full show spanning-tree output breaks down each VLAN individually, displaying bridge priority, bridge ID, root ID, hello timer intervals, port roles, and path cost values. Bridge priority follows a predictable formula: the base priority (32768 by default) is added to the VLAN ID to produce the effective system priority shown in the output, so VLAN 2 yields a priority of 32770 and VLAN 9 yields 32777. To guarantee that a specific switch acts as the root bridge, the spanning-tree vlan command allows administrators to assign a lower-than-default priority across multiple VLANs simultaneously. Setting priority to 4096, for example, ensures the switch wins root bridge election even if additional switches join the network with default priority values. STP mode can also be changed globally using the spanning-tree mode command, with options including PVST+, Rapid PVST+, and MST, giving administrators the flexibility to align the protocol version with network requirements. PortFast shortens the listening and learning delay on access ports, bringing end-device links up immediately rather than waiting through the standard STP convergence process. It is enabled at the interface level with the spanning-tree portfast command, which generates a warning that the feature should only be used on ports connected to end hosts rather than other switches. To protect PortFast-enabled ports from receiving BPDUs, BPDU Guard can be applied per-interface or enforced switch-wide using the spanning-tree portfast bpdu guard default command, which automatically err-disables any PortFast port that receives a BPDU, preventing an unauthorized switch from disrupting the STP topology. Together, manual priority assignment, PortFast, and BPDU Guard represent the most commonly applied STP tuning measures in production switched environments.

What you'll learn

What's covered

Spanning Tree Protocol Commands

Aligned to

Cisco CCNA
2.5 Interpret basic operations of Rapid PVST+ Spanning Tree Protocol
5.7 Configure and verify Layer 2 security features

Key terms

Spanning Tree Protocol
STP
A network protocol that prevents loops in Ethernet networks by creating a loop-free logical topology.
Virtual LAN
VLAN
A logical grouping of network devices that behave as if they are on the same network regardless of physical location.
Bridge
A network device that connects two or more network segments and filters traffic based on MAC addresses.
Bridge ID
BID
A unique identifier used in the Spanning Tree Protocol consisting of a configured priority value and the bridge's MAC address. The BID is used in STP elections to determine which switch becomes the root bridge.
Root Bridge
The switch elected as the reference point for the Spanning Tree Protocol topology, determined by the switch with the lowest Bridge ID (priority + MAC address). All other switches calculate their best path to the root bridge and block redundant links to create a loop-free tree.
PortFast
A Cisco Spanning Tree Protocol feature applied to access-layer ports connected to end devices that allows the port to transition immediately to the forwarding state, bypassing the normal STP listening and learning phases that would otherwise delay connectivity by up to 30 seconds. PortFast should only be used on ports that connect to end devices, not to other switches.
BPDU Guard
A Cisco STP security feature applied to PortFast-enabled ports that immediately shuts down the port if a BPDU is received, preventing an unauthorized switch from being connected and disrupting the spanning tree topology. It protects access-layer ports that should only connect to end devices, not other switches.
Bridge Priority
A configurable numeric value within the Bridge ID, defaulting to 32768 and incrementing in multiples of 4096, used to influence which switch is elected as the root bridge in STP.

Topics

Spanning Tree Protocol Networking Cisco Ios Switched Networks Bpdu Guard Portfast Vlan Configuration

Transcript

We're not going to take a real in-depth look — you don't need to know about how to program every little thing with spanning tree protocol. What we're going to do is we're just going to give a brief understanding about some of the commands that you might use in there, and then we'll also set it up, because we want to implement some of these concepts into our network that we have in our project.

Show spanning tree summary

Let's take a look at our first command, which is show spanning tree, and we will do summary, so we just see a summary of spanning tree. When we see this, the first thing that it shows here is it's for VLAN 2, 9, 10, 20, 30, 40 and 50 — it's the root bridge for those. We also see some information we talked about, PortFast. We see that the PortFast in here, that BPDU guard is disabled, PortFast filter is disabled. So we see some things that are disabled, so some interesting information there.

Show spanning tree

Let's do the same thing, but let's not have the summary written at the end of it. There's a lot of cool information here. So here's VLAN 2, this is the information for VLAN 2. One thing that is interesting is the priority for this is 32770. We said that the default priority is 32768, but we come up with 32770 because if you take 32768 plus VLAN two — so we add two to it — we get 32770. So that's fascinating: that priority is that extension, the extension that we talked about before, and that plus also the priority.

Another thing that's interesting about this is we have the bridge ID. The bridge ID of this machine is here's the priority plus the address. We said that it would be the priority plus the address. And then it is also the root ID, which makes sense, because this is also the root bridge for this.

So we see that information in here. The hello timer is two seconds, so we see that these are being sent out every two seconds. And we see that it also is getting information about spanning tree protocol on these two ports. fa1043 is plugged into switch 2 and 45 is plugged into switch three — at least I believe that's how we've got it set up. We could check our documentation here and see if that's really how we have it set up. I've already filled in some of the information, so some of this is a little bit changed here, but yeah, 43 is in switch 2 and 45 is in switch 3. So this is a foreshadowing clue of some of the stuff we're going to get into in a second.

Cost is 19 for each of these, and we've got the priority of the ports that are being sent to this device. So there we have it, there's some information.

If I keep scrolling through here, here's for VLAN 9, VLAN 10, and really they're going to be very similar, with the exception of the priority is changing, because we're adding the VLAN to it. So the system extension ID is 30 here, so 30 plus the priority, and that's how we come up with it.

Setting the priority

What I'm going to do is let's jump into doing some additional configurations here, and let's get into the global configuration mode. First of all, take a look at the spanning tree, and then we'll type in mode and see what modes there are. For this one we have MST, PVST and Rapid PVST, so we've got a few different options that we can change this to if we wanted to change it to one of the other modes. We're not going to change it to any of those other STP versions, we're just going to keep it the way it is.

One other thing that I can do is I can set the priorities. So I'm going to do spanning tree, and then VLAN, and then I list out the VLANs I want this for. So we had two, nine, ten, twenty, thirty, four, forty, fifty and 150 are the different VLANs we had for this. And then I'm going to set the priority, and we can set the priority to what we want to set the priority to, so 4096.

What this allows is if another switch comes online that has a lower bridge ID than this one, it won't take on the root bridge. I want this one to be the root bridge, so I can set it for this right here.

Now let's go back and take a look at the show spanning-tree and see what has changed with it. So here's two, and now it's 4098, so it's that 4096 plus the VLAN of it, of two. Same thing for 4105, because we add 9 to it. So we just changed the priority of everything. This is switch one, so that's what I wanted to do.

PortFast and BPDU guard

Now I can get into an interface. Let's get into an interface, so I'm going to get into global configuration mode. Let's just do fa 105 as an example. This is one of the access ports that, let's say, I want to make it come live faster, so I'm going to type in a, and then I'll type in PortFast.

It gives me a warning here, just in case, because it can cause problems. We know if there's that loop that happens just because we have PortFast turned on, that could be problematic, and so it gives us a warning for this. But PortFast has been turned on.

Next, what we're going to do is we're going to guard against those BPDUs, so if it does receive a BPDU then it will turn this port off. So I do that, enable. And so now this is enabled on this port.

Or what I could also do is I could enable this globally on this switch right here. So if I wanted to do that, I can go back a level, let's go into the global configuration mode, and do spanning tree BPDU filter — actually, let's just do, make sure I'm getting this right, BBD, and then we will type in default. What this will do is it's going to set now that first switch wide, so no matter what ports are in that PortFast state, then it will apply this BPDU guard. And that will allow me so I don't have to have a BPDU guard on every single port that I type in PortFast into.

So I could do it either way, really. It's just a matter of preference as far as that's concerned. There are some advantages to have this set default as well, to make sure that things are programmed right.

So there are some commands for spanning tree protocol to change the spanning tree. For the most part, spanning tree is up and running and works fine, but there are probably some tweaks that you want to do to make it run more efficient. The two that I always like to do is this PortFast, and get them onto those access ports; and then the other thing I like to do is set the priority.

About TechKnowSurge

TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.

Explore free tools and programs →