在交换机启动后,由于STP的原因,端口状态需要从initialization(初始化)到blocking,从blocking到listening,从listening 到learning,从learning 到forwarding,其中经历了两个forward delay,也就是说一个端口在交换机启动后,至少需要30秒后才能够为用户提供数据转发。对于一个连接了主机或服务器的端口来说,让其参与STP计算是毫无必要的,因为此类端口即使直接转发数据来说,也不会造成环路,并且30秒的时间对于需要立即传递数据的主机或服务器来说,是漫长的,因此,此类端口可以配置为跳过STP的计算,从而直接过渡到forwarding状态。

在Cisco交换机上通过将接口配置为PortFast功能,便可以使接口跳过STP的计算,直接过渡到forwarding状态。

通常情况下,需要在access接口(通常连接的是主机或服务器)配置为portfast功能,trunk接口也可以开启portfast功能,当开启了Port Fast功能的接口,如果在接口上收到BPDU后,就认为对端连接的是交换机,而并非主机或服务器,因此默认在接口收到BPDU后会立即关闭该接口的Port Fast功能。


PortFast的配置:

Switch1(config)#int e0/2

Switch1(config-if)#spanning-tree portfast ?

 disable  Disable portfast for this interface

 trunk    Enable portfast on the interface even in trunk mode

 <cr>


Switch1(config-if)#spanning-tree portfast

%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


%Portfast has been configured on Ethernet0/2 but will only

have effect when the interface is in a non-trunking mode.

Switch1(config-if)#  


如果需要为trunk接口开启portfast功能的话,则需要使用spanning-tree portfast trunk

验证:

Switch1#sh spanning-tree interface e0/2 portfast

VLAN0010            enabled

Switch1#


全局开启portfast功能:

Switch1(config)#spanning-tree portfast default

Switch1(config)#

全局的开启portfast,将为所有的access接口启用portfast功能。