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.
Spanning Tree Protocol Commands
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.
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.
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.
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.
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.
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 →