天天看點

STP小實驗 PVST MST RVST 配置談

STP是為了防止區域網路的實體環路,交換機的環路會帶來3個問題:廣播風暴,同一幀的多次拷貝,交換機的CAM表不穩定。stp基本思路是阻斷一些交換機的接口,建立一張無環路的轉發樹,交換機利用BPDU與其他交換機進行通訊,進而決定那些口阻塞那些口轉發。其中BPDU的格式如圖

<a target="_blank" href="http://blog.51cto.com/attachment/201011/224703520.png"></a>

比較重要的是cost of path bridge id 和端口id 這三個決定哪個交換機為根

我們做下實驗如圖:

<a target="_blank" href="http://blog.51cto.com/attachment/201011/225107411.png"></a>

我們看下交換機上的vlan資訊,這是我上次實驗留下的我們清除下,還原交換機初始設定

sw3#show vlan-switch 

VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa1/0, Fa1/1, Fa1/2, Fa1/3

                                                Fa1/4, Fa1/5, Fa1/6, Fa1/7

                                                Fa1/8, Fa1/9, Fa1/10, Fa1/11

                                                Fa1/12, Fa1/13, Fa1/14, Fa1/15

10   VLAN0010                         active    

20   msn                              active    

30   laliwangwang                     active    

40   360                              active    

1002 fddi-default                     act/unsup 

1003 trcrf-default                    act/unsup 

1004 fddinet-default                  act/unsup 

1005 trbrf-default                    act/unsup 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2

---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------

1    enet  100001     1500  -      -      -        -    -        1002   1003

10   enet  100010     1500  -      -      -        -    -        0      0   

20   enet  100020     9818  -      -      -        -    -        0      0   

30   enet  100030     9818  -      -      -        -    -        0      0   

40   enet  100040     9818  -      -      -        -    -        0      0   

1002 fddi  101002     1500  -      -      -        -    -        1      1003

1003 trcrf 101003     4472  1005   3276   -        -    srb      1      1002

1004 fdnet 101004     1500  -      -      1        ibm  -        0      0   

1005 trbrf 101005     4472  -      -      15       ibm  -        0      0   

VLAN AREHops STEHops Backup CRF

---- ------- ------- ----------

1003 7       7       off

清除過程:sw3#delete flash:vla 

sw3#delete flash:vlan.dat

Delete filename [vlan.dat]? vlan.dat

Delete flash:vlan.dat? [confirm]y

sw3#erase startup-config   擦除配置

Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]y[OK]

Erase of nvram: complete

sw3#reload  重新開機下交換機

System configuration has been modified. Save? [yes/no]: y

Building configuration...

[OK]

Proceed with reload? [confirm]  y

A summary of U.S. laws governing Cisco cryptographic products may be found at:

http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to

[email protected].

Cisco 3725 (R7000) processor (revision 0.1) with 124928K/6144K bytes of memory.

Processor board ID XXXXXXXXXXX

R7000 CPU at 240MHz, Implementation 39, Rev 2.1, 256KB L2, 512KB L3 Cache

18 FastEthernet interfaces

DRAM configuration is 64 bits wide with parity enabled.

55K bytes of NVRAM.

16384K bytes of ATA System CompactFlash (Read/Write)        這是cisco3725 的一些資訊

sw3#show vlan-switch  

1003 token-ring-default               act/unsup 

1005 trnet-default                    act/unsup 

1003 tr    101003     1500  1005   0      -        -    srb      1      1002

1005 trnet 101005     1500  -      -      1        ibm  -        0      0 

發現沒有了上次存在的vlan資訊。好我們開始做實驗

STP是交換機預設啟動的,而具體選擇哪個生成樹協定就在于你了。我們先什麼都不配看看預設下的生成樹。sw1 sw2是核心交換機,sw3為接入層交換機,由于我們在sw1和sw2之間啟的是trunk鍊路我們用2層圖示。

sw1#  show spanning-tree brief 

VLAN1

  Spanning tree enabled protocol ieee

  Root ID    Priority    32768    交換機的根 

             Address     c200.0130.0000

             Cost        19

             Port        42 (FastEthernet1/1)

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec    

  Bridge ID  Priority    32768    本地交換機狀态

             Address     c200.13dc.0000

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time 300

Interface                                   Designated

Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID

-------------------- ------- ---- ----- --- ----- -------------------- -------

FastEthernet1/1      128.42   128    19 FWD     0 32768 c200.0130.0000 128.42   trunk口是轉發的

FastEthernet1/5      128.46   128    19 BLK    19 32768 c200.0f3c.0000 128.46     f1/5是阻塞

sw2#show spanning-tree brief    根交換機   兩個口都是指定端口轉發流量

  Root ID    Priority    32768

             This bridge is the root

  Bridge ID  Priority    32768

FastEthernet1/1      128.42   128    19 FWD     0 32768 c200.0130.0000 128.42 

FastEthernet1/6      128.47   128    19 FWD     0 32768 c200.0130.0000 128.47 

sw3#show spanning-tree brief 

             Port        47 (FastEthernet1/6)

             Address     c200.0f3c.0000

FastEthernet1/5      128.46   128    19 FWD    19 32768 c200.0f3c.0000 128.46 

FastEthernet1/6      128.47   128    19 FWD     0 32768 c200.0130.0000 128.47

發現即使我們沒有設定stp也是運作的,它自動阻塞端口防止形成環路。cisco預設的stp是pvst (per vlan  stp )它是基于每個vlan建立一個生成樹,缺點:不能快速遷移。即使是在點對點鍊路或邊緣端口,也必須等待2倍的forward delay的時間延遲,網絡才能收斂。

我們還可以通過手工指定網橋優先級

sw1(config)#spanning-tree vlan 1 priority ?

  &lt;0-65535&gt;  bridge priority

sw1(config)#spanning-tree vlan 1 priority 0

或者

sw1(config)#spanning-tree vlan 1 root primary 

sw1(config)#spanning-tree vlan 1 root secondary 使用宏指令指定

我們在做2層交換網絡的配置還需完成下面的配置

sw1(config)#spanning-tree ?

  backbonefast  Enable BackboneFast Feature

  portfast      Spanning tree portfast options

  uplinkfast    Enable UplinkFast Feature

  vlan          VLAN Switch Spanning Tree

我們一般在全部交換機上啟用backbonefast  在sw3啟用uplinkfast    在接入層交換機如果連接配接時pc或者伺服器我們要指定portfast  

我們還可以針對接入層的安全啟用根防護和BPDU防護

2.下面我們做下快速stp的配置,我們知道在pvst的端口有5種狀态:blocking listening learning forwarding disabling,想要從blocking切換至forwarding狀态,必需要經過50秒的周期,這50秒我們隻能被動地去等待。20秒的blocking狀态下,如果沒有檢測到鄰居發來的BPDU包,則進入listening,這時要做的是選舉Root Bridge、Designate Port、Root Port,15秒後,進入learning,learning狀态下可以學習MAC位址,為最後的forwarding做準備,同樣是15秒,最後到達轉發狀态。而RSTP(802.1w)的出現解決了延時的問題,它的收斂速度很快,當然CISCO也針對這種技術推出了自已的RPVST+技術。RSTP在STP基礎上額外定義了兩種port role(注意這裡的概念,端口角色),分别是alternate與backup。另外重新規定了port state(端口狀态),分别為discarding、Learning、Forwarding.

<a target="_blank" href="http://blog.51cto.com/attachment/201011/000841420.png"></a>

我們配置下

sw1 :spanning-tree mode rapid-pvst

sw1(config)#int f1/5

sw1(config-if)#duplex full     

 sw1(config-if)#spanning-tree link- type point-to-point  (我們需要指定鍊路類型p2p) 

<a target="_blank" href="http://blog.51cto.com/attachment/201011/003055903.png"></a>

指定鍊路類型有利于快速stp的運作,上圖我标志了3種鍊路類型和應用情況

MST:MSTP可以将多個VLAN的生成樹映射為一個執行個體,即vlan map to a instance,我們不需要那麼多的生成樹,隻需要按照備援鍊路的條數來得出需要幾棵生成樹。

如果隻有兩條鍊路,并且有1-1000個VLAN,我們可以将1-500定義為instance 1,将501-1000定義到instance 2。隻生成兩棵樹1和2,同樣實作了備援與負載分擔。

MSTP是基于RSTP的,沒有RSTP,MSTP是無法運作的。

sw1(config)#SPanning-tree mode mst

sw1(config)#spanning-tree mst config

                          name   liang

                           version  1 

                            instance 1  vlan  1-2      (把vlan1 vlan2 映射到執行個體1)

                           instance  2 vlan    3-4

                           spanning-tree mst 1 pri   8192   (設定優先級,兩個交換機分為跟,輔 負載均衡)

                        spanning-tree mst  2   pri    12288 

 sw2就把優先級改下就行了,互為跟    輔                

一般我們在設定是用的做多的cisco預設的pvst+,一來這種配置簡單cisco的交換機都支援,mst和rpvst    結合具體情況大家使用                      

本文轉自q狼的誘惑 51CTO部落格,原文連結:http://blog.51cto.com/liangrui/423203,如需轉載請自行聯系原作者

繼續閱讀