STP 3 - 生成树协议中4个guard 和 3个fast加一个filter
最近出的幾個問題總是和生成樹協(xié)議有問題,復(fù)習(xí)的時候順帶總結(jié),溫故而知新。
先上一個大牛總結(jié)的圖(Vinny), 總結(jié)的非常好,你看完后面的文章再來看這張圖就會會心一笑 - i got it !
先講下計時器,不論什么協(xié)議總是有些計時器,Hello數(shù)據(jù)包什么的。尤其到路由協(xié)議,怎么建立鄰居關(guān)系,怎么通知拓?fù)涓淖?#xff0c;各種不同路由協(xié)議是各顯神通。
所以在理解的時候最好要了解為什么這些協(xié)議需要計時器等等,這樣我們就可以以不變應(yīng)萬變。
STP Timer?
(計時器的配置在當(dāng)前交換機成為根橋時有用,因為默認(rèn)只有根橋產(chǎn)生bpdu)
- Hello - 發(fā)送BPDU的頻率,默認(rèn)2s
- Max Age - 在沒有收到bpdu的情況下保持在block mode,默認(rèn)20s
- Forward Delay - 在listening 和 learning階段等待時間,默認(rèn)各15s
配置:
Router(config)#spanning-tree vlan 1 hello-time ?
? <1-10> ?number of seconds between generation of config BPDUs
Router(config)#spanning-tree vlan 1 forward-time ?
? <4-30> ?number of seconds for the forward delay timer
Router(config)#spanning-tree vlan 1 max-age ?
? <6-40> ?maximum number of seconds the information in a BPDU is valid
驗證:
Router#sh spanning-tree vlan 1 br
VLAN1
? Spanning tree enabled protocol ieee
? Root ID ? ?Priority ? ?32768
? ? ? ? ? ? ?Address ? ? cc00.5f24.0000
? ? ? ? ? ? ?This bridge is the root
? ? ? ? ? ? ?Hello Time ? 2 sec ?Max Age 20 sec ?Forward Delay 15 sec
? Bridge ID ?Priority ? ?32768
? ? ? ? ? ? ?Address ? ? cc00.5f24.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
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/0 ? ? ?128.1 ? ?128 ? ?19 FWD ? ? 0 32768 cc00.5f24.0000 128.1
FastEthernet0/1 ? ? ?128.2 ? ?128 ? ?19 FWD ? ? 0 32768 cc00.5f24.0000 128.2
====================
PortFast
- 由于局域網(wǎng)中并不是所有設(shè)備都運行STP協(xié)議,比如PC,電話等等,對于連接終端用戶的交換機端口其實是沒有必要把整個生成樹端口狀態(tài)走完。Port Fast的作用就是跳過 Listening & Learning 階段直接從block進入forwarding。當(dāng)然前提是確保物理層沒有產(chǎn)生環(huán)路。
- portfast命令也會影響TCN的生成。面向終端用戶的端口默認(rèn)是會在用戶連接或斷開時發(fā)送TCN到root,這時成個STP都會重新收斂并重置?mac address table /CAM table (by setting aging time to max)。如果開啟portfast,就不會生成TCN
- interface command - spanning-tree portfast?
- global command - spanning-tree portfast default (enable portfast on non-trunk ports)
======================== UplinkFast
用于當(dāng)直連根端口不工作時,立即啟用備用根端口。實際上當(dāng)原有根端口down,交換機會復(fù)制CAM table的內(nèi)容通過備用端口發(fā)送給鄰居交換機,加快收斂速度。當(dāng)啟用這個命令后,優(yōu)先級和root path cost會被更改為更高,意味著更不容易競爭根橋或作為別的交換機去根橋的通路(transit path)。
一般應(yīng)用于有blocked port,而且處于access層的交換機
配置: global command - spanning-tree uplinkfast
======================== BackboneFast
用于當(dāng)與交換機非直接相連的鏈接無效時(鄰居交換機通往root的鏈接down),幫助加速收斂(省去20s Max-age)比如以下拓?fù)?#xff08;開啟backboneFast)
- SW4是根橋,SW1通過SW3再到SW4。當(dāng)SW3和SW4之間的Etherchannel斷路, SW3向SW1發(fā)送 Inferior BPDU警示SW1下游路徑去SW4代價很高,應(yīng)另尋出路。
- BackboneFast可以在所有交換機上開啟,用來偵測非直連鏈路失效。
====================== BPDU Filter
過濾接收和發(fā)送BPDU,可以在interface配置也可以global下配置。被配置的端口就不會發(fā)送和接收bpdu。一般會和portfast在一起用,動態(tài)管理終端連接,但是有安全風(fēng)險 (man in the middle attack)
- interface level - 雙向過濾,既收不到,也不向外發(fā)。
- global level - 單向過濾,不向外發(fā)
interface配置: intface - spanning-tree bpdufilter enable
interface驗證: sh run interface [interface id] clear spanning-tree counters & sh spanning-tree interface [id] details | in BPDU
Global配置(和portfast一起用) spanning-tree portfast default spanning-tree portfast bpdufilter default
這種情況很有意思,全局開啟portfast和bpdufilter。如果端口A連接的是PC,沒有收到bpdu,那么bpdufilter使交換機也不是端口A向外發(fā)送bpdu;端口B恰好連接到另一臺交換機,收到了bpdu,bpdufilter就會在端口B關(guān)閉portfast功能,進而可以進行bpdu溝通。
========================= BPDU Guard
如果在不該收到bpdu的端口收到bpdu數(shù)據(jù)包,則關(guān)閉該端口(err-disable)。有時候因為bpdu guard,莫名其妙端口變?yōu)镋rr-disable,可參考我另一篇博文?Err-disable診斷與恢復(fù)?。 例如:當(dāng)面向主機的端口開啟了bpdu guard,但是有人連接了一個交換機,端口收到bpdu后就會被置于Err-disable狀態(tài)。如果err-disable recovery time沒有開啟的話,就必須聯(lián)系網(wǎng)絡(luò)管理員去shut/ no shut端口。當(dāng)然前提是必須先移除那個多余的交換機,不然端口依然會被關(guān)閉。
在全局配置模式下可以和portfast一起配合使用 spanning-tree portfast default spanning-tree portfast bpduguard default
========================= Root Guard
防止新加入的交換機打亂原有拓?fù)?#xff0c;一般配置在Core和Distribution 面向access layer的端口。一旦下行端口接收到bpdu包,指示下行鄰居交換機為根橋,這時root guard就會block這個下行端口直到鄰居交換機priority等信息更改(不再與原有根橋競爭),才會解除對下行端口block。
端口上配置: interface level - spanning-tree guard root
驗證: sh spanning-tree interface [id] detail
===================== Loop Guard & UDLD (Unidirection Link Detection) "Guard"
紅色標(biāo)出的是兩者的優(yōu)缺點。這就是為什么經(jīng)常同時使用
- Loop Guard - 防止配置錯誤,ios軟件問題導(dǎo)致stp不能正常工作
- UDLD - 能偵測出物理鏈路斷路或搭錯跳線
| Configuration | Per-port | Per-port |
| Action granularity | Per-VLAN | Per-port |
| Autorecover | Yes | Yes, with err-disable timeout feature |
| Protection against STP failures caused by unidirectional links | Yes, when enabled on all root and alternate ports in redundant topology | Yes, when enabled on all links in redundant topology |
| Protection against STP failures caused by problems in the software (designated switch does not send BPDU) | Yes | No |
| Protection against miswiring. | No | Yes |
loopguard配置: interface level - ?spanning-tree guard loop global level - spanning-tree loopgauard default
UDLD配置和驗證: interface level - udld port show udld interface [id]
思科文檔:?http://www.cisco.com/c/en/us/support/docs/lan-switching/spanning-tree-protocol/10596-84.html INE blog "UDLD mode of Operations":http://blog.ine.com/2008/07/05/udld-modes-of-operation/
看來UDLD需要再來一篇單獨講啊,很多地方都能用到。今天先到這里吧。
總結(jié)
以上是生活随笔為你收集整理的STP 3 - 生成树协议中4个guard 和 3个fast加一个filter的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: QQ浏览器HD iOS 动态化/热修复方
- 下一篇: C语言程序设计之考卷成绩分析软件程序设计