TechKnowSurge
Cisco CCNA 2.5 Cisco CCNA 1.13 Cisco CCNA 5.7
VideoNetworkFree

STP Continued

Spanning Tree Protocol port states, STP timers, PortFast, and BPDU Guard are the final concepts needed to understand how switches initialize safely and how network loops are prevented. This content completes a foundational understanding of STP behavior in switched networks.

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

About this video

When a switch powers on or a port becomes active, Spanning Tree Protocol deliberately delays traffic forwarding to avoid introducing loops into the network. Rather than forwarding immediately, the port progresses through a series of states: blocking, listening, learning, and forwarding, with a disabled state reserved for ports that serve as redundant alternate paths. In the blocking state, the port only receives BPDUs to assess the network topology. In listening, it both sends and receives BPDUs, becoming a full participant in the STP process. The learning state adds MAC address table population, and only in the forwarding state does the port perform the full switching function of passing frames based on learned addresses. Three timers embedded in the BPDU frame control how long these transitions take. The hello timer, defaulting to two seconds, sets the interval at which BPDUs are transmitted and is standardized across the network by the root bridge. The max age timer, defaulting to 20 seconds, defines how long a port remains in blocking before transitioning. The forward delay, defaulting to 15 seconds, applies to both the listening and learning states individually, meaning a port spends 30 seconds across those two states alone. Combined with the max age timer, a port can take approximately 50 seconds from activation to forwarding under default settings. PortFast is a per-interface configuration that bypasses the standard STP state transitions for ports connected to end devices, allowing them to begin forwarding almost immediately. This prevents issues such as DHCP discovery timeouts that can occur when a device cannot reach the network during the normal 50-second delay. PortFast is appropriate only for access ports with end devices and should never be applied to ports connecting to other switches. To protect against accidental misuse, BPDU Guard is applied alongside PortFast. If a BPDU is received on a PortFast-enabled port, BPDU Guard immediately shuts the port down and places it in an error-disabled state, requiring manual intervention to restore. This combination of PortFast and BPDU Guard allows fast connectivity for end devices while maintaining the loop-prevention integrity that STP is designed to enforce.

What you'll learn

Aligned to

Cisco CCNA
2.5 Interpret basic operations of Rapid PVST+ Spanning Tree Protocol
1.13 Describe switching concepts
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.
Bridge Protocol Data Unit
BPDU
A data message exchanged between switches running Spanning Tree Protocol to detect network loops and elect a root bridge. BPDUs contain the sending switch's BID and path cost information used to build the loop-free spanning 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.
Hello Timer
An STP timer that defines the interval between BPDU transmissions; the default is 2 seconds with a range of 1 to 10 seconds.
Max Age Timer
An STP timer that defines how long a port stays in the blocking state before transitioning; the default is 20 seconds with a range of 6 to 40 seconds.
Forward Delay
An STP timer that defines the time a port spends in each of the listening and learning states; the default is 15 seconds per state for a total of 30 seconds.

Topics

Spanning Tree Protocol Stp Port States Stp Timers Portfast Bpdu Guard Switched Networks Networking

Transcript

Hopefully by this point we're getting a great understanding of spanning tree protocol, the spanning tree algorithm, and bridge protocol data units. There are a few more things that we have to cover: the processes of spanning tree protocol, the statuses that each of the ports can be in, some timers, PortFast and how to bring a port up very quickly, and what a BPDU guard is for those ports.

How the process gets started

We already know a lot about spanning tree protocol, and about the spanning tree algorithm and the process it uses to communicate using BPDUs. However, one thing we haven't talked about is how this all gets started. We've mentioned a few aspects of this throughout, but let's talk a little more in depth about it.

Let's say there's a switch that's brought up that hasn't spoken on this network yet — it's just being powered up. What's going to happen is it's not going to immediately start forwarding packets, it's not going to immediately start passing information along. That's why in some of my demo videos we saw this pause: I would make a change and then it would be quite a while before that change took effect, and for a lot of those times it was because we were waiting on STP to do its thing.

What is it waiting for? It doesn't want to forward traffic and create a loop. So first of all it starts by just listening. A switch will listen to see if anything's going on, and then it will start responding, sending its own bridge protocol data units out to see if it can generate any traffic and generate any knowledge amongst this network, before it starts forwarding out a bunch of packets that are going to cause loops. That's really the process: there's this waiting game, this wait-and-see. It happens when a switch goes live, but it also happens when a port goes live, so even if you were just to plug in a single port, it doesn't start right away.

Port states

When a port comes live it's going to go through several states. It's going to start out in blocking, and then start working into listening, learning and forwarding, or go into the disabled mode. Each one of those states is going to have different functionality.

For instance, will it receive bridge protocol data units and process them? Next, will it actually send out bridge protocol data units — will it form its own bridge protocol data units and send those out? Then there is the MAC table updates. This is for just the traffic going across the switch. A switch, we know, does learning, where it learns MAC addresses, and also forwarding, where it forwards onto specific ports based off of those MAC addresses. So is the MAC address table going to get updated? And then, does it actually start forwarding frames, forwarding the traffic? These two aspects are what a switch is designed to do, so is it going to perform the functions of the switch? The switch is really not fully functional until it gets to the last word, where it's actually forwarding frames.

What we can see is that in the blocking state it just receives bridge protocol data units. The first thing it does, it says, I don't want to get too involved here, I just want to see what's happening and see how I can be part of this network and where I'm going to fit in.

Then it goes into that listening mode, where it actually sends bridge protocol data units as well as receives them. So it's both sending and receiving at that point in time, and now it's fully participating in spanning tree protocol. Until the listening mode happens, we don't get full participation in spanning tree protocol.

Then it goes into a learning mode, and the learning mode then includes learning the MAC addresses. Remember, that's going to be the source MAC addresses: as a frame comes into it, it'll take a look at the source MAC address and log that, and the port that it came in on, into the MAC address table. So now it's updating the MAC address table.

Then that port will go into full forwarding, where it actually forwards as well. And then, if for some reason it needs to be an alternate route — for instance, it is a redundant link — then it will go into this disabled mode, where it won't participate at all.

Timers

Here is a bridge protocol data unit, and something we went over real quickly before was these timers right here, this information on timers. Let's get a little more in depth into some of these.

The first one is the hello timer. The hello timer is the time in between the times that it sends out new bridge protocol data units. In this case right here it's two bytes long. We can set it; it can be set for a range, and that range could be anywhere from one second to ten seconds, but the default is two seconds. That's the hello timer, and it's sent out with the bridge protocol data units. Because it's sent out, whoever gets elected as the root bridge can set this standard for the rest of the environment and say, this is how often I'd like everyone to speak with these bridge protocol data units.

The next one is the max age timer. The max age timer is how much time a port is spent in blocking before it transitions. The max age timer is set by default for 20 seconds, but it can be set anywhere from six seconds to 40 seconds. So if you want to speed up this process you could go into your network and change that from 20 seconds as the default to 40 seconds if you want to wait longer, or down to six seconds if you want it to be shorter.

We also have this forward delay. The forward delay is how much time is going to be spent both in the listening and learning mode. So if you set this for 15 seconds, it's going to set it for 15 seconds in each mode — 15 seconds is the default, by the way — so it's going to spend a total time of 30 seconds while it's in here. This can be set anywhere from 4 to 30 seconds, but the default once again is 15 seconds. So far, before we ever get into the forwarding mode, we have 20 plus 30: there's a 50 second delay before this port actually becomes live.

PortFast

That is one of the reasons for a command called PortFast. PortFast can be set up on each one of your interfaces that you choose to set it up on. The reason why we do PortFast is because that 50 second delay can cause some problems. When you plug a device into your network, it's expecting to have some sort of connectivity, and it goes and reaches out and tries to find a DHCP server and get a DHCP address and tries to do some things on your network. If it's waiting 50 seconds, that's quite a delay before it actually can start communicating, and it possibly could even have gone over that DHCP discovery process at that point in time.

So one thing that we can do is say, we are going to set up PortFast on all access ports, all ports that are going to have end devices. All three of my pies, my demo laptop, and anything else that I want, I would set up as PortFast so it could transition much faster. What will happen in that transition is that it's going to skip some of those steps and go into sending information out much sooner. This is a command that can help my ports come up much faster, but I wouldn't want to put it on a port that has a switch plugged into it.

BPDU guard

Because we bring these ports up much faster, if we put PortFast on one of these ports, what happens if that port does get plugged into another switch? Then it will create a loop once again. Loops are really bad from a Layer 2 perspective — they cause a lot of problems with our Layer 2 networks — so we want to mitigate against this, and that's where the bridge protocol data unit guard comes into play.

What a BPDU guard is, is that we can put it on any of the ports that we have PortFast turned on. If a BPDU comes in on that port, then it will disable that port immediately. It'll shut off that port and it won't come live; you'll have to manually get onto there and actually set up that port again, or bring it out of the disabled state. That's BPDU guard. We want to use PortFast on a lot of our end devices, but BPDU guard helps guard against anything that happened to get plugged into a switch: it will disable that port and we won't get a loop on our network.

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 →