Jeremy’s IT Lab lecture video:
Day 20 - Spanning Tree Protocol (STP) (1)
Commands
Commands List
Spanning Tree Show Commands
6. Spanning Tree
Link to original
- show spanning-tree
-->Shows general STP status and information- show spanning-tree vlan vlan-id
-->Shows spanning-tree information for a specific VLAN- show spanning-tree detail
-->Shows detailed STP information- show spanning-tree summary
-->Shows a summary of the current STP configurationSpanning Tree Interface Commands
Spanning Tree
1. General
- spanning-tree mode mode {mst
/pvst/rapid-pvst} (Versions)2. Spanning Tree Portfast / BPDU Guard
- spanning-tree portfast
-->Enables portfast on the current interface.- spanning-tree portfast default
-->Enables Portfast on all access ports by default.- spanning-tree bpduguard enable
-->Enables BPDU Guard on the current interface.- spanning-tree portfast bpduguard default
-->Enables BPDU Guard on all Portfast-enabled interfaces by default.3. Spanning Tree VLAN Related
- spanning-tree vlan vlan-id root primary
-->Sets the STP bridge priority to 24576 (Or 4096 lower than the current lowest STP priority.)- spanning-tree vlan vlan-id root secondary
-->Sets the STP bridge priority to 28672- spanning-tree vlan vlan-id cost number
-->Changes the interface’s STP root cost- spanning-tree vlan vlan-id port-priority number
-->Changes the interface’s port priority4. Spanning Tree Link Type
Link to original
- spanning-tree link-type type { point-to-point
/shared }
Spanning Tree Protocol (STP) Info
Redundancy is an important part of modern network design, and the Spanning Tree Protocol (STP) was made to help with that.
Broadcast Storms
The Ethernet frame doesn’t have a Time-To-Live (TTL) field. Therefore, when a switch sends out a broadcast/unknown unicast message, to a network with a lot of switches, there’s a chance the messages will keep looping. Eventually, there will be a lot of looping broadcasts in the network which will lead to congestion in the network making it unusable for legitimate traffic. This is called a broadcast storm
Network congestions leads to MAC Address Flapping. Each time a frame arrives on a switchport, the switch uses the source MAC address to update its MAC address table. When frames with the same source MAC address repeatedly arrive on different interfaces, the switch is continuously updating the interface the interface in its MAC address table, which leads to MAC Address Flapping.
Classic Spanning Tree Protocol
The ‘Classic Spanning Tree Protocol’ is IEEE 802.1D. Switches from all vendors run STP by default.
- STP prevents loops by placing redundant ports in a blocking state. These become disabled interfaces which can enter a forwarding state if a currently forwarding interface fails.
- Forwarding interfaces send and receive all normal traffic as well as Bridge Protocol Data Units (BPDUs).
- Blocking interfaces only send or receive STP messages called Bridge Protocol Data Units (BPDUs).
- By selecting forwarding and blocking ports, STP creates a single path to/from each point in the network. This prevents Layer 2 loops.
- STP-enabled switches send/receive Hello BPDUs out of all of their interfaces every 2 seconds (default timer).
- If a switch receives a Hello BPDU on an interface, it knows that the interface its connected to belongs to another switch, as end hosts don’t use STP and therefore don’t send Hello BPDUs.
Bridge Protocol Data Unit
Switches use one field in the STP BPDU, the Bridge ID field, to elect a root bridge for the network.
The switch with the lowest Bridge ID becomes the root bridge. All ports on the root bridge must be in a forwarding state in each collision domain, and other switches must have a path to the root bridge.
![]() |
|---|
| Bridge ID Field |
- The bridge priority is 32768 by default.
- The STP bridge priority can only be changed in units of 4096.
- If all switches have the same bridge priority, the lowest MAC address becomes the root bridge.
- (The Bridge Priority is compared first, if they tie, then the MAC address is used as a tie-breaker)
- For Cisco switches, they use a version of STP called PVST (Per-VLAN Spanning Tree) which runs a separate STP instance in each VLAN, so in each VLAN, different interfaces could be either forwarding or blocking.
- To calculate the total bridge priority, we add up the bridge priority and the extended system ID (VLAN ID).
Every switch assumes it’s the root bridge when it is powered on, and it will only give up that status if it receives a superior BPDU (a lower bridge ID)
Only the root bridge sends the BPDUs, other switches in the network will forward them, but not generate their own.
Spanning Tree Root Costs & Port Priority
| Speed | STP Cost |
|---|---|
| 10 Mbps | 100 |
| 100 Mbps | 19 |
| 1 Gbps | 4 |
| 10 Gbps | 2 |
The port priority of all interfaces is 128.interface-id by default.
- Ex: Interface G0/1 would have a default port priority of 128.1
The Process of Assigning Ports in Spanning Tree
- One switch is the root bridge, and all the ports on it are designated ports (forwarding state)
- Root bridge selection is done through:
- Lowest bridge ID
- Root bridge selection is done through:
- Remaining switches will select one root port (forwarding state). Ports across from the root port are ALWAYS designated ports
- Root port selection is done through:
- Lowest root cost
- Lowest neighbor bridge ID
- Lowest neighbor port ID
- Root port selection is done through:
- Each remaining collision domain will select one designated port (forwarding state) and one non-designated port (blocking state)
- Designated port selection is done through:
- Interface on switch with lowest root cost
- Interface on switch with lowest bridge ID
- Designated port selection is done through:
Jeremy’s IT Lab előadásvideó:
20. Nap - Spanning Tree Protocol (STP) (1)
Parancsok
Parancslista
Spanning Tree Show Parancsok
6. Spanning Tree
Eredeti hivatkozása
- show spanning-tree
-->Megjeleníti az általános STP állapotot és információkat- show spanning-tree vlan vlan-id
-->Megjeleníti egy adott VLAN spanning-tree információit- show spanning-tree detail
-->Részletes STP információkat jelenít meg- show spanning-tree summary
-->Összefoglalót jelenít meg az aktuális STP konfigurációrólSpanning Tree Interfész Parancsok
Spanning Tree
1. Általános
- spanning-tree mode mode {mst
/pvst/rapid-pvst} (Verziók)2. Spanning Tree Portfast / BPDU Guard
- spanning-tree portfast
-->Engedélyezi a portfastot az aktuális interfészen.- spanning-tree portfast default
-->Alapértelmezés szerint engedélyezi a Portfastot minden access porton.- spanning-tree bpduguard enable
-->Engedélyezi a BPDU Guardot az aktuális interfészen.- spanning-tree portfast bpduguard default
-->Alapértelmezés szerint engedélyezi a BPDU Guardot minden Portfast-engedélyezett interfészen.3. Spanning Tree VLAN-hoz kapcsolódó parancsok
- spanning-tree vlan vlan-id root primary
-->Az STP bridge priority értékét 24576-ra állítja (Vagy 4096-tal alacsonyabbra a jelenlegi legalacsonyabb STP priority-nél.)- spanning-tree vlan vlan-id root secondary
-->Az STP bridge priority értékét 28672-re állítja- spanning-tree vlan vlan-id cost number
-->Módosítja az interfész STP root cost értékét- spanning-tree vlan vlan-id port-priority number
-->Módosítja az interfész port priority értékét4. Spanning Tree Link Típus
Eredeti hivatkozása
- spanning-tree link-type type { point-to-point
/shared }
Spanning Tree Protocol (STP) Információk
A redundancia a modern hálózattervezés fontos része, és a Spanning Tree Protocol (STP) ennek biztosítására és támogatására jött létre.
Broadcast Viharok (Broadcast Storms)
Az Ethernet frame nem rendelkezik Time-To-Live (TTL) mezővel. Emiatt, ha egy switch broadcast vagy unknown unicast üzenetet küld ki egy olyan hálózatba, ahol sok switch van összekötve, fennáll a veszélye, hogy az üzenetek végtelen hurokba (loop) kerülnek. Végül hatalmas mennyiségű keringő broadcast forgalom alakul ki a hálózatban, ami hálózati torlódáshoz vezet, és használhatatlanná teszi azt a legitim adatforgalom számára. Ezt nevezzük broadcast viharnak (broadcast storm).
A hálózati hurkok MAC Address Flappinghez vezetnek. Minden alkalommal, amikor egy frame beérkezik egy switchportra, a switch a forrás MAC-címet (source MAC address) használja a MAC address táblájának frissítésére. Amikor azonos forrás MAC-című frame-ek folyamatosan más-más interfészekre érkeznek, a switch folyamatosan frissíti a bejegyzéshez tartozó interfészt a MAC address táblájában, ami a MAC Address Flapping jelenségét okozza.
Klasszikus Spanning Tree Protocol
A „Klasszikus Spanning Tree Protocol” az IEEE 802.1D szabvány. Minden gyártó switchén alapértelmezés szerint fut az STP.
- Az STP úgy akadályozza meg a loopokat, hogy a redundáns portokat blocking (blokkolt) állapotba helyezi. Ezek inaktív interfészekké válnak, amelyek forwarding állapotba léphetnek, ha egy jelenleg továbbító interfész meghibásodik.
- A forwarding interfészek továbbítják és fogadják az összes normál adatforgalmat, valamint a Bridge Protocol Data Unit-okat (BPDU-kat).
- A blocking interfészek kizárólag Bridge Protocol Data Unit-oknak (BPDU-knak) nevezett STP üzeneteket küldenek vagy fogadnak.
- A forwarding és blocking portok kiválasztásával az STP egyetlen hurkamentes útvonalat hoz létre a hálózat minden pontja között. Ez megakadályozza a Layer 2 loopokat.
- Az STP-engedélyezett switchek minden interfészükön 2 másodpercenként (alapértelmezett időzítő) Hello BPDU-kat küldenek és fogadnak.
- Ha egy switch egy interfészen Hello BPDU-t kap, tudja, hogy a csatlakozó interfész egy másik switchhez tartozik, mivel a végberendezések nem használnak STP-t, és így nem küldenek Hello BPDU-kat.
Bridge Protocol Data Unit
A switchek az STP BPDU egyik mezőjét, a Bridge ID mezőt használják a hálózat root bridge-ének megválasztására.
A legalacsonyabb Bridge ID-val rendelkező switch válik root bridge-dzsé. A root bridge-en minden portnak forwarding állapotban kell lennie minden collision domainben, és a többi switchnek rendelkeznie kell útvonallal a root bridge felé.
![]() |
|---|
| Bridge ID Mező |
- A bridge priority alapértelmezetten 32768.
- Az STP bridge priority csak 4096-os lépésközökben módosítható.
- Ha minden switch azonos bridge priority értékkel rendelkezik, a legalacsonyabb MAC address lesz a root bridge.
- (A Bridge Priority-t hasonlítják össze először; holtverseny esetén a MAC address dönti el a választást)
- A Cisco switchek az STP egy PVST (Per-VLAN Spanning Tree) nevű változatát használják, amely külön STP példányt futtat minden egyes VLAN-ban, így az egyes VLAN-okban a különböző interfészek lehetnek forwarding vagy blocking állapotban.
- A teljes bridge priority kiszámításához összeadjuk a bridge priority-t és az extended system ID-t (VLAN ID-t).
Bekapcsoláskor minden switch feltételezi, hogy ő a root bridge, és csak akkor mond le erről a státuszról, ha egy fölényesebb (superior) BPDU-t kap (egy alacsonyabb bridge ID-val).
Kizárólag a root bridge küld BPDU-kat; a hálózat többi switch-e továbbítja őket, de nem generál sajátokat.
Spanning Tree Root Cost & Port Priority
| Sebesség (Speed) | STP Költség (Cost) |
|---|---|
| 10 Mbps | 100 |
| 100 Mbps | 19 |
| 1 Gbps | 4 |
| 10 Gbps | 2 |
Minden interfész port priority értéke alapértelmezetten 128.interface-id.
- Példa: A G0/1 interfész alapértelmezett port priority-je 128.1
A Portok Kiosztásának Folyamata a Spanning Tree-ben
- Egyetlen switch a root bridge, és rajta minden port designated port (forwarding állapot)
- A root bridge kiválasztásának szempontja:
- Legalacsonyabb bridge ID
- A root bridge kiválasztásának szempontja:
- A többi switch kiválaszt egyetlen root portot (forwarding állapot). A root porttal szemközti portok MINDIG designated portok
- A root port kiválasztása a következők alapján történik:
- Legalacsonyabb root cost
- Legalacsonyabb szomszéd (neighbor) bridge ID
- Legalacsonyabb szomszéd (neighbor) port ID
- A root port kiválasztása a következők alapján történik:
- Minden fennmaradó collision domain kiválaszt egy designated portot (forwarding állapot) és egy non-designated portot (blocking állapot)
- A designated port kiválasztása a következők alapján történik:
- A legalacsonyabb root costtal rendelkező switch interfésze
- A legalacsonyabb bridge ID-val rendelkező switch interfésze
- A designated port kiválasztása a következők alapján történik:
-(1)/ATCH-Day-20---Spanning-Tree-Protocol-(STP)-(1)-20240320221938.webp)