Table of Contents
Every switched network runs on a handful of Layer 2 protocols working quietly in the background — protocols that prevent loops, negotiate trunk links, bundle redundant connections, and let devices discover their neighbors automatically. Understanding what each one does, how the different loop-prevention variants compare, and exactly which commands bring them to life on a real switch is the difference between a network that just works and one that mysteriously breaks the moment you add a second uplink. This guide covers all of it, from concepts through to a ready-reference command sheet.
The Core Layer 2 Protocols Every Switch Relies On
Before configuring anything, it helps to know what each of these protocols is actually responsible for and how they interact with one another.
- Spanning Tree Protocol (STP) — loop prevention. Whenever switches are connected with redundant links (for resilience), those links create physical loops that would otherwise cause broadcast storms. STP solves this by electing a root bridge and selectively blocking redundant paths, keeping exactly one active path between any two switches while holding the rest in standby.
- VLAN Trunking Protocol (VTP) — VLAN database synchronization. In multi-switch environments, VTP lets one switch act as a "server" that propagates VLAN configuration to other switches configured as "clients," so you don't have to manually recreate every VLAN on every switch in the network.
- Link Aggregation Control Protocol (LACP) — bundling redundant links. Rather than letting STP block a redundant physical link entirely, LACP bundles multiple physical links into a single logical link (an EtherChannel or port channel), giving you both increased bandwidth and redundancy without wasting capacity.
- Link Layer Discovery Protocol (LLDP) and Cisco Discovery Protocol (CDP) — neighbor discovery. These vendor-neutral (LLDP) and Cisco-proprietary (CDP) protocols let directly connected devices exchange information about themselves — device type, capabilities, port ID — which is invaluable for mapping out a network or troubleshooting physical connectivity without needing existing documentation.
- How they work together in practice. A typical switch uplink runs LACP to bundle physical links into one logical trunk, that trunk carries 802.1Q-tagged traffic for multiple VLANs (kept in sync across switches via VTP), STP runs underneath to make sure no unintended loop exists outside the bundled link, and LLDP/CDP quietly report neighbor information the whole time for visibility. None of these protocols replace each other — they solve different problems at the same layer.
With the roles of each protocol clear, the next natural question is which loop-prevention variant to actually deploy, since STP itself has evolved considerably since its original design.
Comparing STP, RSTP, and MSTP for Loop Prevention
Spanning Tree Protocol has gone through multiple revisions, and picking the right variant depends heavily on your topology size and convergence requirements.
| Criteria | STP (802.1D) | RSTP (802.1w) | MSTP (802.1s) |
|---|---|---|---|
| Convergence time | Slow — up to 30-50 seconds after a topology change | Fast — typically under 1-2 seconds | Fast — same rapid convergence as RSTP |
| VLAN handling | One spanning tree instance for the entire network (or per-VLAN with proprietary extensions) | One spanning tree instance for the entire network by default | Multiple instances, each mapped to a group of VLANs |
| Best for | Legacy networks with minimal redundancy changes; largely superseded today | Small to mid-sized networks with a single or few VLANs | Larger networks with many VLANs needing load balancing across redundant links |
| Load balancing across links | Not supported — one active path for the whole network | Not supported — one active path for the whole network | Supported — different VLAN groups can use different active paths |
| Configuration complexity | Low | Low | Higher — requires defining MST instances and VLAN-to-instance mapping |
| Backward compatibility | N/A (the original standard) | Compatible with legacy STP switches (falls back automatically) | Compatible with RSTP; requires matching MST region config to interoperate fully with other MSTP switches |
| Typical use case today | Rare in new deployments | Small offices, simple topologies, or a starting point before MSTP | Enterprise campus networks with many VLANs and a need for efficient link utilization |
The practical guidance: RSTP is the sensible default for most straightforward networks today, since it's simple to configure and converges quickly; reach for MSTP specifically when you have enough VLANs that spreading load across multiple redundant paths meaningfully improves bandwidth utilization, and you're prepared to manage the added instance-mapping complexity that comes with it.
Configuring VLAN Trunking and LACP: Step-by-Step
With the concepts and STP variant decided, here's how to actually bring 802.1Q trunking and LACP link aggregation to life on a Cisco-style switch.
- Configure the physical interfaces that will form your bundle. Before enabling LACP, make sure the member ports have matching speed, duplex, and VLAN settings — mismatches here are the most common cause of a bundle failing to form.
switch(config)# interface range gigabitEthernet 1/0/1-2
switch(config-if-range)# shutdown
- Enable LACP on the member interfaces. Use
activemode so the switch initiates negotiation rather than waiting passively (useactiveon at least one side of the connection).
switch(config-if-range)# channel-group 1 mode active
- Verify the port channel interface was created.
switch(config-if-range)# no shutdown
switch# show etherchannel summary
- Configure the resulting port-channel interface as an 802.1Q trunk. Once the physical interfaces are bundled, you configure trunking on the logical port-channel interface — not on the individual member ports.
switch(config)# interface port-channel 1
switch(config-if)# switchport trunk encapsulation dot1q
switch(config-if)# switchport mode trunk
- Restrict the trunk to only the VLANs it should actually carry. Allowing every VLAN by default is a common security and stability oversight — explicitly list only what's needed.
switch(config-if)# switchport trunk allowed vlan 10,20,30
- Set a native VLAN for untagged traffic. Make sure both ends of the trunk agree on the native VLAN — a mismatch here is a classic misconfiguration that silently leaks traffic between VLANs.
switch(config-if)# switchport trunk native vlan 99
- Verify the trunk and LACP bundle are both healthy.
switch# show interfaces trunk
switch# show etherchannel port-channel
switch# show lacp neighbor
- Confirm STP sees the port-channel as expected. Since the bundle is a single logical interface, STP treats it as one link — check that it's forwarding, not blocking, on the interface you expect.
switch# show spanning-tree interface port-channel 1
Once you've verified trunking, LACP bundling, and STP state all agree with each other, the logical link is functioning as intended — bandwidth is aggregated, VLANs are correctly tagged, and the whole bundle appears to STP as a single resilient path rather than multiple separate links it might otherwise block.
Layer 2 Protocol Command Cheat Sheet
For quick lookup during day-to-day work or troubleshooting, here's a consolidated reference covering the protocols discussed above plus VTP and neighbor discovery, beyond what was already configured step-by-step in the previous section.
# --- Spanning Tree Protocol ---
switch(config)# spanning-tree mode rapid-pvst # Enable RSTP (per-VLAN)
switch(config)# spanning-tree mode mst # Enable MSTP
switch(config)# spanning-tree vlan 10 priority 4096 # Influence root bridge election
switch# show spanning-tree summary # Verify STP mode and status
switch# show spanning-tree vlan 10 # View STP state for a VLAN
switch# show spanning-tree mst configuration # View MST region/instance mapping
# --- VLAN Trunking Protocol ---
switch(config)# vtp mode server # Set switch as VTP server
switch(config)# vtp mode client # Set switch as VTP client
switch(config)# vtp domain CORP # Set VTP domain name
switch(config)# vtp password S3cr3t # Set VTP authentication password
switch# show vtp status # Verify VTP mode/domain/revision
# --- LACP / EtherChannel ---
switch(config-if)# channel-group 1 mode active # Enable LACP (active)
switch(config-if)# channel-group 1 mode passive # Enable LACP (passive)
switch# show etherchannel summary # View all port-channel bundles
switch# show lacp counters # View LACP packet counters
# --- LLDP ---
switch(config)# lldp run # Enable LLDP globally
switch# show lldp neighbors # View discovered neighbors
switch# show lldp neighbors detail # Detailed neighbor info
# --- CDP (Cisco-only) ---
switch(config)# cdp run # Enable CDP globally
switch(config-if)# cdp enable # Enable CDP per interface
switch# show cdp neighbors # View discovered neighbors
switch# show cdp neighbors detail # Detailed neighbor info
# --- General troubleshooting ---
switch# show interfaces status # Quick port/VLAN/duplex overview
switch# show interfaces trunk # Trunk state and allowed VLANs
Bookmark this section specifically for moments when you already understand the concept and just need the exact syntax — pair it with the verification commands from the configuration walkthrough above when you need to confirm a change actually took effect.
Bringing It All Together
Layer 2 protocols are easiest to reason about once you see them as a stack of cooperating layers rather than isolated features: STP (or its faster RSTP/MSTP variants) keeps the topology loop-free, LACP reclaims bandwidth that STP would otherwise block, VLAN trunking and VTP keep segmentation consistent across switches, and LLDP/CDP give you visibility into how it's all physically connected. Start with the right STP variant for your topology size, configure trunking and LACP together rather than as separate afterthoughts, and keep the command cheat sheet handy for the inevitable 2 a.m. troubleshooting session — that combination covers the vast majority of real-world Layer 2 work.
