MDstable
NoteSnippetChecklistPlaybook

Spanning Tree Protocol — STP / RSTP / PVST+

Comprendre et configurer STP, RSTP, PVST+ et les protections PortFast/BPDU Guard

snippetintermediate 2025-05-14 6 min read
stprstppvstspanning-treeciscoportfastbpdu-guardloop

Concepts fondamentaux

STP 802 prvient les boucles L2 en bloquant des ports redondants
RSTP 802 convergence rapide < vs 30-50s pour STP classique
PVST Per-VLAN Spanning Tree Cisco une instance STP par VLAN
Rapid PVST RSTP PVST recommand sur Cisco moderne
MSTP 802 Multiple STP regrouper plusieurs VLANs par instance
lection Root Bridge
Le switch avec le Bridge ID priorit MAC le plus bas devient Root
Priorit par dfaut 32768 ; incrments de 4096
En pratique configurer manuellement la priorit du root
Rles des ports
Root Port RP meilleur chemin vers le Root Bridge 1 par switch
Designated Port DP port actif sur chaque segment forwarding
Blocked/Alternate port bloqu pour viter les boucles
Backup Port RSTP backup dun Designated sur le mme segment
tats des ports STP classique Disabled Blocking Listening Learning Forwarding
tats RSTP Discarding Learning Forwarding

Configuration Cisco — STP de base

Vérifier l'état STP actuel

text
Variables
{{VLAN_ID}}
show spanning-tree
show spanning-tree vlan {{VLAN_ID}}
show spanning-tree summary
show spanning-tree detail

Choisir le mode STP

text
conf t
! Rapid PVST+ (recommandé — défaut sur IOS moderne)
spanning-tree mode rapid-pvst
! PVST+ classique (compatibilité anciens équipements)
spanning-tree mode pvst
! MSTP
spanning-tree mode mst

Configurer le Root Bridge

text
conf t
! Méthode 1 : forcer la priorité manuellement (multiple de 4096)
spanning-tree vlan 10 priority 4096 ! Root primaire
spanning-tree vlan 10 priority 8192 ! Root secondaire
! Méthode 2 : macro Cisco (calcule automatiquement la priorité optimale)
spanning-tree vlan 10 root primary
spanning-tree vlan 10 root secondary
! Pour plusieurs VLANs d'un coup
spanning-tree vlan 10,20,30 root primary
spanning-tree vlan 40,50,60 root secondary
! Vérifier
show spanning-tree vlan 10 | include Root

Diameter et hello timers

text
conf t
! Modifier les timers (seulement sur le Root Bridge !)
spanning-tree vlan 10 hello-time 2 ! défaut = 2s
spanning-tree vlan 10 forward-time 15 ! défaut = 15s (listening+learning)
spanning-tree vlan 10 max-age 20 ! défaut = 20s
! En Rapid PVST+, les timers sont négociés automatiquement — ne pas modifier

PortFast

text
! Activer sur un port access individuel (postes, imprimantes, serveurs)
! → passe directement en Forwarding sans attendre la convergence STP
conf t
interface GigabitEthernet0/1
spanning-tree portfast
! Activer globalement sur TOUS les ports access (attention : pas sur les trunks)
conf t
spanning-tree portfast default
! Désactiver PortFast sur un trunk (si portfast default est activé globalement)
interface GigabitEthernet0/24
spanning-tree portfast disable
! Vérifier
show spanning-tree interface GigabitEthernet0/1 portfast
show running-config | include portfast

BPDU Guard

text
! BPDU Guard : si un BPDU est reçu sur un port PortFast → err-disable immédiat
! Empêche qu'un switch non autorisé soit branché sur un port access
! Activer sur une interface spécifique
conf t
interface GigabitEthernet0/1
spanning-tree bpduguard enable
! Activer globalement sur tous les ports PortFast
conf t
spanning-tree portfast bpduguard default
! Récupérer un port en err-disable
interface GigabitEthernet0/1
shutdown
no shutdown
! Récupération automatique (optionnel)
conf t
errdisable recovery cause bpduguard
errdisable recovery interval 300 ! secondes
! Vérifier les ports err-disabled
show interfaces status err-disabled
show errdisable recovery

BPDU Filter

text
! BPDU Filter : supprime l'envoi ET la réception de BPDUs
! ATTENTION : dangereux — peut créer des boucles. Utiliser avec précaution.
! Sur une interface (bloque totalement les BPDUs)
interface GigabitEthernet0/1
spanning-tree bpdufilter enable
! Globalement (seulement sur ports PortFast — si BPDU reçu, PortFast désactivé)
spanning-tree portfast bpdufilter default

Root Guard

text
Variables
{{VLAN_ID}}
! Root Guard : empêche un port de devenir Root Port
! → si un BPDU supérieur est reçu, le port passe en root-inconsistent (bloqué)
! Placer sur les ports Designated vers les switchs "inférieurs" (accès, distribution)
conf t
interface GigabitEthernet0/24
spanning-tree guard root
! Vérifier les ports inconsistants
show spanning-tree inconsistentports
show spanning-tree vlan {{VLAN_ID}} inconsistentports

Loop Guard

text
! Loop Guard : si un port Root/Alternate cesse de recevoir des BPDUs
! → passe en loop-inconsistent au lieu de Forwarding (évite la boucle)
! Complémentaire de Root Guard — activer sur les ports non-Designated
conf t
! Sur une interface
interface GigabitEthernet0/1
spanning-tree guard loop
! Globalement
spanning-tree loopguard default
! Vérifier
show spanning-tree detail | include loop

PVST+ — Équilibrage de charge par VLAN

text
! Stratégie : SW-CORE-1 = Root pour VLANs pairs, SW-CORE-2 = Root pour VLANs impairs
! → utilise les deux liens trunk simultanément
! Sur SW-CORE-1
conf t
spanning-tree vlan 10,30,50 root primary
spanning-tree vlan 20,40,60 root secondary
! Sur SW-CORE-2
conf t
spanning-tree vlan 20,40,60 root primary
spanning-tree vlan 10,30,50 root secondary

Vérifications complètes

text
Variables
{{VLAN_ID}}
! Vue globale de toutes les instances STP
show spanning-tree summary
! Détail complet d'une instance
show spanning-tree vlan {{VLAN_ID}} detail
! État des ports (roles, states, cost)
show spanning-tree vlan {{VLAN_ID}}
! Ports en état inconsistant (Root Guard, Loop Guard)
show spanning-tree inconsistentports
! Compteurs BPDU sur une interface
show spanning-tree interface GigabitEthernet0/1 detail
! Debug (à utiliser avec précaution en prod)
debug spanning-tree events
debug spanning-tree bpdu

Interprétation de show spanning-tree

VLAN0010
Spanning tree enabled protocol rstp
Root ID Priority 4106 4096 VLAN ID
Address aabbcc000100
This bridge is the root ce switch EST le root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4106
Address aabbcc000100
Interface Role Sts Cost PrioNbr Type
------------------- ---- --- --------- -------- ----
Gi0/1 Desg FWD 4 1281 P2p
Gi0/2 Desg FWD 4 1282 P2p
Gi0/3 Root FWD 4 1283 P2p Root Port
Gi0/4 Altn BLK 4 1284 P2p Bloqu
💡 Tip —

Activer BPDU Guard sur tous les ports access avec spanning-tree portfast bpduguard default — c'est la protection la plus simple et la plus efficace contre une boucle L2 involontaire. Si quelqu'un branche un switch non managé sur un port access, le port passe immédiatement en err-disable au lieu de propager une boucle sur tout le réseau.

OPS·BRAIN v1.027 notes · Networklocal