STP - Spanning Tree Protocol on Switch & Router
Spanning Tree Protocol (STP) is used to prevent network loops in Ethernet networks by creating a loop-free logical topology. Cisco switches typically run the Rapid Spanning Tree Protocol (RSTP) or the IEEE 802.1D Spanning Tree Protocol (STP). Here are the commands to configure STP (RSTP or STP) on a Cisco switch, along with descriptions and a use case:
Use Case for STP on a Switch: Consider a scenario where you have multiple interconnected switches in your network. These switches are part of a single broadcast domain, and you want to prevent network loops to ensure network stability. STP is used to identify and disable redundant links, creating a loop-free topology.
1. Access Configuration Mode:
- Description: Access the switch's command-line interface (CLI) and enter configuration mode.
bashSwitch> enable
Switch# configure terminal
2. Configure STP Mode:
- Description: Configure the switch to run either RSTP or STP. RSTP is faster and more efficient than STP, so it's the recommended choice.
bashSwitch(config)# spanning-tree mode {rapid-pvst | pvst | mst}
- Example (RSTP):
bashSwitch(config)# spanning-tree mode rapid-pvst
- Example (STP):
bashSwitch(config)# spanning-tree mode pvst
- Description:
rapid-pvst: Configures the switch to use RSTP (Rapid Spanning Tree Protocol).pvst: Configures the switch to use the older IEEE 802.1D STP.mst: Configures the switch to use Multiple Spanning Tree Protocol (MST).
3. Configure the Bridge Priority (Optional):
- Description: You can adjust the bridge priority to influence which switch becomes the root bridge in the STP topology. Lower values indicate higher priority.
bashSwitch(config)# spanning-tree vlan vlan_id priority priority_value
- Example:
bashSwitch(config)# spanning-tree vlan 10 priority 8192
4. Configure Portfast on Access Ports (Optional):
- Description: Portfast can be enabled on access ports (ports connected to end devices like PCs) to reduce the time it takes for a port to transition to the forwarding state.
bashSwitch(config)# interface range interface_type interface_range
Switch(config-if-range)# spanning-tree portfast
- Example:
bashSwitch(config)# interface range GigabitEthernet0/1 - 24
Switch(config-if-range)# spanning-tree portfast
5. Verify the STP Configuration:
- Description: To verify the STP configuration on the switch, you can use the following command:
bashSwitch# show spanning-tree
- Description: This command displays information about the current STP topology, including the root bridge, port roles, and states.
6. Save the Configuration:
- Description: After configuring STP, be sure to save the configuration to the startup configuration to ensure it persists after a reboot.
bashSwitch# write memory
In this use case, STP (RSTP or STP) is configured to prevent network loops in a switched network. It ensures that one of the switches becomes the root bridge, and all other switches adjust their forwarding ports accordingly to create a loop-free topology.
=============================================================
STP on Router
Spanning Tree Protocol (STP) is typically configured on switches rather than routers. Routers typically use routing protocols to manage traffic, whereas STP is used on switches to prevent loops in Ethernet networks. Routers do not participate in STP, as their primary function is to make forwarding decisions based on network layer information (e.g., IP addresses). However, if you have a router with Ethernet interfaces and you want to understand the STP configuration on those interfaces, you can view the STP status on the router.
Here's how you can view the STP status on a router's Ethernet interface:
Use Case: Let's assume you have a router with multiple Ethernet interfaces, and these interfaces are connected to different VLANs on a switch. You want to ensure that there are no network loops in your LAN, and you want to verify the STP status on the router's Ethernet interfaces.
1. Access the Router's CLI:
- Description: Access the router's command-line interface (CLI).
bashRouter> enable
Router# show spanning-tree interface interface_type interface_number
- Example:
bashRouter# show spanning-tree interface GigabitEthernet0/0
- Description: This command displays the STP status for a specific Ethernet interface on the router. It provides information about the port's role (e.g., Root, Designated, or Blocking), the port's state (e.g., Forwarding or Blocking), and other STP-related details.
Please note that routers do not participate in STP calculations or run STP processes. STP is primarily used on Ethernet switches to prevent loops in the Layer 2 topology.
Comments
Post a Comment