Stp Topology and Implement RSTP
The potential effect of a loop in the Layer 2 network is significant. Layer 2 loops could impact connected hosts as well as the network equipment. Layer 2 loops can be prevented by following good design practices and careful implementation of the Spanning Tree Protocol.
Switch#conf t
Switch(config)#hostname D1
D1(config)#spanning-tree mode pvst
D1(config)#banner motd ^ STP Topology Change and RSTP lab ^
D1(config)#line con 0
D1(config-line)#exec-timeout 0 0
D1(config-line)#logging synchronous
D1(config-line)#exit
D1(config)#int range g1/0/1-3
D1(config-if-range)#switchport mode access
D1(config-if-range)#switchport trunk
D1(config-if-range)#exit
D1(config)#vlan 2
D1(config-vlan)#name SecondVLAN
D1(config-vlan)#exit
D1(config)#
D1(config)#int vlan 1
D1(config-if)#ip add 10.0.0.1 255.0.0.0
D1(config-if)#no shut
D1(config-if)#
%LINK-5-CHANGED: Interface Vlan1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
D1(config-if)#exit
D1#sh interfaces trunk
Port Mode Encapsulation Status Native vlan
Gig1/0/1 on 802.1q trunking 1
Gig1/0/2 on 802.1q trunking 1
Gig1/0/3 on 802.1q trunking 1
Port Vlans allowed on trunk
Gig1/0/1 1-1005
Gig1/0/2 1-1005
Gig1/0/3 1-1005
Port Vlans allowed and active in management domain
Gig1/0/1 1,2
Gig1/0/2 1,2
Gig1/0/3 1,2
Port Vlans in spanning tree forwarding state and not pruned
Gig1/0/1 1,2
Gig1/0/2 1,2
Gig1/0/3 1,2
D1#
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname D2
D2(config)#banner motd ^ D2 Stp topology change and rstp lab ^
D2(config)#spanning-tree mode pvst
D2(config)#line con 0
D2(config-line)#exec-timeout 0 0
D2(config-line)#logging synchronous
D2(config-line)#exit
D2(config)#int range gig1/0/1-3
D2(config-if-range)#switchport mode access
D2(config-if-range)#switchport mode trunk
D2(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/3, changed state to up
D2(config-if-range)#no shut
D2(config-if-range)#exit
D2(config)#vlan 2
D2(config-vlan)#name SecondVLAN
D2(config-vlan)#exit
D2(config)#interface vlan 1
D2(config-if)#ip add 10.0.0.2 255.0.0.0
D2(config-if)#no shut
D2(config-if)#
%LINK-5-CHANGED: Interface Vlan1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
D2(config-if)#exit
A1#sh version | include MAC
Base ethernet MAC Address : 00:17:59:A7:51:80
A1#
D1#sh version | include MAC
Base ethernet MAC Address : 00:0B:BE:41:E6:C6
D1#
D2#sh version | include MAC
Base ethernet MAC Address : 00:E0:A3:09:23:60
D2#
D1#sh spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 000B.BE41.E6C6
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000B.BE41.E6C6
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi1/0/1 Desg FWD 4 128.1 P2p
Gi1/0/2 Desg FWD 19 128.2 P2p
Gi1/0/3 Desg FWD 19 128.3 P2p
VLAN0002
Spanning tree enabled protocol ieee
Root ID Priority 32770
Address 000B.BE41.E6C6
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32770 (priority 32768 sys-id-ext 2)
Address 000B.BE41.E6C6
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi1/0/1 Desg FWD 4 128.1 P2p
Gi1/0/2 Desg FWD 19 128.2 P2p
Gi1/0/3 Desg FWD 19 128.3 P2p
D1#
A1#sh spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 000B.BE41.E6C6
Cost 19
Port 1(FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000B.BE79.CD69
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/4 Altn BLK 19 128.4 P2p
Fa0/2 Altn BLK 19 128.2 P2p
Fa0/3 Altn BLK 19 128.3 P2p
Fa0/1 Root FWD 19 128.1 P2p
VLAN0002
Spanning tree enabled protocol ieee
Root ID Priority 32770
Address 000B.BE41.E6C6
Cost 19
Port 1(FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32770 (priority 32768 sys-id-ext 2)
Address 000B.BE79.CD69
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/4 Altn BLK 19 128.4 P2p
Fa0/2 Altn BLK 19 128.2 P2p
Fa0/3 Altn BLK 19 128.3 P2p
Fa0/1 Root FWD 19 128.1 P2p
A1#
sh spanning-tree root komutu örnek kullanımı
A1# show spanning-tree root
Root Hello Max Fwd
Vlan Root ID Cost Time Age Dly Root Port
---------------- -------------------- --------- ----- --- --- ------------
VLAN0001 32769 d8b1.9028.af80 19 2 20 15 Fa0/1
VLAN0002 32770 d8b1.9028.af80 19 2 20 15 Fa0/1
The first thing to look at is the priority value. It is 32768 by default.
Because we are working with PVST+,
a differentiator is added – the priority value is modified with the extended system ID, which is equal to the
VLAN number. You can see in the output here that our three devices are using default priorities – 32769
for VLAN 1 (32768 + 1) and 32770 for VLAN 2 (32768 + 2).
For each VLAN, the priority values are the
same for each of the three switches.
When this happens, the rest of the BID is taken into account. The
rest of the BID includes the base MAC address.
The lowest base MAC address is used to break the tie
Last updated