cannot pxe boot on an interface with spanning-tree portfast disabled

Synopsis

I had a situation on a server with a trunked management interface (also communicating on native VLAN) where it refused to PXE boot, but once the OS had booted, everything worked fine. All other systems on that VLAN were able to PXE boot, so it wasn't firewall/router settings affecting it.

Fault overview

Without spanning-tree portfast configured on a switchport, when the link initialises, it will go through the Spanning Tree Listening, Learning and Forwarding states. This takes a little while, long enough for the PXE boot attempt to time out.

Resolution

Always use PortFast or Trunk portfast mode on non-switch devices (i.e. plain servers etc), even if the interface is trunked.

Code example
switch01#sh span int g2/0/15 portfast
VLAN0030            disabled
VLAN0040            disabled
switch01#sh span int g2/0/15
 
Vlan                Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
VLAN0030            Desg FWD 4         128.71   P2p
VLAN0040            Desg FWD 4         128.71   P2p
switch01#sh mac address-table | inc 911e
  32    11ca.2b93.911e    DYNAMIC     Gi2/0/55
cenhkgwans01#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
switch01 (config)#int Gi2/0/55
switch01#sh mac address-table interface Gi2/0/55
          Mac Address Table
-------------------------------------------
 
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
  32    11ca.2b93.911e    DYNAMIC     Gi2/0/55
Total Mac Addresses for this criterion: 1
switch01#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
switch01 (config)#int Gi2/0/55
switch01 (config-if)#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
 
cenhkgwans01#sh spanning-tree int Gi2/0/55 portfast
VLAN0030            enabled
VLAN0040            enabled