4.STP Lab Guide
4.STP Lab Guide
1
STP Lab Guide
(2) Manually specify SW1 as the root bridge and SW2 as the backup root bridge.
(3) Change the cost values of ports to make port G0/1 of SW4 the root port.
(4) Configure the priority of port G0/1 of SW1 to make port G0/1 of SW2 the root port.
1.1.6 Procedure
(1) Enable STP on SW1–SW4 and change the STP mode to RSTP. Perform the same
configuration on SW1–SW4. Only the configurations of SW1 are listed below. On an actual
network, if STP is disabled on a device by default, do not start devices at the same time to
prevent loops.
Ruijie-SW1 (config)#spanning-tree
Ruijie-SW1 (config)#spanning-tree mode stp
(2) Change the bridge priorities of SW1 and SW2 to make SW1 the root bridge and SW2 the
backup root bridge.
Analysis: Two parameters are compared in the root bridge election. The two parameters
are the bridge priority and MAC address in the order of priority. A smaller parameter value
indicates a higher priority.
You need to manually specify the device priority to control the root bridge election. Here,
set the priority of SW1 to 4096 and the priority of SW2 to 8192.
Ruijie-SW1(config)#spanning-tree priority 4096
Ruijie-SW2(config)#spanning-tree priority 8192
2
STP Lab Guide
(3) Change the cost value of a port on SW4 to make port Gi0/1 the root port.
Analysis: After the priorities of SW1 and SW2 are changed in step 2, SW1 becomes the root
bridge and SW2 becomes the backup root bridge. On SW4, BPDUs are received by ports G0/0,
G0/1, and G0/2. The root port selection process of SW4 is as follows:
a The device compares the cost values in the three BPDUs (the cost values in the BPDUs
received by ports G0/0 and G0/1 are 40000, and the cost value in the BPDU received by
port G0/2 is 20000).
b The device compares bridge IDs in the three BPDUs. A bridge ID is composed of the
bridge priority and device MAC address, and the bridge priorities are compared first and
then the MAC addresses are compared. A smaller value indicates a higher priority. The
priority in the BPDU received by port G0/0 is 32768, the priority in the BPDU received by
port G0/1 is 8192, and the priority in the BPDU received by port G0/2 is 4096.
c The device compares port IDs in the three BPDUs. A port ID is composed of the port
priority and port ID, and the port priorities are compared first and then port IDs are
compared. A port with a smaller port ID will become the root port.
The figure below shows the status of ports on SW4. Port G0/2 is the root port, port G0/1 is
a backup port, and it is in the blocked state.
Adjust the cost values of ports as required so that the cost value from port G0/1 to the root
bridge is minimum. According to the rules above, adjust the cost value of port G0/2 to be greater
than 40000. Set it to 40001 here. The figure below shows the result after adjustment.
Ruijie-SW4(config)#interface gigabitEthernet 0/2
Ruijie-SW4(config-if-GigabitEthernet 0/2)#spanning-tree cost 40001
3
STP Lab Guide
(4) Change the priority of port G0/1 of SW1 to make G0/1 of SW2 the root port.
Analysis: SW2 receives BPDUs through four ports. According to the root port selection
process described in step 3, we need to focus only on the parameters in the BPDUs received
by ports G0/0 and G0/1.
BPDUs received by ports G0/0 and G0/1 are both sent by the root bridge. Therefore, which
port is better cannot be compared in a) and b) in step 3 and c) needs to be carried out for
comparison.
The port priority is the default value, that is, 128. Therefore, the root port can be selected
only by comparing port IDs. In this topology, port G0/0 has a smaller port ID than port G0/1 in
the BPDUs received by SW2 from SW1. Port G0/0 of SW1 is interconnected to port G0/0 of
SW2. Therefore, port G0/0 of SW2 becomes the root port, as shown in the figure below.
To make port G0/1 of SW2 the root port, you must change the priority of the peer port of
G0/1 on SW2 to be less than 128. The figure below shows the result after adjustment.
Ruijie-SW1(config)#interface gigabitEthernet 0/1
4
STP Lab Guide