Spanning Tree
Spanning Tree Protocol (STP) is a Layer 2 loop prevention mechanism that ensures a loop-free topology in Ethernet networks by selectively blocking redundant paths while maintaining network connectivity and providing automatic failover capabilities. It supports multiple implementations including Per-VLAN Spanning Tree Plus (PVST+), Rapid Per-VLAN Spanning Tree Plus (RPVST+), and Multiple Spanning Tree (MST) protocol, each offering different approaches to VLAN-aware loop prevention and convergence optimization. Spanning Tree configuration includes features like PortFast for edge ports, BPDU Guard for security, root bridge selection, and path cost manipulation to optimize network topology and ensure rapid recovery from link failures while preventing broadcast storms and network instability.
Diagram
Section titled “Diagram”Classes
Section titled “Classes”configuration (iosxe.devices)
Section titled “configuration (iosxe.devices)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| spanning_tree | Class | [spanning_tree] | No |
spanning_tree (iosxe.devices.configuration)
Section titled “spanning_tree (iosxe.devices.configuration)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| mode | Choice | mst, pvst, rapid-pvst | No | |
| logging | Boolean | true, false | No | |
| loopguard_default | Boolean | true, false | No | |
| portfast_default | Boolean | true, false | No | |
| portfast_bpduguard_default | Boolean | true, false | No | |
| extend_system_id | Boolean | true, false | No | |
| mst_instances | List | [mst_instances] | No | |
| vlans | List | [vlans] | No | |
| disabled | Class | [disabled] | No |
mst_instances (iosxe.devices.configuration.spanning_tree)
Section titled “mst_instances (iosxe.devices.configuration.spanning_tree)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| id | Integer | min: 0, max: 4094 | Yes | |
| vlans | Class | [vlans] | No |
vlans (iosxe.devices.configuration.spanning_tree)
Section titled “vlans (iosxe.devices.configuration.spanning_tree)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| id | Integer | min: 1, max: 4094 | No | |
| vlans | Class | [vlans] | No | |
| priority | Integer | min: 0, max: 61440 | No |
disabled (iosxe.devices.configuration.spanning_tree)
Section titled “disabled (iosxe.devices.configuration.spanning_tree)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| vlans | Class | [vlans] | No |
vlans (iosxe.devices.configuration.spanning_tree.mst_instances)
Section titled “vlans (iosxe.devices.configuration.spanning_tree.mst_instances)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| ids | List | Integer[min: 1, max: 4094] | No | |
| ranges | List | [ranges] | No |
ranges (iosxe.devices.configuration.spanning_tree.mst_instances.vlans)
Section titled “ranges (iosxe.devices.configuration.spanning_tree.mst_instances.vlans)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| from | Integer | min: 1, max: 4094 | Yes | |
| to | Integer | min: 1, max: 4094 | Yes |
By preventing Layer 2 loops, Spanning Tree Protocol (STP) ensures network stability and rapid recovery from link failures.
Spanning Tree Parameters
Section titled “Spanning Tree Parameters”Key Components:
-
STP Mode (
mode): Selects the spanning tree protocol (PVST+, Rapid-PVST+, MST). -
Logging (
logging): Enables STP logging for topology changes and root bridge elections. -
Bridge Priority (
priority): Sets the priority for root bridge election. -
VLANs (
vlans): Configures per-VLAN STP settings including bridge priority for individual VLANs in PVST+/Rapid-PVST+ mode. Each entry specifies either a single VLAN (id) or a group of VLANs (vlansusing the general_vlans structure withidsandranges). When ranges are used, the TF module expands them into individual per-VLAN entries at plan time. -
Disabled VLANs (
disabled.vlans): Explicitly disables STP on specific VLANs by executingno spanning-tree vlan X. Use this when you need to completely remove VLANs from spanning tree participation. -
MST Instance ID and VLAN Mappings (
mst_instances): Configures MST instances and their associated VLANs. -
Port Priority (
port_priority): Sets the priority for individual ports. -
Path Cost (
path_cost): Adjusts the cost for spanning tree path selection. -
PortFast (
portfast_default,portfast): Enables PortFast globally or per interface. -
BPDU Guard (
portfast_bpduguard_default,bpduguard): Enables BPDU Guard globally or per interface. -
BPDU Filter (
bpdufilter): Enables BPDU Filter globally or per interface. -
Root Guard (
rootguard): Protects the root bridge role. -
Loop Guard (
loopguard_default,loopguard): Prevents loops caused by unidirectional links. -
EtherChannel Guard (
etherchannel_guard): Protects EtherChannel links. -
Max Age, Forward Delay, Hello Time (
max_age,forward_delay,hello_time): Sets STP timers. -
Extend System ID (
extend_system_id): Enables extended system ID for bridge priority.
Key Parameters Briefly Explained:
mode: STP protocol selection.logging: Enable STP event logging.priority: Bridge priority.vlans: Per-VLAN STP configuration withid(single) orvlans(range) andpriority.disabled.vlans: VLANs to completely disable from STP participation.mst_instances: MST instance configuration.port_priority,path_cost: Port-specific settings.portfast_default,portfast: PortFast settings.portfast_bpduguard_default,bpduguard: BPDU Guard settings.bpdufilter,rootguard,loopguard_default,loopguard,etherchannel_guard: Protective features.max_age,forward_delay,hello_time: STP timers.extend_system_id: Extended system ID.
You can use these Spanning Tree parameters to control loop prevention, optimize convergence, and enhance the security of your Layer 2 network. Customize the STP mode, bridge priorities, port settings, and protective features to fit your network’s topology, performance requirements, and resilience needs. Adjusting these parameters lets you tailor how your network handles redundancy and prevents loops.
Guidelines and Limitations
Section titled “Guidelines and Limitations”VLAN Removal Behavior
Section titled “VLAN Removal Behavior”When VLANs are removed from the spanning_tree.vlans list, they retain their default STP participation. Removing a VLAN from the data model does not execute no spanning-tree vlan X on the device. VLANs removed from the configuration will revert to default STP priority (32768) while continuing to participate in spanning tree.
To completely disable STP on specific VLANs (no spanning-tree vlan X), use the disabled.vlans attribute instead. This explicitly removes VLANs from spanning tree participation.
Sample Configuration
Section titled “Sample Configuration”The following configuration describes how to set up Spanning Tree Protocol on a Cisco IOS-XE device, including STP mode, logging, global PortFast and BPDU Guard, per-VLAN priority, MST configuration, and instance mapping for robust Layer 2 loop prevention and optimized convergence.
Rapid-PVST+ with Per-VLAN Priority
Section titled “Rapid-PVST+ with Per-VLAN Priority”spanning-tree mode rapid-pvstspanning-tree loggingspanning-tree loopguard defaultspanning-tree portfast defaultspanning-tree portfast bpduguard defaultspanning-tree extend system-id!spanning-tree vlan 10 priority 4096spanning-tree vlan 20 priority 8192spanning-tree vlan 30 priority 4096!interface GigabitEthernet0/1 spanning-tree portfast spanning-tree bpduguard enableRapid-PVST+ with VLAN Range Priority
Section titled “Rapid-PVST+ with VLAN Range Priority”spanning-tree mode rapid-pvstspanning-tree vlan 10 priority 4096spanning-tree vlan 100 priority 8192spanning-tree vlan 101 priority 8192spanning-tree vlan 102 priority 8192spanning-tree vlan 103 priority 8192MST Configuration
Section titled “MST Configuration”spanning-tree mode mstspanning-tree loggingspanning-tree loopguard defaultspanning-tree portfast defaultspanning-tree portfast bpduguard defaultspanning-tree extend system-id!spanning-tree mst configuration name MY_MST_REGION revision 1 instance 0 vlan 1,10,20,30 instance 1 vlan 100,200,300 instance 2 vlan 400,500,600 exit!spanning-tree mst 0 priority 4096spanning-tree mst 1 priority 8192Example YAML Code
Section titled “Example YAML Code”The following YAML code defines Spanning Tree Protocol configuration on an IOS-XE device, including global settings for mode, logging, loopguard, portfast, BPDU guard, extend system ID, per-VLAN priority configuration, and MST instance configuration.
Rapid-PVST+ with Per-VLAN Priority
Section titled “Rapid-PVST+ with Per-VLAN Priority”iosxe: devices: - name: AccessSwitch1 configuration: spanning_tree: mode: rapid-pvst logging: true loopguard_default: true portfast_default: true portfast_bpduguard_default: true vlans: - id: 10 priority: 4096 - id: 20 priority: 8192 - id: 30 priority: 4096Rapid-PVST+ with VLAN Range Priority
Section titled “Rapid-PVST+ with VLAN Range Priority”Use the vlans key (instead of id) to apply the same priority to a range of VLANs without listing each one individually. The TF module expands ranges into individual per-VLAN entries at plan time.
iosxe: devices: - name: DistSwitch1 configuration: spanning_tree: mode: rapid-pvst vlans: - id: 10 priority: 4096 - vlans: ranges: - from: 100 to: 103 priority: 8192MST Configuration
Section titled “MST Configuration”iosxe: devices: - name: CoreSwitch1 configuration: spanning_tree: mode: mst logging: true loopguard_default: true portfast_default: false portfast_bpduguard_default: true extend_system_id: true mst_instances: - id: 0 vlans: ids: [1, 10, 20, 30] - id: 1 vlans: ids: [100, 200, 300] ranges: - from: 350 to: 360 - id: 2 vlans: ranges: - from: 400 to: 500 - from: 550 to: 600Disabling STP on Specific VLANs
Section titled “Disabling STP on Specific VLANs”Use disabled.vlans to completely disable STP on specific VLANs. This executes no spanning-tree vlan X on the device, removing those VLANs from STP participation entirely.
no spanning-tree vlan 40no spanning-tree vlan 50no spanning-tree vlan 60-65iosxe: devices: - name: AccessSwitch1 configuration: spanning_tree: mode: rapid-pvst disabled: vlans: ids: [40, 50] ranges: - from: 60 to: 65Spanning Tree Protocol (STP) is a Layer 2 loop prevention mechanism that ensures a loop-free topology in Ethernet networks by selectively blocking redundant paths while maintaining network connectivity and providing automatic failover capabilities. It supports multiple implementations including Per-VLAN Spanning Tree Plus (PVST+), Rapid Per-VLAN Spanning Tree Plus (RPVST+), and Multiple Spanning Tree (MST) protocol, each offering different approaches to VLAN-aware loop prevention and convergence optimization. Spanning Tree configuration includes features like PortFast for edge ports, BPDU Guard for security, root bridge selection, and path cost manipulation to optimize network topology and ensure rapid recovery from link failures while preventing broadcast storms and network instability.
Diagram
Section titled “Diagram”Classes
Section titled “Classes”configuration (iosxe.devices)
Section titled “configuration (iosxe.devices)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| spanning_tree | Class | [spanning_tree] | No |
spanning_tree (iosxe.devices.configuration)
Section titled “spanning_tree (iosxe.devices.configuration)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| mode | Choice | mst, pvst, rapid-pvst | No | |
| logging | Boolean | true, false | No | |
| loopguard_default | Boolean | true, false | No | |
| portfast_default | Boolean | true, false | No | |
| portfast_bpduguard_default | Boolean | true, false | No | |
| extend_system_id | Boolean | true, false | No | |
| mst_instances | List | [mst_instances] | No | |
| vlans | List | [vlans] | No |
mst_instances (iosxe.devices.configuration.spanning_tree)
Section titled “mst_instances (iosxe.devices.configuration.spanning_tree)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| id | Integer | min: 0, max: 4094 | Yes | |
| vlans | Class | [vlans] | No |
vlans (iosxe.devices.configuration.spanning_tree)
Section titled “vlans (iosxe.devices.configuration.spanning_tree)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| id | Integer | min: 1, max: 4094 | Yes | |
| priority | Integer | min: 0, max: 61440 | No |
vlans (iosxe.devices.configuration.spanning_tree.mst_instances)
Section titled “vlans (iosxe.devices.configuration.spanning_tree.mst_instances)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| ids | List | Integer[min: 1, max: 4094] | No | |
| ranges | List | [ranges] | No |
ranges (iosxe.devices.configuration.spanning_tree.mst_instances.vlans)
Section titled “ranges (iosxe.devices.configuration.spanning_tree.mst_instances.vlans)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| from | Integer | min: 1, max: 4094 | Yes | |
| to | Integer | min: 1, max: 4094 | Yes |
By preventing Layer 2 loops, Spanning Tree Protocol (STP) ensures network stability and rapid recovery from link failures.
Spanning Tree Parameters
Section titled “Spanning Tree Parameters”Key Components:
-
STP Mode (
mode): Selects the spanning tree protocol (PVST+, Rapid-PVST+, MST). -
Logging (
logging): Enables STP logging for topology changes and root bridge elections. -
Bridge Priority (
priority): Sets the priority for root bridge election. -
VLANs (
vlans): Configures per-VLAN STP settings including bridge priority for individual VLANs in PVST+/Rapid-PVST+ mode. -
MST Instance ID and VLAN Mappings (
mst_instances): Configures MST instances and their associated VLANs. -
Port Priority (
port_priority): Sets the priority for individual ports. -
Path Cost (
path_cost): Adjusts the cost for spanning tree path selection. -
PortFast (
portfast_default,portfast): Enables PortFast globally or per interface. -
BPDU Guard (
portfast_bpduguard_default,bpduguard): Enables BPDU Guard globally or per interface. -
BPDU Filter (
bpdufilter): Enables BPDU Filter globally or per interface. -
Root Guard (
rootguard): Protects the root bridge role. -
Loop Guard (
loopguard_default,loopguard): Prevents loops caused by unidirectional links. -
EtherChannel Guard (
etherchannel_guard): Protects EtherChannel links. -
Max Age, Forward Delay, Hello Time (
max_age,forward_delay,hello_time): Sets STP timers. -
Extend System ID (
extend_system_id): Enables extended system ID for bridge priority.
Key Parameters Briefly Explained:
mode: STP protocol selection.logging: Enable STP event logging.priority: Bridge priority.vlans: Per-VLAN STP configuration withidandpriority.mst_instances: MST instance configuration.port_priority,path_cost: Port-specific settings.portfast_default,portfast: PortFast settings.portfast_bpduguard_default,bpduguard: BPDU Guard settings.bpdufilter,rootguard,loopguard_default,loopguard,etherchannel_guard: Protective features.max_age,forward_delay,hello_time: STP timers.extend_system_id: Extended system ID.
You can use these Spanning Tree parameters to control loop prevention, optimize convergence, and enhance the security of your Layer 2 network. Customize the STP mode, bridge priorities, port settings, and protective features to fit your network’s topology, performance requirements, and resilience needs. Adjusting these parameters lets you tailor how your network handles redundancy and prevents loops.
Sample Configuration
Section titled “Sample Configuration”The following configuration describes how to set up Spanning Tree Protocol on a Cisco IOS-XE device, including STP mode, logging, global PortFast and BPDU Guard, per-VLAN priority, MST configuration, and instance mapping for robust Layer 2 loop prevention and optimized convergence.
Rapid-PVST+ with Per-VLAN Priority
Section titled “Rapid-PVST+ with Per-VLAN Priority”spanning-tree mode rapid-pvstspanning-tree loggingspanning-tree loopguard defaultspanning-tree portfast defaultspanning-tree portfast bpduguard defaultspanning-tree extend system-id!spanning-tree vlan 10 priority 4096spanning-tree vlan 20 priority 8192spanning-tree vlan 30 priority 4096!interface GigabitEthernet0/1 spanning-tree portfast spanning-tree bpduguard enableMST Configuration
Section titled “MST Configuration”spanning-tree mode mstspanning-tree loggingspanning-tree loopguard defaultspanning-tree portfast defaultspanning-tree portfast bpduguard defaultspanning-tree extend system-id!spanning-tree mst configuration name MY_MST_REGION revision 1 instance 0 vlan 1,10,20,30 instance 1 vlan 100,200,300 instance 2 vlan 400,500,600 exit!spanning-tree mst 0 priority 4096spanning-tree mst 1 priority 8192Example YAML Code
Section titled “Example YAML Code”The following YAML code defines Spanning Tree Protocol configuration on an IOS-XE device, including global settings for mode, logging, loopguard, portfast, BPDU guard, extend system ID, per-VLAN priority configuration, and MST instance configuration.
Rapid-PVST+ with Per-VLAN Priority
Section titled “Rapid-PVST+ with Per-VLAN Priority”iosxe: devices: - name: AccessSwitch1 configuration: spanning_tree: mode: rapid-pvst logging: true loopguard_default: true portfast_default: true portfast_bpduguard_default: true vlans: - id: 10 priority: 4096 - id: 20 priority: 8192 - id: 30 priority: 4096MST Configuration
Section titled “MST Configuration”iosxe: devices: - name: CoreSwitch1 configuration: spanning_tree: mode: mst logging: true loopguard_default: true portfast_default: false portfast_bpduguard_default: true extend_system_id: true mst_instances: - id: 0 vlans: ids: [1, 10, 20, 30] - id: 1 vlans: ids: [100, 200, 300] ranges: - from: 350 to: 360 - id: 2 vlans: ranges: - from: 400 to: 500 - from: 550 to: 600