From point A to point B
Point A: You configure trunks and VLANs, but when links are redundant you don't know why one ends up blocked or how to change the path a VLAN's traffic takes. Point B: By the end you will configure an 802.1Q trunk, synchronize VLANs with VTP without surprises, read the output of show spanning-tree vlan and pick the root bridge of each VLAN to spread traffic across your links.
This chapter covers the four parts of the last block of Day 1: trunks and VTP, STP per VLAN, root bridge per VLAN and traffic per VLAN. They are one exercise on one topology: first the trunks are built, then you watch how Spanning Tree decides, and finally you move the tree on purpose.
802.1Q trunks: many VLANs over one cable
An access port belongs to a single VLAN. A trunk port carries several VLANs over the same link between switches. So the switch at the other end knows which VLAN each frame belongs to, 802.1Q inserts a 4-byte tag that includes the VLAN ID (12 bits: values 1 to 4094). Normal-range VLANs go from 1 to 1005 and extended-range VLANs from 1006 to 4094. The only VLAN that travels untagged is the native VLAN (VLAN 1 by default); both ends must agree on which one it is.
A trunk can be negotiated with DTP (Dynamic Trunking Protocol) or set by hand. In production, set it by hand: fewer surprises and less attack surface.
| Mode (switchport mode) | Behavior | Forms a trunk with |
|---|---|---|
| access | Never a trunk | Nobody |
| trunk | Always a trunk and sends DTP | trunk, dynamic desirable, dynamic auto |
| dynamic desirable | Actively asks to become a trunk | trunk, desirable, auto |
| dynamic auto | Passive: accepts if the other side asks (default on many Catalyst) | trunk, desirable (two auto ports do not form a trunk) |
| nonegotiate | Fixed trunk without sending DTP | One end set to trunk |
SW4(config)# interface range FastEthernet0/19 - 24
SW4(config-if-range)# description Conexiones trunk 802.1Q
SW4(config-if-range)# switchport mode trunk
SW4(config-if-range)# switchport nonegotiate
SW4(config-if-range)# switchport trunk native vlan 99
SW4(config-if-range)# switchport trunk allowed vlan 1,10-13,99
SW4(config-if-range)# no shutdown
Fixed trunk on six ports. The last two configuration lines are optional: they change the native VLAN and limit which VLANs travel.
switchport trunk encapsulation dot1q. On 2960 switches only 802.1Q exists and the command does not exist.SW4# show interfaces trunk
Port Mode Encapsulation Status Native vlan
Fa0/19 on 802.1q trunking 99
Fa0/20 on 802.1q trunking 99
Port Vlans allowed on trunk
Fa0/19 1,10-13,99
Port Vlans allowed and active in management domain
Fa0/19 1,10-13,99
Port Vlans in spanning tree forwarding state and not pruned
Fa0/19 1,10-13,99
Verification: Mode, Status and Native vlan in the first table; the other three show which VLANs are allowed, which exist and which Spanning Tree is forwarding.
VTP: distributing VLANs across the domain
VTP (VLAN Trunking Protocol) advertises the VLAN database over trunks so you create VLANs on one switch and the others learn them. Two switches synchronize only if they share the same domain name (and the same password, if any) and have a trunk between them. Every change on a server raises the configuration revision; a switch that receives an advertisement with a higher revision replaces its database.
| VTP mode | What it can do |
|---|---|
| server | The default. Creates, modifies and deletes VLANs and advertises them |
| client | Learns and relays advertisements; cannot create, modify or delete VLANs |
| transparent | Does not synchronize; keeps its own VLANs; in VTP v2 it relays advertisements |
| off | Like transparent, but does not relay advertisements |
SW3(config)# vtp domain THOR
SW3(config)# vtp mode server
SW3(config)# vtp version 2
SW3(config)# vlan 10
SW3(config-vlan)# name LAN-10
SW3(config-vlan)# exit
SW4(config)# vtp domain THOR
SW4(config)# vtp mode client
SW4# show vtp status
VTP Version : 2
Configuration Revision : 5
Maximum VLANs supported locally : 255
Number of existing VLANs : 9
VTP Operating Mode : Client
VTP Domain Name : THOR
SW3 is the VLAN server of the THOR domain; SW4 learns the VLANs. Always check with show vtp status and show vlan brief.
The risk is the revision. If you plug in a switch with a higher revision (for example one coming from another lab) into a domain with the same name, its VLANs replace those of the entire network, and deleting a VLAN on a server deletes it on every client. Before connecting a used switch, bring its revision to 0: change the domain name to a different one and then set the original back (Cisco documents this method).
SW5(config)# vtp domain TEMP
SW5(config)# vtp domain THOR
SW5# show vtp status | include Revision
Configuration Revision : 0
Resetting the VTP revision before connecting a reused switch.
switchport mode trunk on both sides). And confirm with show interfaces trunk that the ports did not stay in access: it is the most common mistake.transparent or off and create VLANs by hand or with automation.STP per VLAN: one tree for each broadcast domain
Cisco switches run PVST+ (Per-VLAN Spanning Tree Plus) by default: one independent STP instance per VLAN. Each VLAN is a different broadcast domain, so each has its own root bridge, its own port roles and its own state. The view is entirely logical: it does not depend on how the cables are physically connected, but on which VLANs cross each trunk.
The election uses the Bridge ID (BID): priority + extended system ID (the VLAN number) + MAC. The default priority is 32768, so the BID for VLAN 10 starts at 32778 and the one for VLAN 1 at 32769. The lowest BID wins; if priorities tie, the lowest MAC breaks the tie (so, with no configuration, the oldest switch wins, which is almost never the one you want).
This repeats independently in every VLAN.
- The root bridge has all its ports in the designated role and forwarding state.
- A non-root switch has one root port only: the one giving the lowest-cost path to the root. Cost adds up over each link: 100 (10 Mb/s), 19 (100 Mb/s), 4 (1 Gb/s), 2 (10 Gb/s) with the 802.1D short method.
- Each segment has one designated port, on the switch with the lowest cost to the root; the other end becomes alternate and blocks to prevent a loop.
- Default timers: hello 2 s, max age 20 s, forward delay 15 s. A port that recovers without PortFast goes through blocking, listening and learning before forwarding.
SW2# show spanning-tree vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 24586
Address 0001.4a2b.7c01
Cost 4
Port 2 (GigabitEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 0001.4a2b.7c02
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------
Gi0/1 Altn BLK 4 128.1 P2p
Gi0/2 Root FWD 4 128.2 P2p
Example output on a non-root switch (SW2): the root is reached through Gi0/2; Gi0/1 is alternate and in BLK. The local BID 32778 is 32768 + VLAN 10.
Root bridge per VLAN: you choose, not the MAC
Since each VLAN has its own tree, you can assign a different root to each. There are two ways: the root primary / root secondary shortcut, or setting the priority directly. With PVST+ and extended system ID the priority can only be a multiple of 4096.
SW1(config)# spanning-tree vlan 1 root primary
SW1(config)# spanning-tree vlan 10 root secondary
SW3(config)# spanning-tree vlan 10 root primary
SW3(config)# spanning-tree vlan 1 root secondary
SW3(config)# spanning-tree vlan 10 priority 4096
SW1 rules VLAN 1 and backs up VLAN 10; SW3 does the opposite. The last line shows the manual form (4096 is the lowest practical priority).
| Value in VLAN 10 | Advertised priority | Set by |
|---|---|---|
| Default | 32768 + 10 = 32778 | IOS |
| root primary | 24576 + 10 = 24586 (if the current root has more than 24576; otherwise 4096 less than it) | Macro |
| root secondary | 28672 + 10 = 28682 | Macro |
| priority 4096 | 4096 + 10 = 4106 | Manual |
Check that the change worked: the switch that is now root will say This bridge is the root and all its ports move to Desg FWD. The other switches see a new root and recalculate their root port. That is why, in the class lab, the VLAN 1 root showed priority 24577: 24576 from root primary plus the VLAN ID.
SW3(config)# spanning-tree vlan 10 root primary
SW3(config)# end
SW3# show spanning-tree vlan 10
VLAN0010
Root ID Priority 24586
Address 0001.4a2b.7c03
This bridge is the root
Bridge ID Priority 24586 (priority 24576 sys-id-ext 10)
Interface Role Sts Cost Prio.Nbr Type
Gi0/2 Desg FWD 4 128.2 P2p
Gi0/3 Desg FWD 4 128.3 P2p
After root primary, the switch declares itself root of VLAN 10 with 24586.
root primary on the switch where you want the root and root secondary on the backup. Do not let MAC luck decide: an old access switch in a corner can end up as the center of the tree.Traffic engineering: moving the tree on purpose
The class exercise: three switches in a triangle (SW1, SW2, SW3), trunks between all of them and two VLANs, 1 and 10. The goal is for VLAN 1 traffic to go over one side of the network and VLAN 10 traffic over the other, even though both use the same cables. That is layer 2 traffic engineering: you do not create new links, you change where each tree's root is.
Repeat VLAN by VLAN until you get the split you want.
SW2# show spanning-tree vlan 1 root
Vlan Root ID Cost Time Age Dly Root Port
VLAN0001 24577 0001.4a2b.7c01 4 2 20 15 Gi0/1
SW2# show spanning-tree vlan 10 root
Vlan Root ID Cost Time Age Dly Root Port
VLAN0010 24586 0001.4a2b.7c03 4 2 20 15 Gi0/2
On SW2 (the middle switch), the root port changes with the VLAN: Gi0/1 toward SW1 for VLAN 1 and Gi0/2 toward SW3 for VLAN 10.
On SW2 what you expect happens: in VLAN 1 it blocks the link toward SW3 (Gi0/2) and in VLAN 10 it blocks the link toward SW1 (Gi0/1). Each VLAN leaves one link unused, but a different link, so no cable sits idle for all VLANs. Which end blocks is decided by the BID tie-break; that is why it pays to define the root secondary.
For finer tuning you can change a port's cost per VLAN on the receiving switch, or the port-priority (multiples of 16, 128 by default) on the switch at the root side to break ties between parallel links.
SW2(config)# interface GigabitEthernet0/2
SW2(config-if)# spanning-tree vlan 10 cost 2
SW3(config)# interface GigabitEthernet0/2
SW3(config-if)# spanning-tree vlan 10 port-priority 64
Per-VLAN cost on the non-root switch's port and port-priority on the root side.
Traffic per VLAN: access ports and troubleshooting
A PC connects to an access port in its VLAN. If two PCs are in VLAN 10, they do not need to be on the same switch: their frames travel tagged over the trunks until they arrive. A user-facing access port should be hardened: no trunk negotiation, PortFast so it goes straight to forwarding, and BPDU Guard so it shuts down if someone plugs in a switch.
SW2(config)# interface FastEthernet0/1
SW2(config-if)# description PC-VLAN10
SW2(config-if)# switchport mode access
SW2(config-if)# switchport access vlan 10
SW2(config-if)# switchport nonegotiate
SW2(config-if)# spanning-tree portfast
SW2(config-if)# spanning-tree bpduguard enable
SW2# show vlan brief
SW2# show interfaces FastEthernet0/1 switchport
Typical access port configuration in VLAN 10 and the two commands to confirm it.
When a PC asks for an IP in its own subnet, it sends an ARP: a layer 2 broadcast frame. The switch floods it out every port in that VLAN (and over the trunks that allow it), never outside it. Until the ARP table exists there is no communication, however perfect the tree is. That is why troubleshooting always starts at layers 1 to 3, not at STP.
| Symptom | Command | Likely cause |
|---|---|---|
| VLANs do not reach the other switch | show interfaces trunk | Port in access, VLAN not in allowed list, or VLAN does not exist |
| VLANs are not learned via VTP | show vtp status | Different domain, password, version or mode; trunk down |
| Traffic takes an unexpected path | show spanning-tree vlan N | That VLAN's root is not the one you think |
| An access port goes errdisable | show interfaces status err-disabled | BPDU Guard detected a BPDU |
| A link is blocked | show spanning-tree vlan N | Normal operation: alternate in BLK |
shutdown and no shutdown on the interface, or restart the device, before hunting for a fault that does not exist. On real equipment this should not be needed.Class videos
- Day 1 · Part 8.1Trunks and VTPWatch video
- Day 1 · Part 8.2STP per VLANWatch video
- Day 1 · Part 8.3Root bridge per VLANWatch video
- Day 1 · Part 8.4Per-VLAN trafficWatch video
Recorded live in 2021; Spanish audio with Spanish, English, French and Portuguese subtitles. When you play it, the video loads from YouTube. Day 1 playlist on YouTube
Test what you learned
1. A switch has priority 24576 and became root of VLAN 10. What BID does it advertise for that VLAN?
Answer. Answer. 24586. With extended system ID, the BID is priority + VLAN number: 24576 + 10. The VLAN 1 root with the same priority would be 24577.
2. Two switches are in different VTP domains, both with switchport mode dynamic desirable, and the trunk does not come up. Why, and how do you fix it?
Answer. Answer. DTP carries the VTP domain name and does not negotiate the trunk if the domains differ. Fix: make the domains match or set switchport mode trunk (with nonegotiate) on both sides.
3. You plug a switch with configuration revision 25 into a VTP domain of the same name whose revision is 8. The new switch is in server mode. What happens, and how did you avoid it?
Answer. Answer. The domain adopts the new switch's database, which has the higher revision, and you can lose VLANs across the network. You avoid it by bringing the revision to 0 before connecting: change the domain name and then set the original back.
4. A non-root switch has three parallel links to the root switch. How many forward, and how do you use all three?
Answer. Answer. Only one forwards (the root port); the other two are alternate and in blocking. You use all three by bundling them into an EtherChannel, which STP treats as a single link.
5. You want SW3 to be root of VLAN 10 without touching VLAN 1. Which command do you use and what do you verify?
Answer. Answer. spanning-tree vlan 10 root primary on SW3. You verify with show spanning-tree vlan 10 that it says "This bridge is the root" with all ports Desg FWD, and that the other switches change their root port; VLAN 1 does not change because it has its own tree.
Key takeaways
- An 802.1Q trunk tags frames with the VLAN ID; only the native VLAN travels untagged and it must match on both ends.
- Set trunks by hand (
switchport mode trunk) instead of relying on DTP, and always validate withshow interfaces trunk. - VTP synchronizes VLANs by domain, password and revision: a switch with a high revision can wipe the VLANs of the whole network; reset the revision before reusing a switch.
- PVST+ runs one tree per VLAN: each has its own root bridge, roles and states.
- The BID is priority + VLAN ID + MAC;
root primarylowers the priority to 24576 androot secondarysets it to 28672. - The root has all ports designated/forwarding; every other switch has one root port and blocks redundant links.
- With a different root per VLAN you spread traffic across links without touching the cabling.
- Access ports get PortFast and BPDU Guard; troubleshooting starts at layers 1 to 3 and then STP.
Official resources
Source and credits. Chapter written from the CCNA 200-301 Bootcamp that Jesús Espinoza recorded live in 2021, on the v1.0 syllabus; the current exam is v1.1. Text drafted with AI assistance and reviewed; original diagrams by The House of Routing. Technical data and configuration were checked against Cisco's official documentation, IETF RFCs and IEEE standards.