BPDU GUARD的功能是當這個端口收到任何的BPDU就馬上設爲Error-Disabled狀態。我們知道,當交換機STP功能啓用的時候,默認所有端口都會參與STP,併發送和接受BPDU,當BPDU GUARD開啓後,在正常情況下,一個下聯的端口是不會收到任何BPDU的,因爲PC和非網管換機都不支持STP,所以不會收發BPDU。當這個端口下如果有自迴環的環路,那麼它發出去的BPDU在非網管換機上回環後就會被自己接收到,這個時候BPDU GUARD就會把它立刻設爲Error-Disabled狀態,這個端口就相當於被關閉了,不會轉發任何數據,也就切斷了環路,保護了整個網絡。
BPDU Guard特性可以全局啓用也可以基於基於接口的啓用,兩種方法稍有不同.當在啓用了Port Fast特性的端口收到了BPDU後,BPDU Guard特性將關閉(err-disable)該端口 端口處於err-disable狀態時必須手動才能把此端口回覆爲正常狀態。
配置方法:
Switch(config)# spanning-tree portfast bpduguard default /---在啓用了Port Fast特性的端口上啓用BPDU Guard---/
Switch(config-if)# spanning-tree bpduguard enable /---在不啓用Port Fast特性的情況下啓用BPDU Guard---/
BPDU Filtering特性和BPDU Guard特性非常類似.通過使用BPDU Filtering,將能夠防止交換機在啓用了Port Fast特性的端口上發送BPDU給主機。
如果全局配置了BPDU Filtering,當某個端口接收到了BPDU,那麼交換機將把端口更改回正常的STP狀態,也就是它將禁用Port Fast和BPDU Filtering特性。
/*Cisco的原文是:
If an operational PortFast port receives a BPDU, it immediately loses its operational PortFast status. In that case,
PortFast BPDU filtering is disabled on this port and STP resumes sending BPDUs on this port.
*/
注意,如果在連接到其他交換機的端口上配置了BPDU Filtering,那麼就有可能導致層2環路(Prevent from sending and receiving BPDU).另外,如果在與啓用了BPDU Filtering的相同端口上配置了BPDU Guard特性,所以BPDU Guard將不起作用,起作用的將是BPDU Filtering.
配置BPDU Filtering:
Switch(config)# spanning-tree portfast bpdufilter default /---在啓用了Port Fast特性的端口上啓用BPDU Filtering---/
Switch(config-if)# spanning-tree bpdufilter enable /---在不啓用Port Fast特性的情況下啓用BPDU Filtering---/