Настройка режима PortFast и функции BPDU Guard
Отредактирована 06.05.2025
Режим PortFast и STP
sw3#show interfaces fastEthernet 0/13 status Port Name Status Vlan Duplex Speed Type Fa0/13 Attacker connected 10 a-full a-100 10/100BaseTX
sw3#show spanning-tree vlan 10 | include Fa0/13 Fa0/13 Desg FWD 19 128.13 P2p
sw3#debug spanning-tree events
sw3(config)#interface fastEthernet 0/13 sw3(config-if)#shutdown sw3(config-if)# *Mar 1 00:33:08.452: STP: VLAN0010 sent Topology Change Notice on Gi0/2 *Mar 1 00:33:08.452: STP[10]: Generating TC trap for port FastEthernet0/13 *Mar 1 00:33:10.457: %LINK-5-CHANGED: Interface FastEthernet0/13, changed state to administratively down *Mar 1 00:33:11.463: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/13, changed state to down sw3(config-if)#
sw3(config-if)#no shutdown sw3(config-if)# *Mar 1 00:33:27.108: set portid: VLAN0010 Fa0/13: new port id 800D *Mar 1 00:33:27.108: STP: VLAN0010 Fa0/13 -> listening *Mar 1 00:33:27.427: %LINK-3-UPDOWN: Interface FastEthernet0/13, changed state to up *Mar 1 00:33:28.434: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/13, changed state to up *Mar 1 00:33:42.115: STP: VLAN0010 Fa0/13 -> learning *Mar 1 00:33:57.123: STP[10]: Generating TC trap for port FastEthernet0/13 *Mar 1 00:33:57.123: STP: VLAN0010 sent Topology Change Notice on Gi0/2 *Mar 1 00:33:57.123: STP: VLAN0010 Fa0/13 -> forwarding sw3(config-if)#
Обратите внимание, что полный период перехода между состояниями обычно занимает от 30 до 50 секунд.
В это время не передаются пользовательские данные. Некоторые пользовательские приложения могут
завершить работу в течение этого периода. Чтобы обеспечить немедленный переход порта в режим
перенаправления (forwarding), включите режим STP PortFast.
sw3#configure terminal Enter configuration commands, one per line. End with CNTL/Z. sw3(config)#interface range FastEthernet 0/1-48 sw3(config-if-range)#spanning-tree portfast ? disable Disable portfast for this interface trunk Enable portfast on the interface even in trunk mode sw3(config-if-range)#spanning-tree portfast trunk %Warning: portfast should only be enabled on ports connected to a single host. Connecting hubs, concentrators, switches, bridges, etc... to this interface when portfast is enabled, can cause temporary bridging loops. Use with CAUTION sw3(config-if-range)exit sw3(config)#
При такой настройке PortFast будет работать как в режиме access, так и в режиме trunk.
sw3(config)#interface fastEthernet 0/13 sw3(config-if)#shutdown sw3(config-if)# *Mar 1 00:55:43.740: %LINK-5-CHANGED: Interface FastEthernet0/13, changed state to administratively down *Mar 1 00:55:44.747: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/13, changed state to down
sw3(config-if)#no shutdown sw3(config-if)# *Mar 1 00:58:21.312: set portid: VLAN0010 Fa0/13: new port id 800D *Mar 1 00:58:21.312: STP: VLAN0010 Fa0/13 ->jump to forwarding from blocking *Mar 1 00:58:21.648: %LINK-3-UPDOWN: Interface FastEthernet0/13, changed state to up *Mar 1 00:58:22.654: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/13, changed state to up sw3(config-if)#
Функция BPDU Guard и STP
sw3#show running-config interface fastEthernet 0/13 Building configuration... Current configuration : 212 bytes ! interface FastEthernet0/13 description Attacker switchport access vlan 10 switchport mode access switchport nonegotiate no lldp receive spanning-tree portfast trunk end
Source | Info | Расшифровка |
---|---|---|
6f:e6:de:4b:7d:5a | Conf. TC + Root = 4096/3465/6f:e6:de:4b:7d:5a Cost = 0 Port = 0x8002 | Приоритет 4096, VLAN ID 3465, MAC 6f:e6:de:4b:7d:5a |
b0:85:0d:50:b1:5a | Conf. TC + Root = 8192/1511/b0:85:0d:50:b1:5a Cost = 0 Port = 0x8002 | |
db:39:43:04:a5:46 | Conf. TC + Root = 4096/634/db:39:43:04:a5:46 Cost = 0 Port = 0x8002 | |
Пример 1. Настройка функции BPDU Guard на всех портах доступа
sw3#configure terminal Enter configuration commands, one per line. End with CNTL/Z sw3(config)#interface range FastEthernet 0/1-48 sw3(config-if-range)#spanning-tree bpduguard ? disable Disable BPDU guard for this interface enable Enable BPDU guard for this interface sw3(config-if-range)#spanning-tree bpduguard enable sw3(config-if-range)#end sw3# sw3#copy running-config startup-config Destination filename [startup-config]? Building configuration... [OK]
sw3#show running-config interface fastEthernet 0/13 Building configuration... Current configuration : 212 bytes ! interface FastEthernet0/13 description Attacker switchport access vlan 10 switchport mode access switchport nonegotiate no lldp receive spanning-tree portfast trunk spanning-tree bpduguard enable end
sw3#show spanning-tree interface fastEthernet 0/13 portfast VLAN0010 enabled
sw3# *Mar 1 00:05:38.639: %SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port Fa0/13 with BPDU Guard enabled. Disabling port. *Mar 1 00:05:38.639: %PM-4-ERR_DISABLE: bpduguard error detected on Fa0/13, putting Fa0/13 in err-disable state *Mar 1 00:05:39.654: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/13, changed state to down *Mar 1 00:05:40.652: %LINK-3-UPDOWN: Interface FastEthernet0/13, changed state to down
sw3#show interfaces status | include Fa0/13 Fa0/13 Attacker err-disabled 10 auto auto 10/100BaseTX
sw3#show logging | begin BLOCK *Mar 1 00:05:38.639: %SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port Fa0/13 with BPDU Guard enabled. Disabling port. *Mar 1 00:05:38.639: %PM-4-ERR_DISABLE: bpduguard error detected on Fa0/13, putting Fa0/13 in err-disable state *Mar 1 00:05:39.654: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/13, changed state to down *Mar 1 00:05:40.652: %LINK-3-UPDOWN: Interface FastEthernet0/13, changed state to down
sw3#configure terminal Enter configuration commands, one per line. End with CNTL/Z sw3(config)#interface FastEthernet 0/13 sw3(config-if)#no shutdown
Примечание: интервал ожидания по умолчанию составляет 300 секунд, и по умолчанию функция
timeout отключена.
sw3(config)#errdisable recovery cause bpduguard sw3(config)#errdisable recovery interval ? <30-86400> timer-interval(sec) sw3(config)#errdisable recovery interval 60
Атакующий начинает снова атаку, и статус порта Fa0/13 переходит в err-disabled, но через 60 секунд, снова переходит в connected
sw3#show interfaces status | include Fa0/13 Fa0/13 Attacker err-disabled 10 auto auto 10/100BaseTX
sw3# *Mar 1 00:53:35.068: %PM-4-ERR_RECOVER: Attempting to recover from bpduguard err-disable state on Fa0/13 *Mar 1 00:53:38.725: %LINK-3-UPDOWN: Interface FastEthernet0/13, changed state to up *Mar 1 00:53:39.732: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/13, changed state to up sw3# sw3#show inter fastEthernet 0/13 status Port Name Status Vlan Duplex Speed Type Fa0/13 Attacker connected 10 a-full a-100 10/100BaseTX
Но при такой настройке портов доступа, злоумышленник сканирует трафик на порту Fa0/13, лучше заменить функцию BPDU Guard на BPDU Filter. У атакующего не будет возможности получать кадры STP BPDU.
sw3#show spanning-tree detail | section Port 13 Port 13 (FastEthernet0/13) of VLAN0010 is designated forwarding Port path cost 19, Port priority 128, Port Identifier 128.13. Designated root has priority 32778, address a40c.c392.1180 Designated bridge has priority 32778, address a40c.c392.1900 Designated port id is 128.13, designated path cost 4 Timers: message age 0, forward delay 0, hold 0 Number of transitions to forwarding state: 1 The port is in the portfast mode by portfast trunk configuration Link type is point-to-point by default Bpdu guard is enabled BPDU: sent 140, received 0
sw3(config)#no errdisable recovery cause bpduguard sw3(config)#no errdisable recovery interval 60 sw3(config)#interface range FastEthernet 0/1-48 sw3(config-if-range)#no spanning-tree bpduguard enable sw3(config-if-range)#spanning-tree bpdufilter enable sw3(config-if-range)#no cdp enable sw3(config-if-range)#end sw3# sw3#copy running-config startup-config Destination filename [startup-config]? Building configuration... [OK]
sw3#clear spanning-tree counters interface FastEthernet 0/13 sw3# sw3#show spanning-tree detail | section Port 13 Port 13 (FastEthernet0/13) of VLAN0010 is designated forwarding Port path cost 19, Port priority 128, Port Identifier 128.13. Designated root has priority 32778, address a40c.c392.1180 Designated bridge has priority 32778, address a40c.c392.1900 Designated port id is 128.13, designated path cost 4 Timers: message age 0, forward delay 0, hold 0 Number of transitions to forwarding state: 1 The port is in the portfast mode by portfast trunk configuration Link type is point-to-point by default Bpdu filter is enabled BPDU: sent 0, received 0
sw3#show spanning-tree detail | section Port 13 Port 13 (FastEthernet0/13) of VLAN0010 is designated forwarding Port path cost 19, Port priority 128, Port Identifier 128.13. Designated root has priority 32778, address a40c.c392.1180 Designated bridge has priority 32778, address a40c.c392.1900 Designated port id is 128.13, designated path cost 4 Timers: message age 0, forward delay 0, hold 0 Number of transitions to forwarding state: 1 The port is in the portfast mode by portfast trunk configuration Link type is point-to-point by default Bpdu filter is enabled BPDU: sent 0, received 0
sw3#show interfaces fastEthernet 0/13 status Port Name Status Vlan Duplex Speed Type Fa0/13 Attacker connected 10 a-full a-100 10/100BaseTX
sw3#show running-config interface FastEthernet 0/13 Building configuration... Current configuration : 226 bytes ! interface FastEthernet0/13 description Attacker switchport access vlan 10 switchport mode access switchport nonegotiate no lldp receive no cdp enable spanning-tree portfast trunk spanning-tree bpdufilter enable end
В данном примере были использованы коммутаторы Cisco Catalyst серии 2960, и прошивкой:
c2960-lanlitek9-mz.150-2.SE5.bin
«-«-«- Назад | Вперед -»-»-» |