STP(Spanning tree Protocol) Configuration



STP (Spanning tree Protocol)

Objective: STP is designed to prevent loops in Ethernet networks. Loops can occur in networks with redundant connections between switches, leading to broadcast storms and network congestion. STP ensures that only one active path exists between any two network devices, thus eliminating loops

Topology Discovery: STP works by discovering the network topology and calculating the most efficient path from each switch to a root bridge. The root bridge is the central reference point for the network

Bridge Protocol Data Units (BPDUs): STP uses BPDUs to exchange information between switches. BPDUs contain information such as bridge IDs, port costs, and path priorities. Switches use BPDUs to elect a root bridge and determine the best paths to reach it.

Root Bridge Election: The process of selecting a root bridge involves comparing bridge IDs. Each switch advertises its own bridge ID in BPDUs, and switches select the root bridge based on the lowest bridge ID. If multiple switches have the same lowest bridge ID, the switch with the lowest MAC address becomes the root bridge.

Path Calculation: Once the root bridge is elected, each switch calculates the shortest path to reach the root bridge based on the costs associated with each link. This calculation is used to determine the active and blocking ports in the network, ensuring a loop-free topology.

Port States: STP defines several port states to manage the network topology:

  • Blocking: Ports that are not part of the active path are in the blocking state to prevent loops.
  • Listening: Ports transition to the listening state to prepare for becoming part of the active topology.
  • Learning: Ports in the learning state start populating their MAC address tables but still don't forward data frames.
  • Forwarding: Ports in the forwarding state actively forward data frames and participate in network communication.

STP Variants: In addition to the original IEEE 802.1D STP, there are variants such as Rapid Spanning Tree Protocol (RSTP) and Multiple Spanning Tree Protocol (MSTP), which offer faster convergence and support for multiple spanning tree instances, respectively.

Overall, STP is a fundamental protocol in Ethernet networks, ensuring network stability and preventing loops by creating a loop-free topology.



STP Configuration



Enable STP globally:
  • Replace <mode> with the desired mode: pvst for Per-VLAN Spanning Tree, rapid-pvst for Rapid Per-VLAN Spanning Tree, or mst for Multiple Spanning Tree.

Configure Bridge Priority:
  • This command sets the bridge priority for a specific VLAN. <vlan_id> is the VLAN number, and <priority_value> is the bridge priority value. Lower values indicate higher priority.
Configure Port Costs:
  • This command sets the cost of a specific interface. <interface_type> is the interface type (e.g., Ethernet, FastEthernet, GigabitEthernet), <interface_number> is the interface number, and <cost> is the cost value.The cost value influences the path selection process in Spanning Tree Protocol (STP), with lower costs indicating preferred paths.
Enable Portfast:

  • This command enables Portfast on all interfaces within the specified range. Portfast allows interfaces to transition directly to the forwarding state, bypassing the listening and learning states, which is useful for end-user access ports.
Enable BPDU Guard:

  • This command enables BPDU Guard on a specific interface, which disables the port if it receives BPDUs. helping to prevent loops in the network
Enable Root Guard:
  • This command enables Root Guard on a specific interface, ensuring that it does not become a root port if unexpected BPDUs are received.helping to enforce the root bridge placement in the network.
Verification Commands:

This command displays the spanning tree status and configuration for all VLANs.

This command displays the spanning tree status and configuration for a specific interface.

  • These commands provide a basic overview of STP configuration on Cisco switches. Remember to replace <vlan_id>, <priority_value>, <interface_type>, and <interface_number> with the appropriate values for your network configuration.



network source

Previous Post Next Post