實驗 快速生成樹配置

實驗 快速生成樹配置

【實驗名稱】

快速生成樹協議 RSTP 的配置。

【實驗目的】

理解快速生成樹協議 RSTP 的工作原理,掌握如何在交換機上配置快速生成樹。

【背景描述】

某學校爲了開展計算機教學和網絡辦公,建立了一個計算機教室和一個校辦公區,這兩

處的計算機網絡通過兩臺交換機互連組成內部校園網,爲了提高網絡的可靠性,網絡管理員

用 2 條鏈路將交換機互連,現要在交換機上做適當配置,使網絡避免環路。

【需求分析】

兩臺交換機以雙鏈路互聯,需要在啓用 RSTP 避免環路的同時,提供鏈路的冗餘備份功

能。

【實驗拓撲】

圖 4‐ 1 實驗拓撲圖

按照拓撲圖連接網絡時注意,兩臺交換機都配置完 RSTP 後,再將兩臺交換機連接起

來。如果先連線再配置可能會造成廣播風暴,影響交換機的正常工作。

【實驗設備】

三層交換機 1 臺

二層交換機 1 臺

【預備知識】

交換機的基本配置方法,Trunk 的工作原理和配置方法,SVI 端口的配置方法、生成樹

的工作原理以及 RSTP 的配置方法

【實驗原理】

生成樹協議(spanning-tree),作用是在交換網絡中提供冗餘備份鏈路,並且解決交換網

絡中的環路問題。

生成樹協議是利用 SPA 算法(生成樹算法),在存在交換環路的網絡中生成一個沒有環

路的樹形網絡。運用該算法將交換網絡冗餘的備份鏈路邏輯上斷開,當主要鏈路出現故障時,

能夠自動的切換到備份鏈路,保證數據的正常轉發。

生成樹協議目前常見的版本有 STP(生成樹協議 IEEE 802.1d)、RSTP(快速生成樹協

議 IEEE 802.1w)、MSTP(多生成樹協議 IEEE 802.1s)。

生成樹協議的特點是收斂時間長。當主要鏈路出現故障以後,到切換到備份鏈路需要

50 秒的時間。

快速生成樹協議(RSTP)在生成樹協議的基礎上增加了兩種端口角色:替換端口

(alternate Port)和備份端口(backup Port),分別做爲根端口(root Port)和指定端口(designated

Port)的冗餘端口。當根端口或指定端口出現故障時,冗餘端口不需要經過 50 秒的收斂時

間,可以直接切換到替換端口或備份端口。從而實現 RSTP 協議小於 1 秒的快速收斂。

【實驗步驟】

第一步:配置兩臺交換機的主機名、管理 IP  地址和 Trunk

Switch#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname L2-SW

L2-SW(config)#interface vlan 1

L2-SW(config-if)#ip address 192.168.1.2 255.255.255.0

L2-SW(config-if)#no shutdown

L2-SW(config-if)#exit

L2-SW(config)#

L2-SW(config)#interface fastEthernet 0/1

L2-SW(config-if)#switchport mode trunk

L2-SW(config-if)#exit

L2-SW(config)#

L2-SW(config)#interface fastEthernet 0/2

L2-SW(config-if)#switchport mode trunk

L2-SW(config-if)#exit

L2-SW(config)#

S3750#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

S3750(config)#hostname L3-SW

L3-SW(config)#interface vlan 1

L3-SW(config-if)#Dec 2 23:15:26 L3-SW %7:%LINE PROTOCOL CHANGE:

Interface VLAN 1, changed state to UP

L3-SW(config-if)#ip address 192.168.1.1 255.255.255.0

L3-SW(config-if)#no shutdown

L3-SW(config-if)#exit

L3-SW(config)#

L3-SW(config)#interface fastEthernet 0/1

L3-SW(config-if)#switchport mode trunk

L3-SW(config-if)#exit

L3-SW(config)#

L3-SW(config)#interface fastEthernet 0/2

L3-SW(config-if)#switchport mode trunk

L3-SW(config-if)#exit

第二步:在兩臺交換機上啓用 RSTP

L2-SW(config)#spanning-tree

!啓用生成樹協議

L2-SW(config)#spanning-tree mode rstp

!修改生成樹協議的類型爲 RSTP

L2-SW(config)#

L3-SW(config)#spanning-tree

Enable spanning-tree.

!啓用生成樹協議

L3-SW(config)#spanning-tree mode rstp

!修改生成樹協議的類型爲 RSTP

L3-SW(config)#

在使用默認參數啓用了 RSTP 之後,可以使用 show spanning-tree 命令觀察現在兩臺

交換機上生成樹的工作狀態:

L3-SW#show spanning-tree

StpVersion : RSTP

SysStpStatus : ENABLED

MaxAge : 20

HelloTime : 2

ForwardDelay : 15

BridgeMaxAge : 20

BridgeHelloTime : 2

BridgeForwardDelay : 15

MaxHops: 20

TxHoldCount : 3

PathCostMethod : Long

BPDUGuard : Disabled

BPDUFilter : Disabled

BridgeAddr : 00d0.f821.a542

Priority: 32768

TimeSinceTopologyChange : 0d:0h:0m:9s

TopologyChanges : 2

DesignatedRoot : 8000.00d0.f821.a542

RootCost : 0

RootPort : 0

L2-SW#show spanning-tree

StpVersion : RSTP

SysStpStatus : Enabled

BaseNumPorts : 24

MaxAge : 20

HelloTime : 2

ForwardDelay : 15

BridgeMaxAge : 20

BridgeHelloTime : 2

BridgeForwardDelay : 15

MaxHops : 20

TxHoldCount : 3

PathCostMethod : Long

BPDUGuard : Disabled

BPDUFilter : Disabled

BridgeAddr : 00d0.f88b.ca34

Priority : 32768

TimeSinceTopologyChange : 0d:0h:3m:54s

TopologyChanges : 0

DesignatedRoot : 800000D0F821A542

RootCost : 200000

RootPort : Fa0/1

可以看到兩臺交換機已經正常啓用了 RSTP 協議,由於 MAC 地址較小,L3-SW 被選

舉爲根網橋,優先級是 32768;L2-SW 上的根端口是 Fa0/1;兩臺交換機上計算路徑成本

的方法都是長整型。

爲了在網絡中新加入其他的交換機後,L3-SW 還是保證能夠選舉爲根網橋,需要提高

L3-SW 的網橋優先級。

第三步:指定三層交換機爲根網橋,二層交換機的 F0/2 端口爲根端口,指定兩臺交換機的

端口路徑成本計算方法爲短整型

端口爲根端口,指定兩臺交換機的

端口路徑成本計算方法爲短整型

L3-SW(config)#spanning-tree priority ?

<0-61440> Bridge priority in increments of 4096

!查看網橋優先級的可配置範圍,在 0~61440 之內,且必須是 4096 的倍數

L3-SW(config)#spanning-tree priority 4096

!配置網橋優先級爲 4096

L3-SW(config)#

L3-SW(config)#interface fastEthernet 0/2

L3-SW(config-if)#spanning-tree port-priority ?

<0-240> Port priority in increments of 16

!查看端口優先級的可配置範圍,在 0~240 之內,且必須是 16 的倍數

L3-SW(config-if)#spanning-tree port-priority 96

!修改 F0/2 端口的優先級爲 96

L3-SW(config-if)#exit

L3-SW(config)#spanning-tree pathcost method short

!修改計算路徑成本的方法爲短整型

L3-SW(config)#exit

L2-SW(config)#spanning-tree pathcost method short

!修改計算路徑成本的方法爲短整型

L2-SW(config)#exit

第四步:查看生成樹的配置

L3-SW#show spanning-tree

StpVersion : RSTP

SysStpStatus : ENABLED

MaxAge : 20

HelloTime : 2

ForwardDelay : 15

BridgeMaxAge : 20

BridgeHelloTime : 2

BridgeForwardDelay : 15

MaxHops: 20

TxHoldCount : 3

PathCostMethod : Short

BPDUGuard : Disabled

BPDUFilter : Disabled

BridgeAddr : 00d0.f821.a542

Priority: 4096

TimeSinceTopologyChange : 0d:0h:0m:34s

TopologyChanges : 7

DesignatedRoot : 1000.00d0.f821.a542

RootCost : 0

RootPort : 0

L3-SW#

L3-SW#show spanning-tree interface fastEthernet 0/1

PortAdminPortFast : Disabled

PortOperPortFast : Disabled

PortAdminLinkType : auto

PortOperLinkType : point-to-point

PortBPDUGuard : disable

PortBPDUFilter : disable

PortState : forwarding

PortPriority : 128

PortDesignatedRoot : 1000.00d0.f821.a542

PortDesignatedCost : 0

PortDesignatedBridge :1000.00d0.f821.a542

PortDesignatedPort : 8001

PortForwardTransitions : 2

PortAdminPathCost : 19

PortOperPathCost : 19

PortRole : designatedPort

L3-SW#

L3-SW#show spanning-tree interface fastEthernet 0/2

PortAdminPortFast : Disabled

PortOperPortFast : Disabled

PortAdminLinkType : auto

PortOperLinkType : point-to-point

PortBPDUGuard : disable

PortBPDUFilter : disable

PortState : forwarding

PortPriority : 96

PortDesignatedRoot : 1000.00d0.f821.a542

PortDesignatedCost : 0

PortDesignatedBridge :1000.00d0.f821.a542

PortDesignatedPort : 6002

PortForwardTransitions : 4

PortAdminPathCost : 19

PortOperPathCost : 19

PortRole : designatedPort

L3-SW#

可以觀察到 L3-SW 中,網橋優先級已經被修改爲 4096,Fa0/2 端口的優先級也被修改

成 96,在短整型的計算路徑成本的方法中,兩個端口的路徑成本都是 19,現在都處於轉發

狀態。

L2-SW#show spanning-tree

StpVersion : RSTP

SysStpStatus : Enabled

BaseNumPorts : 24

MaxAge : 20

HelloTime : 2

ForwardDelay : 15

BridgeMaxAge : 20

BridgeHelloTime : 2

BridgeForwardDelay : 15

MaxHops : 20

TxHoldCount : 3

PathCostMethod : Short

BPDUGuard : Disabled

BPDUFilter : Disabled

BridgeAddr : 00d0.f88b.ca34

Priority : 32768

TimeSinceTopologyChange : 0d:0h:1m:38s

TopologyChanges : 0

DesignatedRoot : 100000D0F821A542

RootCost : 19

RootPort : Fa0/2

L2-SW#

L2-SW#show spanning-tree interface fastEthernet 0/1

PortAdminPortfast : Disabled

PortOperPortfast : Disabled

PortAdminLinkType : auto

PortOperLinkType : point-to-point

PortBPDUGuard: Disabled

PortBPDUFilter: Disabled

PortState : discarding

PortPriority : 128

PortDesignatedRoot : 100000D0F821A542

PortDesignatedCost : 0

PortDesignatedBridge : 100000D0F821A542

PortDesignatedPort : 8001

PortForwardTransitions : 5

PortAdminPathCost : 0

PortOperPathCost : 19

PortRole : alternatePort

L2-SW#

L2-SW#show spanning-tree interface fastEthernet 0/2

PortAdminPortfast : Disabled

PortOperPortfast : Disabled

PortAdminLinkType : auto

PortOperLinkType : point-to-point

PortBPDUGuard: Disabled

PortBPDUFilter: Disabled

PortState : forwarding

PortPriority : 128

PortDesignatedRoot : 100000D0F821A542

PortDesignatedCost : 0

PortDesignatedBridge : 100000D0F821A542

PortDesignatedPort : 6002

PortForwardTransitions : 3

PortAdminPathCost : 0

PortOperPathCost : 19

PortRole : rootPort

L2-SW#

在 L2-SW 中,網橋優先級還是默認的 32768,端口優先級也是默認的 128,路徑成本

是 19,端口 Fa0/2 被選舉爲根端口,處於轉發狀態,而 Fa0/1 則是替換端口,處於丟棄狀

態。

第五步:驗證配置

在三層交換機 L3-SW 上長時間的 ping 二層交換機 L2-SW,其間斷開 L2-SW 上的轉發

端口 Fa0/2,這時觀察替換端口能夠在多長時間內成爲轉發端口:

L3-SW#ping 192.168.1.2 ntimes 1000

!使用 ping 命令的 ntimes 參數指定 ping 的次數

Sending 1000, 100-byte ICMP Echoes to 192.168.1.2, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!Dec 2 23:30:56 L3-SW %7:2008-12-2 23:30:56 topochange:topology

is changed.%LINK CHANGED: Interface FastEthernet 0/2, changed state to down

Dec 2 23:30:57 L3-SW %7:%LINE PROTOCOL CHANGE: Interface FastEthernet

0/2, changed state to DOWN

Dec 2 23:30:57 L3-SW %7:2008-12-2 23:30:57 topochange:topology is

changed.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Success rate is 99 percent (998/1000), round-trip min/avg/max = 1/1/10 ms

L3-SW#

從中可以看到替換端口變成轉發端口的過程中,丟失了 2 個 ping 包,中斷時間小於

20ms。

【注意事項】

1、銳捷交換機缺省是關閉 spanning-tree 的,如果網絡在物理上存在環路,則必須手工開

啓 spanning-tree。

2、銳捷全系列的交換機默認爲 MSTP 協議,在配置時注意生成樹協議的版本。

【參考配置】

L3-SW#show running-config

Building configuration...

Current configuration : 1386 bytes

!

version RGNOS 10.1.00(4), Release(18443)(Tue Jul 17 19:51:54 CST 2007 -ubu6server)

hostname L3-SW

!

vlan 1

!

spanning-tree

spanning-tree pathcost method short

spanning-tree mode rstp

spanning-tree mst 0 priority 4096

interface FastEthernet 0/1

switchport mode trunk

!

interface FastEthernet 0/2

switchport mode trunk

spanning-tree mst 0 port-priority 96

!

interface FastEthernet 0/3

!

interface FastEthernet 0/4

!

interface FastEthernet 0/5

!

interface FastEthernet 0/6

!

interface FastEthernet 0/7

!

interface FastEthernet 0/8

!

interface FastEthernet 0/9

!

interface FastEthernet 0/10

!

interface FastEthernet 0/11

!

interface FastEthernet 0/12

!

interface FastEthernet 0/13

!

interface FastEthernet 0/14

!

interface FastEthernet 0/15

!

interface FastEthernet 0/16

!

interface FastEthernet 0/17

!

interface FastEthernet 0/18

!

interface FastEthernet 0/19

!

interface FastEthernet 0/20

!

interface FastEthernet 0/21

!

interface FastEthernet 0/22

!

interface FastEthernet 0/23

!

interface FastEthernet 0/24

!

interface GigabitEthernet 0/25

!

interface GigabitEthernet 0/26

!

interface GigabitEthernet 0/27

!

interface GigabitEthernet 0/28

!

interface VLAN 1

ip address 192.168.1.1 255.255.255.0

!

!

line con 0

line vty 0 4

login

!

end

L2-SW#show running-config

System software version : 1.68 Build Apr 25 2007 Release

Building configuration...

Current configuration : 319 bytes

!

version 1.0

!

hostname L2-SW

vlan 1

!

spanning-tree mode rstp

spanning-tree

spanning-tree pathcost method short

interface fastEthernet 0/1

switchport mode trunk

!

interface fastEthernet 0/2

switchport mode trunk

!

interface vlan 1

no shutdown

ip address 192.168.1.2 255.255.255.0

!

end

wKioL1hQ6NzAEXaOAABKr_AJLOw284.png-wh_50

wKioL1hQ6NyhtqxSAACTgurRaxE926.png-wh_50

wKiom1hQ6NzTVUjtAAAR4Qu5Jqc019.png-wh_50


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章