Switching, VLANs and Spanning Tree

Switching questions come in two shapes: a configuration that does not work, and a topology asking which port blocks. The command tables answer the first and the spanning tree tables answer the second.

VLAN and trunk commands

CommandWhat it does
vlan 20Create VLAN 20 and enter VLAN config
name SALESName the VLAN
interface gi0/1Enter interface config
switchport mode accessFix the port as an access port
switchport access vlan 20Put the access port in VLAN 20
switchport mode trunkFix the port as a trunk
switchport trunk allowed vlan 10,20Restrict which VLANs cross the trunk
switchport trunk native vlan 99Set the untagged VLAN. Must match both ends
show vlan briefVLANs and their ports
show interfaces trunkTrunk status, native and allowed VLANs

Spanning tree port states

StateForwards dataLearns MACsDuration
BlockingNoNo20 s max age
ListeningNoNo15 s forward delay
LearningNoYes15 s forward delay
ForwardingYesYesSteady state
DisabledNoNoAdministratively down

Spanning tree roles and election

ConceptRule
Root bridgeLowest bridge ID: priority first, then MAC address
Default priority32768, adjusted in increments of 4096
Root portOne per non-root switch, lowest cost to root
Designated portOne per segment, forwards toward the root
Blocking portEverything else, prevents the loop
PortFastAccess ports skip to forwarding. Never on a trunk to a switch
BPDU GuardShuts a PortFast port that receives a BPDU
RSTP (802.1w)Faster convergence, states are Discarding, Learning, Forwarding

EtherChannel and port security

FeatureDetail
LACPOpen standard, modes active and passive
PAgPCisco proprietary, modes desirable and auto
StaticMode on, no negotiation, both ends must match
Will not formMismatched speed, duplex, VLAN, or trunk mode
Port securityLimits MAC addresses learned on a port
Violation: protectDrops unknown traffic silently
Violation: restrictDrops and logs
Violation: shutdownErr-disables the port. The default
Sticky MACLearns and saves the address to the config

Now test yourself

Memorizing a table is a start. Practice questions are what make it stick, and every answer carries the full explanation.