In this lab we tune STP port priority and port cost on Cisco switches in Cisco Packet Tracer. STP (Spanning Tree Protocol) prevents loops in a switched network. When there is more than one path between switches, STP blocks some ports so frames do not circle around forever.
In the STP and root bridge article we chose which switch becomes the centre of the tree (the root bridge). This time we decide which ports forward and which get blocked, using two tools: port priority and port cost. One point trips up a lot of people: port priority has to be changed on the neighbour switch, not on the switch that is choosing its path. I prove it in a lab with three switches and two parallel cables. Everything was done in Cisco Packet Tracer 8.2.1.
Lab Topology and Devices
Three switches form a triangle. ROOT at the top is the root bridge. SW-B on the left connects to ROOT with two cables, while SW-C on the right connects to ROOT with one cable. SW-B and SW-C are also linked to each other.
The design has loops on purpose. The two parallel ROOT to SW-B cables make a small loop, and the ROOT, SW-B, SW-C triangle makes a big one. STP has to break both.
ROOT on top, SW-B on the left with two cables, SW-C on the right

All switch-to-switch links are dashed lines (crossover).
Switch links
ROOT Fa0/1 <-> SW-B Fa0/1
ROOT Fa0/2 <-> SW-B Fa0/2
ROOT Fa0/3 <-> SW-C Fa0/1
SW-B Fa0/3 <-> SW-C Fa0/2
PC Switch / Port IP
PC0 SW-B Fa0/4 192.168.1.10/24
PC1 SW-C Fa0/3 192.168.1.20/24
Bridge priority
ROOT 4096 (forced to be root bridge)
SW-B 32768 (default), MAC 00E0.F926.3AC1
SW-C 32768 (default), MAC 0002.4A06.8074Everything is in VLAN 1 and one subnet, so no router is needed.
Two parallel crossover cables from ROOT to SW-B

All four switch links use Copper Cross-Over. The PCs connect with Copper Straight-Through. The two parallel cables are the ones we steer with port priority.
STP Terms to Know First
Before typing commands, a few terms keep showing up in show spanning-tree. If they are not clear, the lab output is hard to read.
Every switch except the root picks one root port, its cheapest path to the root bridge. Its other ports become designated (forwarding) or alternate (blocked).
Term Meaning
Root port A switch's best port toward the root bridge (Root FWD)
Designated The port that forwards on a given cable segment (Desg FWD)
Alternate A backup port blocked to prevent a loop (Altn BLK)
Cost Path cost; FastEthernet is 19, lower is better
Prio.Nbr Port priority and port number, for example 128.1STP picks the root port in this order: lowest total cost, then lowest sender bridge ID, then lowest sender port priority, then lowest sender port number. The word sender matters, and it is exactly why port priority is set on the neighbour.
Setting the PC IP Addresses
Two PCs prove the network still works after we move STP paths around. They only need an IP, no gateway, because everything is in one subnet.
The steps are the same on both PCs.
Open PC0

Click PC0 at the bottom left.
PC0 IP

Desktop tab, IP Configuration, Static, then 192.168.1.10 with subnet mask 255.255.255.0. Give PC1 192.168.1.20.
Making ROOT the Root Bridge
Left alone, the root bridge is the switch with the lowest MAC, which could be any of them. To make the lab repeatable, I force ROOT to be the root bridge.
The priority must be a multiple of 4096. I use 4096, which is lower than the default 32768.
Open the ROOT switch

Click Switch0 at the top, then the CLI tab. Answer no if the initial configuration dialog appears.
enable
configure terminal
hostname ROOT
spanning-tree vlan 1 priority 4096
end
write memory
show spanning-treeROOT is the root bridge

You see This bridge is the root with priority 4097 (4096 plus VLAN number 1). Fa0/3 briefly shows Altn BLK while STP recalculates. After about 30 seconds every port on the root bridge is Desg FWD.
Default Behaviour on SW-B and SW-C
Now we look at what STP chooses before any tuning. This is our baseline, so the changes later are easy to spot.
On SW-B and SW-C I only change the hostname and run show spanning-tree.
Open SW-B

Click Switch1 on the left, then the CLI tab.
enable
configure terminal
hostname SW-B
end
write memory
show spanning-treeSW-B chooses Fa0/1 as its root port

SW-B’s root port is Fa0/1, shown as Port 1(FastEthernet0/1). Both cables to ROOT cost 19, and the sender bridge ID is the same (both are ROOT). The tie-breaker is the port priority and port number on the ROOT side: 128.1 beats 128.2. So Fa0/2 becomes Altn BLK.
Fa0/3 (toward SW-C) is Altn BLK too. That is part of the triangle loop, covered below.
Open SW-C

Click Switch2 on the right, then the CLI tab, and set the hostname to SW-C the same way.
SW-C uses its direct path to ROOT

SW-C’s root port is Fa0/1 with cost 19, the direct cable to ROOT. Fa0/2 (toward SW-B) is Designated.
Why is the SW-B end blocked and not the SW-C end? On the SW-B to SW-C cable both switches advertise the same cost to the root (19). The tie-breaker is bridge ID: SW-C (MAC 0002…) is lower than SW-B (MAC 00E0…), so SW-C wins and SW-B’s port gets blocked.
Test 1: Changing Port Priority on SW-B Itself
Many people want SW-B’s root port on Fa0/2, so they lower Fa0/2’s port priority on SW-B. It sounds reasonable, so let us test it.
In Packet Tracer, spanning-tree port-priority 16 without a VLAN is rejected with Invalid input. The per-VLAN form is accepted.
SW-B Fa0/2 port priority lowered to 16

configure terminal
interface fa0/2
spanning-tree vlan 1 port-priority 16
end
show spanning-treeThe Prio.Nbr column for Fa0/2 does change to 16.2, but the port is still Altn BLK and the root port is still Fa0/1. I waited more than 40 seconds and nothing changed.
My experience: This happens because STP compares the port priority of the BPDU sender, the switch on the other end of the cable. SW-B receives ROOT’s BPDUs on Fa0/1 and Fa0/2, and those BPDUs carry ROOT’s port priority, not SW-B’s. Changing the priority on SW-B therefore does not change SW-B’s own decision. After this test I removed the setting with no spanning-tree vlan 1 port-priority.
Test 2: Changing Port Priority on ROOT
Now the correct way. Lower the port priority on ROOT’s Fa0/2, the port cabled to SW-B’s Fa0/2.
Port priority must be a multiple of 16 between 0 and 240. The default is 128, and lower wins.
ROOT Fa0/2 port priority set to 16

configure terminal
interface fa0/2
spanning-tree vlan 1 port-priority 16
end
write memory
show spanning-treeROOT’s Fa0/2 now shows 16.2. Its state is briefly LSN (listening) while STP recalculates.
SW-B’s root port moves to Fa0/2

About 30 seconds later show spanning-tree on SW-B shows Port 2(FastEthernet0/2). Fa0/2 is Root FWD and Fa0/1 is Altn BLK. Notice SW-B’s own Prio.Nbr is still 128.1 and 128.2, because we changed ROOT’s port.
Test 3: Changing Port Cost on SW-C
Port priority only helps you choose between parallel cables to the same switch. To choose a genuinely different path, the tool is port cost.
On SW-C the direct path to ROOT costs 19. The path through SW-B costs 19 + 19 = 38. Raise the direct path’s cost to 100 and the path through SW-B becomes cheaper.
SW-C Fa0/1 cost raised to 100

configure terminal
interface fa0/1
spanning-tree vlan 1 cost 100
end
write memory
show spanning-treeThe Cost column for Fa0/1 changes to 100 straight away, but the root port is still Fa0/1 with Cost 19. STP has not finished recalculating.
After 40 seconds SW-C’s root port moves

Checking again, the Root ID shows Cost 38 and Port 2(FastEthernet0/2). Fa0/2 is Root FWD and Fa0/1 (cost 100) is Altn BLK. Unlike port priority, cost is set on the switch making the choice, because cost is added when a BPDU arrives on that port.
My experience: Do not panic if nothing changes right away. Classic STP needs 30 to 50 seconds to go through listening and learning. That delay is also why many networks run Rapid PVST+, which is much faster.
Proving the Network Still Works
After two path changes, we check that the PC on SW-B and the PC on SW-C can still talk. Their traffic now uses the SW-B to SW-C cable that used to be blocked.
The port colours on the topology change too. Packet Tracer marks STP-blocked ports with an orange dot.
Orange ports are blocked ports

The blocked ports are now SW-B Fa0/1 (the parallel cable that lost on port priority) and SW-C Fa0/1 (lost on cost). The SW-B to SW-C cable is active at both ends.
PC0 pings PC1

From PC0’s Command Prompt:
ping 192.168.1.204 replies, 0% loss. Loops are still prevented, and traffic follows the path we chose.
Port Priority or Port Cost?
These two get mixed up because both change the root port. The difference is where you configure them and when you use them.
This table sums up the three tests above.
Port priority Port cost
Configured on the neighbour (BPDU sender) the switch choosing the path
Use it to pick between parallel cables pick a different path
to the same switch (direct vs roundabout)
Values 0-240, multiples of 16 1-200000000
Default 128 19 (FastEthernet)
PT command spanning-tree vlan 1 spanning-tree vlan 1
port-priority 16 cost 100Common Problems and Fixes
STP mistakes rarely produce an error. The switch accepts the command, but the path does not change the way you expected.
Make a habit of waiting about 50 seconds and then running show spanning-tree on every switch involved.
Port priority changed but the root port did not move
You changed it on the wrong switch. Set it on the neighbour’s port that connects to the port you want as root port.
spanning-tree port-priority is rejected
Packet Tracer wants a VLAN number: spanning-tree vlan 1 port-priority 16.
Cost changed but nothing happened yet
STP is still listening and learning. Wait 30 to 50 seconds and check again.
The priority value is rejected
Port priority must be a multiple of 16, such as 0, 16, 32, up to 240. Bridge priority must be a multiple of 4096.
We have now steered STP in two different ways, proved that port priority belongs on the neighbour, and watched cost move the path onto a longer route. If you would rather bundle the parallel cables so neither gets blocked, see EtherChannel mode on and PAgP configuration. When a switch carries several VLANs, STP paths can even differ per VLAN. That is covered in PVST+ and Rapid PVST+ configuration. If something breaks while you follow along, leave a comment below.












