CCIE試驗備考之交換STP(2)

第二部分 STP特性
Portfast快速端口
  Portfast快速端口是一個Catalyst的一個特性,能使交換機或中繼端口跳過偵聽學習狀態而進入STP轉發狀態,在基於IOS交換機上,PortFast 只能用於連接到終端工作站的接入端口上。
   當一個設備連接到一個端口上時,端口通常進入偵聽狀態。當轉發延遲定時器超時後,進入學習狀態,當轉發延遲定時器第二次超時,端口進入到轉發或者阻塞狀態,當一個交換機或中繼端口啓用PortFast後,端口立即進入轉發狀態,但交換機檢測到鏈路,端口就進入轉發狀態(插電纜後的2s) 。如果端口檢測到一個環路同時又啓用了PortFast 功能。它就進入阻塞狀態。重要的是要注意到PortFast 值在端口初始化的時候才生效。如果端口由於某種原因又被迫進入阻塞狀態,隨後又需要回到轉發狀態,仍然要經過正常的偵聽 。
 
啓用PortFast的主要原因是防止啓動週期小於30s的PC需要和交換機端口從未連接狀態進入到轉發狀態,一些網卡直到 MAC 層軟件驅動被實際加載之後纔會啓動鏈路。這種情況下就會導致一些故障,例如DHCP環境下,這可能會出現一些問題。
配置過程:
1) 進入全局配置模式  configure terminal
2) 選擇端口  interface 端口
3) 設置該端口啓用portfast功能
   spanning-tree portfast [trunk]
   如果你要在trunk端口上啓用portfast,必須添加trunk關鍵字。
4) 驗證配置
          show spanning-tree interface 端口 portfast
          -----------------------------------------------
          VLAN0001         enabled
         
          Show spanning-tree summary
          ------------------------------------
          Switch is in pvst mode
          Root bridge for: none
          EtherChannel misconfig guard is enabled
          Extended system ID           is enabled
          Portfast Default             is enabled
          PortFast BPDU Guard Default  is disabled
          Portfast BPDU Filter Default is disabled
          Loopguard Default            is disabled
          UplinkFast                   is disabled
          BackboneFast                 is disabled
          Pathcost method used         is short
案例:
    conf t
    spanning portfast default  (所有的接入端口)
    interface f0/24
    spanning portfast trunk
    end
    show spanning summary
    show runn inter f0/24
    Building configuration...
    Current configuration : 87 bytes
    !
    interface FastEthernet0/24
      switchport mode trunk
      spanning-tree portfast trunk
    end
案例:
CCIE-LAB(V142)
題目要求:
在sw1的F0/18口連接一臺PC,使其不需要經過spanning-tree的學習過程,直接forwarding,不會自動協商成trunk。
配置:
SW1
       Interface f0/18
          Spanning-tree portfast
UplinkFast
在 STP 收斂過程中,一些終端站點可能會不可達,這是基於站點所連接交換機端口的 STP 狀態而定。這打亂網絡連接,於是關鍵是減少STP的收斂時間和網絡受影響的時間。快速級聯鏈路(UplinkFast)就是用來加快STP收斂的。UplinkFast是一項交換機的功能,用於在鏈路或者交換機失效時加速新的根端口的選擇。
 
當鏈路或交換機故障,或 STP 重新配置後,UplinkFast可以加速選擇一個新的根端口。根端口立即進入轉發狀態,Uplinkfast 通過減少最大更新速率來限制突發多博流量。定義了更新分組發送的最大速率,默認爲150分組/分鐘
Uplinkfast 對於網絡邊緣的佈線間交換機非常有用。他不適用於骨幹設備。UplinkFast 在直連鏈路故障後提供快速的收斂能力,並通過上行鏈路組在冗餘。
如上圖所示,A 和根交換機相連的端口爲轉發狀態,另一個爲阻塞狀態。當到根交換機的上行鏈路斷開後,如果配置了Uplinkfast到另一臺上層交換機的鏈路將直接轉入轉發狀態,而不需要經過減聽和學習狀態,如圖,這個轉換需要經過大約1-5秒。
一旦交換機將以個備用端口轉爲轉發狀態,交換機開始在該端口發送僞多播幀,本地橋接標中每個表項都對應一個僞多播幀,每個本地網橋表中的表項(除了與發生故障的根端口相關聯的表項)都對應一個僞組播幀。缺省時,每100毫秒大約發送15個僞組播幀。它使用工作站地址做爲源地址,目的地址01-00-0C-CD-CD-CD作爲目的地址。 如果原來的交換機恢復連接,交換機在等待2倍轉發延遲時間再加上5s後纔將該端口轉入轉發狀態。這是的鄰接端口有時間經過偵聽和學習狀態才轉入轉發狀態。
注意,
1) 啓用了uplinkfast後,它會影響此交換機的所有的VLAN。不能在單個VLAN上配置UplinkFast。
2) 在已經配置了網橋優先級的VLAN上不能啓動Uplinkfast。要在配置了網橋優先級的VLAN上啓動uplinkfast,必須首先將vlan上的交換機優先級恢復到默認值(使用命令no spanning-tree vlan vlan號 priority)
3) 啓動了UplinkFast時,所有VLAN的網橋優先級都被設爲49152,並且如果不改變缺省的路徑開銷,所有接口和VLAN trunk的路徑開銷都會增加3000
配置過程:
1) 進入全局配置模式 configure terminal
2) 啓用UplinkFast
     spanning-tree uplinkfast [max-update-rate 每秒傳輸包]
     取值爲每秒0到32000個數據包,缺省值爲150。通常這個值就足夠了。
3) 驗證配置
     show spanning-tree uplinkfast
     show spanning-tree summary
案例:
    #show spanning summary
    ----------------------------
    Switch is in pvst mode
    Root bridge for: none
    EtherChannel misconfig guard is enabled
    Extended system ID           is enabled
    Portfast Default             is enabled
    PortFast BPDU Guard Default  is enabled
    Portfast BPDU Filter Default is disabled
    Loopguard Default            is disabled
    UplinkFast                   is disabled
    BackboneFast                 is enabled
    Pathcost method used         is short
Name                   Blocking Listening Learning Forwarding STP Active
---------------------- -------- --------- -------- ---------- ----------
VLAN0001                     1         0        0          2          3
VLAN0010                     1         0        0          1          2
VLAN0020                     1         0        0          1          2
VLAN0100                     1         0        0          1          2
VLAN0200                     1         0        0          1          2
VLAN0201                     1         0        0          1          2
---------------------- -------- --------- -------- ---------- ----------
6 vlans                      6         0        0          7         13
   
    #conf t
    (config)#spanning uplinkfast
    #show span  uplinkfast
    UplinkFast is enabled
    Station update rate set to 150 packets/sec.
    UplinkFast statistics
    -----------------------
    Number of transitions via uplinkFast (all VLANs)            : 0
    Number of proxy multicast addresses transmitted (all VLANs) : 0
    Name                 Interface List
    -------------------- ------------------------------------
    VLAN0001             Fa0/23(fwd), Fa0/24
    VLAN0010             Fa0/23(fwd), Fa0/24
    VLAN0020             Fa0/23(fwd), Fa0/24
    VLAN0100             Fa0/23(fwd), Fa0/24
    VLAN0200             Fa0/23(fwd), Fa0/24
    VLAN0201             Fa0/23(fwd), Fa0/24
    #Show span summary
    Switch is in pvst mode
    Root bridge for: none
    EtherChannel misconfig guard is enabled
    Extended system ID           is enabled
    Portfast Default             is enabled
    PortFast BPDU Guard Default  is disabled
    Portfast BPDU Filter Default is disabled
    Loopguard Default            is disabled
    UplinkFast                   is enabled
    BackboneFast                 is disabled
    Pathcost method used         is short
    #debug spanning uplinkfast
    #conf t
    (config)#int f0/23
    (config-if)#switchport mode access
00:26:40: STP FAST: UPLINKFAST: make_forwarding on VLAN0001 FastEthernet0/24 root port id new: 128.24 prev: 128.23
00:26:40: %SPANTREE_FAST-7-PORT_FWD_UPLINK: VLAN0001 FastEthernet0/24 moved to Forwarding (UplinkFast).
00:26:40: STP FAST: make_forwarding: via UPLINKFAST: NOT: port FastEthernet0/18
VLAN0001 is: uplink enabled new root FastEthernet0/24 (not me)prev root exists(8017/FastEthernet0/23) cur state forwarding role uplink
00:26:40: STP: UFAST: removing prev root port Fa0/23 VLAN0001 port-id 8017
00:26:40: STP FAST: UPLINKFAST: make_forwarding on VLAN0010 FastEthernet0/24 root port id new: 128.24 prev: 128.23
00:26:40: STP: UFAST: removing prev root port Fa0/23 VLAN0010 port-id 8017
00:26:40: STP FAST: UPLINKFAST: make_forwarding on VLAN0020 FastEthernet0/24 root port id new: 128.24 prev: 128.23
00:26:40: STP: UFAST: removing prev root port Fa0/23 VLAN0020 port-id 8017
00:26:40: STP FAST: UPLINKFAST: make_forwarding on VLAN0100 FastEthernet0/24 root port id new: 128.24 prev: 128.23
00:26:40: STP: UFAST: removing prev root port Fa0/23 VLAN0100 port-id 8017
00:26:40: STP FAST: UPLINKFAST: make_forwarding on VLAN0200 FastEthernet0/24 root port id new: 128.24 prev: 128.23
00:26:40: STP: UFAST: removing prev root port Fa0/23 VLAN0200 port-id 8017
00:26:40: STP FAST: UPLINKFAST: make_forwarding on VLAN0201 FastEthernet0/24 root port id new: 128.24 prev: 128.23
00:26:40: STP: UFAST: removing prev root port Fa0/23 VLAN0201 port-id 8017
00:26:40: STP FAST: make_forwarding: via UPLINKFAST: NOT: port FastEthernet0/24
VLAN0001 is: uplink enabled new root FastEthernet0/24 (me)prev root exists(8017/<none>) cur state forwarding role uplink
00:26:40: STP FAST: make_forwarding: via UPLINKFAST: NOT: port FastEthernet0/18
VLAN0001 is: uplink enabled new root FastEthernet0/24 (not me)prev root exists(8017/<none>) cur state forwarding role uplink
00:26:40: STP FAST: make_forwarding: via UPLINKFAST: NOT: port FastEthernet0/23
VLAN0001 is: uplink enabled new root FastEthernet0/24 (not me)prev root exists(8017/<none>) cur state blocking role looped
00:26:40: %SPANTREE-7-RECV_1Q_NON_TRUNK: Received 802.1Q BPDU on non trunk FastEthernet0/23 VLAN1.
00:26:40: %SPANTREE-7-BLOCK_PORT_TYPE: Blocking FastEthernet0/23 on VLAN0001. Inconsistent port type.
00:26:55: %SPANTREE-2-UNBLOCK_CONSIST_PORT: Unblocking FastEthernet0/23 on VLAN0001. Port consistency restored.
00:26:55: STP FAST: make_forwarding: via UPLINKFAST: NOT: port FastEthernet0/23
VLAN0001 is: uplink enabled new root FastEthernet0/24 (not me)prev root exists(8017/<none>) cur state blocking role looped
00:26:56: STP FAST: make_forwarding: via UPLINKFAST: NOT: port FastEthernet0/24
VLAN0001 is: uplink enabled new root FastEthernet0/24 (me)prev root exists(8017/<none>) cur state forwarding role uplink
00:26:56: STP FAST: make_forwarding: via UPLINKFAST: NOT: port FastEthernet0/18
VLAN0001 is: uplink enabled new root FastEthernet0/24 (not me)prev root exists(8017/<none>) cur state forwarding role uplink
00:27:31: STP FAST: UPLINKFAST: make_forwarding on VLAN0001 FastEthernet0/23 root port id new: 128.23 prev: 128.24
00:27:31: %SPANTREE_FAST-7-PORT_FWD_UPLINK: VLAN0001 FastEthernet0/23 moved to Forwarding (UplinkFast).
     
#show spanning uplinkfast
UplinkFast is enabled
Station update rate set to 150 packets/sec.
UplinkFast statistics
-----------------------
Number of transitions via uplinkFast (all VLANs)            : 7
Number of proxy multicast addresses transmitted (all VLANs) : 32
Name                 Interface List
-------------------- ------------------------------------
VLAN0001             Fa0/23(fwd), Fa0/24
VLAN0010             Fa0/24(fwd)
VLAN0020             Fa0/24(fwd)
VLAN0100             Fa0/24(fwd)
VLAN0200             Fa0/24(fwd)
VLAN0201             Fa0/24(fwd)

BackboneFast
BackboneFast快速骨幹是Catalyst交換機在跟端口或阻塞端口從指定網橋收到一個劣質(inferor)的BPDU時會起動的一種特性。次級BPDU用來標識一個既是根橋又是指定網橋的交換機。當一個交換機收到一個劣質 BPDU,就以爲這該交換機的一個非直接鏈路出現故障。也就是說,一個指定網橋已經丟失到根交換機的連接。按照 STP 規則,因爲所有配置的最大生存時間(20秒), 交換機會忽略所有的劣質的BPDU。Backbonefast的作用就是欺騙這20秒的延遲。當交換機接收到了次級BPDU時,交換機會判斷是否有到達根橋的其他路徑。
有兩種情況需要考慮:
1) 如果劣質BPDU 到達一個阻塞端口,則交換機上的根端口和其他阻塞端口成爲到根交換機的備選路徑
2) 如果劣質BPDU 到達根端口,所有的阻塞端口都會成爲到根交換機的潛在備用。
 
 
   如果劣質BPDU 到達根端口,且沒有阻塞端口,交換機將自己定義爲根交換機。如果交換機存在備
用路徑,它適用備用路徑傳送一種新的協議,通常情況下該模式會節約 20s的時間。
如上圖:當L1 Down時,SWB 會發送一個劣等BPDU,告訴 SWC,我SWB 是Root,SWC 經過和SWA溝通(使用Root Link Query BPDU查詢),SWA 告訴SWC,我SWA還活着呢。然後SWC告訴 SWB,SWA還活着,它還是Root。
BackboneFast應用在所有的VLAN中,不支持令牌環VLAN
配置過程:
1) 進入全局配置模式 configure terminal
2) 啓用BackboneFast
    spanning-tree backbonefast
3) 驗證配置
    show spanning-tree backbonefast
----------------------------------------------------
BackboneFast is enabled
BackboneFast statistics
-----------------------
Number of transition via backboneFast (all VLANs)           : 0
Number of inferior BPDUs received (all VLANs)               : 0
Number of RLQ request PDUs received (all VLANs)             : 0
Number of RLQ response PDUs received (all VLANs)            : 0
Number of RLQ request PDUs sent (all VLANs)                 : 0
Number of RLQ response PDUs sent (all VLANs)                : 0
show spanning-tree summary
BPDU保護
BPDU保護僅用在PortFast模式。它被網絡設計者用來加強STP域邊界。從而保持與其的活動拓撲。在啓用STP PortFast端口之後的設備被禁止影響STP拓撲。對於配置了portfast特性的接口,它不應當接收到BPDU,如果配置了PortFast特性的接口接收了BPDU,那就表示了無效的配置,可能就會產生橋接環路,通過配置BPDU保護後,配置了PortFast的端口如果收到BPDU將會把端口狀態調整到Err-Disable.如下是一個信息:
2000 May 12 15:13:32 %SPANTREE-2-RX_PORTFAST:Received BPDU on PortFast enable port. Disabling 2/1
2000 May 12 15:13:32 %PAGP-5-PORTFROMSTP:Port 2/1 left bridge port 2/1
如下圖所示,A的優先級爲8192,爲該vlan的根橋,B的優先級爲16384,爲備份根橋,B和A之間的鏈路爲Gbit/s鏈路,C是一個接入交換機,並在連接到設備D得端口上設置了PortFast.其他的STP參數都是默認值,網橋C上連接到網橋B得端口處於STP阻塞狀態。設備D(PC)不參與STP。正確的BPDU流向,如下左圖

   如果D爲一臺基於Linux的軟件網橋,可以發送BPDU報文,並將自身BID的優先級設置爲0,此時,D將成爲根橋,故BPDU流向變爲右圖, A,B間的Gbit/s鏈路被阻塞,通過C走100Mbit/s鏈路。此時會超負載出現丟包的情況, BPDU保護的目的就是基於這種情況,防止接入設備對整個網絡拓撲的影響。
   配置過程:
     方法一:全局配置模式
1) 全局配置模式 configure terminal
2) 配置BPDU保護
     (config)#spanning-tree portfast bdpuguard default
3) 進入接口模式  interface 接口
4) 接口使能portfast,BPDU保護才能啓用
     (config-if)#spanning-tree portfast
方法二:接口模式
1) 接口模式下  interface 接口
2) 使能BPDU保護
    (config-if)#spanning-tree bpduguard enable
   驗證過程:
    show running-configure
BPDU過濾(BPDU Filtering)
通過使用BPDU過濾功能,將能夠防止交換機在啓用了PortFast特性的接口上發送BPDU。對於配置了PortFast特性的端口,它通常連接到主機設備,因爲主機不需要參與STP,所有它將丟棄所接收到的BPDU。通過使用BPDU過濾功能,將能夠防止向主機設備發送不必要的BPDU。
   交換機支持以每個端口或者整個交換機配置BPDU過濾。
   如果全局配置了BPDU過濾功能,但當某個端口接收到了任何的BPDU,那麼交換機將把接口更改回正常的STP操作,也就是它將禁用PortFast和BPDU過濾特性。
   如果在接口上明確配置了BPDU過濾功能,那麼交換機將不發送任何的BPDU,並且將把接收到的所有BPDU都丟棄。
   注意,如果在鏈接到其他交換機的端口上配置了BPDU過濾,那麼就有可能導致橋接環路,所以在部署BPDU過濾時要格外小心,一般我們不推薦使用BPDU過濾。
   如果在與啓用了BPDU過濾的相同接口上配置了BPDU保護,因爲BPDU過濾的優先級高於BPDU保護,所以BPDU保護將不起作用。
配置過程:
     方法一:全局配置模式
1) 全局配置模式 configure terminal
2) 配置BPDU保護
    (config)#spanning-tree portfast bdpufilter default
3) 進入接口模式  interface 接口
4) 接口使能portfast,BPDU保護才能啓用
    (config-if)#spanning-tree portfast
方法二:接口模式
1) 接口模式下  interface 接口
2) 使能BPDU保護
    (config-if)#spanning-tree bpduguard enable
   驗證過程:
    show running-configure
根保護
傳統的802.1D STP沒有給網絡管理員提供確保交換式第2層網絡拓撲安全。如下圖,當新接入的
交換機優先級更低,將搶佔原有的根網橋。
根保護的目的是確保啓用了根保護的端口成爲指定端口。通常一個根橋的所有端口均爲指定端口。
除非連接到兩個或多根網橋的端口。如果網橋在啓用根保護的端口上收到一個較好的 STP  BPDU。這個
端口進入STP的根不一致狀態,  不會有流量通過該端口。
   如下拓撲:
   A 和 B 爲分佈層 SW,C 爲接入層 SW,根爲 A。當在 C 下面再接一臺 SW時,由於D的優先級或MAC地址可能比其它要低,可能會使D成爲Root SW,從而使得從A 到達B的流量不能直接發送到B,而得使用C來轉發,這樣很不合理(A 和 B 之間爲千兆)。爲了避免這種情況,可以在C的下聯端口上使用Root Guard,以防止該端口成爲Root Port,從而防止D成爲Root SW,確保A永遠爲 Root SW。使用Root Guard 後,SW D接入網絡後,C的下聯D的端口會收到一個更新的BPDU(前提是D的優先級最高)後,C將該端口轉爲Block狀態,直到D不在發送新的BPDU或更改D的優先級。
 
當一個根保護端口阻塞一個端口時,控制檯將會顯示如下消息:
 %SPANTREE-2-ROOTGUARDBLOCK: Port 1/1 tried to become non-designated in VLAN 77. Moved to root-inconsistent state
   注意,在一個端口上起用了根保護,會作用於該端口所屬的所有VLAN。不要再一個起用了UplinkFast特性的端口上啓用根保護。遊樂UplinkFast,在出現故障時備份端口(處於阻塞狀態)會代替根端口。但是,如果也啓用了根保護,所有使用UplinkFast特性的備份端口將被置於根不一致(阻塞)狀態,使其無法進入轉發狀態。
    配置過程:
1) 進入接口模式  interface 接口
2) 啓用根保護
    spanning-tree guard root
3) 驗證過程
    show running-config interface 接口
    show spanning-tree inconsistentports
顯示端口不一致(阻塞)狀態的信息
環路保護
換路保護能夠對第2層轉發環路(STP環路)提供額外的保護。當冗餘拓撲中的STP阻塞端口錯誤地過渡到轉發狀態的時候,就將發生橋接環路。
如下圖:交換機A是根交換機。因爲交換機B和C之間的鏈路發生單向鏈路失效,交換機不能從交換機B接收BPDU。如果沒有啓用環路保護特性,那麼交換機C在最大壽命計時器到期之後,交換機C上的STP阻塞端口將轉換到STP監聽狀態,並最終會在兩倍的轉發延遲時間之後轉換到轉發狀態。當交換機C的源阻塞端口進入到轉發狀態的時候,交換機B的源指定端口還處於轉發狀態,這個拓撲中沒有阻塞端口,而產生了環路。
 
如果啓用了環路保護特性之後,當最大壽命計時器到器之後,交換機C上的阻塞端口將過渡到“不一致環路”狀態,如下圖,如果端口處於“不一致環路”狀態,它就不能傳遞任何數據流量,因此,網絡也就不能產生橋接環路。“不一致環路”狀態等效於阻塞狀態。
 
在非指定端口上使用 Loop  Guard。防止環路產生。避免上於處於 Block 端口的 SW 在Max_age 時間內接收不到對方(鄰居)的 BPDU 而將端口狀態轉爲 Listen->Learning->Forward 狀態。使用Loop Guard 後,等接收不到對方的BPDU消息後,將端口Block狀態轉爲Loop-inconsistent(環路不一致)狀態,從而避免產生環路。
如果使用Loop Guard,那麼Root Guard將會被關閉。兩者不能同時啓用
配置過程:
     方法一:全局配置模式
1) 全局配置模式 configure terminal
2) 配置環路保護
    (config)#spanning-tree portfast loopguard default
方法二:接口模式
1) 接口模式下  interface 接口
2) 使能環路保護
    (config-if)#spanning-tree guard loop
   驗證過程:
show running-configure
show spanning-tree active
show spanning-tree interface 接口 detail
-------------------------------------------------------------------
Port 23 (FastEthernet0/23) of VLAN0001 is forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.23.
   Designated root has priority 32769, address 000b.5f2c.2080
   Designated bridge has priority 32769, address 000b.5f2c.2080
   Designated port id is 128.23, designated path cost 0
   Timers: message age 0, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   Link type is point-to-point by default
   Loop guard is enabled on the port
   BPDU: sent 2709, received 5
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章