Sub topic 14
Edge ports and PortFast
This chapter assumes you know how root bridges, port roles and the classic 802.1D port states work, and that you can read basic Cisco IOS configuration. It covers what an edge port is, how PortFast implements it, and the mistakes that go with it.
The problem: 30 seconds of silence
A port in classic STP moves through blocking, listening, learning and forwarding. With default timers, the listening and learning stages each last the forward delay of 15 seconds. A port that has just come up therefore carries no traffic for about 30 seconds.
That delay protects the network when the neighbor is another switch, because the switch must learn whether forwarding would create a loop. A laptop, printer or IP phone cannot create a loop. The wait only causes harm:
- A DHCP client may give up before the port forwards, and the host then self-assigns an address.
- PXE and network boot can time out.
- Some operating systems report "network unavailable" at login.
What an edge port is
An edge port is a port that connects to a single end device and never to another bridge. The RSTP standard (802.1w, now part of 802.1Q) defines the concept directly. Cisco's name for the feature is PortFast. Two behaviors define an edge port:
- It moves to forwarding immediately when the link comes up. It skips listening and learning.
- It does not trigger a topology change when it goes up or down. Other switches therefore do not shorten their MAC aging timers every time someone reboots a PC.
An edge port still takes part in spanning tree. It still receives BPDUs, and a BPDU arriving on the port is evidence that the "edge" assumption is false. A PortFast port that receives a BPDU stops acting as an edge port and goes through normal STP processing. The configured PortFast setting stays in place, so the port can regain edge status only after the BPDUs stop.
Configuring PortFast
Enable PortFast per interface on access ports that face hosts. Pair it with BPDU Guard so that the port shuts down if a switch is plugged in.
! Cisco IOS: host-facing access port
interface GigabitEthernet0/5
switchport mode access
switchport access vlan 10
spanning-tree portfast
spanning-tree bpduguard enableTwo global commands apply the same settings to every access port at once:
! Cisco IOS: defaults for all access ports
configure terminal
spanning-tree portfast default
spanning-tree portfast bpduguard default
endThe default form affects only ports in access mode. A port that is operationally a trunk is not made an edge port by it. That behavior is a feature, because trunks usually lead to other switches.
Some trunks lead to a single host. A hypervisor with VLAN-tagged virtual machines is the usual case. For those, use the explicit trunk form:
! Cisco IOS: trunk to a server, never to a switch
interface GigabitEthernet0/20
switchport mode trunk
switchport trunk allowed vlan 10,20
spanning-tree portfast trunk
spanning-tree bpduguard enableIOS warns when you enable PortFast on an interface. The warning says that PortFast should be used only on ports connected to a single host, and that connecting hubs, concentrators, switches or bridges to the port can cause temporary bridging loops.
Checking the result
! Cisco IOS: confirm which ports are edge ports
show spanning-tree interface GigabitEthernet0/5 portfast
show spanning-tree vlan 10
show spanning-tree summaryIn show spanning-tree vlan 10, the Type column shows P2p Edge for an operational edge port and P2p for an ordinary point-to-point port. If you configured PortFast and still see plain P2p, the port has probably received a BPDU. Look at what is plugged in.
In show spanning-tree summary, the line "Portfast Default" tells you whether the global default is on. The same output also lists BPDU Guard settings.
When PortFast goes wrong
The failure modes mostly come from a switch ending up behind an edge port.
- Unmanaged switch or hub looped back on itself. A user plugs both ends of a patch cable into a small desk switch. That switch has no STP. Frames circulate inside it and flood back into your edge port. Without BPDUs the port cannot detect the loop. BPDU Guard does not help either, because the desk switch sends no BPDUs. Storm control and the MAC-flapping logs are the tools that catch it.
- Managed switch added to a PortFast port. The new switch sends BPDUs. With BPDU Guard on, the port is put into err-disabled state at once. Without it, the new switch may even become root if its priority is lower, and the topology changes.
- PortFast on an inter-switch link. The port forwards before STP has evaluated the link. This can create a brief loop that is large enough to saturate links and trigger a broadcast storm.
- Blaming PortFast for a delay it cannot fix. PortFast removes only the STP delay. A link that takes 20 seconds to negotiate speed, or a DHCP server that is slow to respond, is not an STP problem.
An err-disabled port stays down until an administrator acts. To restore it, shut and re-enable the port after removing the cause. You can also set the switch to recover automatically:
! Cisco IOS: recover BPDU Guard err-disabled ports after 5 minutes
configure terminal
errdisable recovery cause bpduguard
errdisable recovery interval 300
end
show errdisable recoveryAutomatic recovery is convenient, but if the offending device is still connected, the port will cycle between err-disabled and up every 5 minutes. Fix the cause first.
Related settings
| Setting | What it does | Where to use it |
|---|---|---|
| PortFast | Skips listening and learning, and suppresses topology changes | Host-facing ports |
| BPDU Guard | Err-disables a port that receives any BPDU | Every PortFast port |
| BPDU Filter | Stops sending and receiving BPDUs on the port | Rarely, and only with a clear reason |
| Root Guard | Blocks a port that receives a superior BPDU | Ports that must never lead to the root |
BPDU Filter deserves particular caution. A port with a filter ignores incoming BPDUs, so a switch plugged into it can no longer be detected, and it silently removes loop protection. Prefer BPDU Guard.
Other platforms
The Linux kernel bridge implements only classic 802.1D STP, so it has no true edge-port behavior. If you need RSTP on Linux, use a user-space daemon such as mstpd. It supports an administrative edge setting per port. Many vendors use the names "edge port" or "admin edge" for what Cisco calls PortFast.
Summary
- Classic STP makes every new port wait about 30 seconds. An edge port skips that wait.
- Only ports that face a single end device should be edge ports.
- Edge ports do not cause topology changes when they flap.
- A BPDU on an edge port means the assumption was wrong. Pair PortFast with BPDU Guard so the port reacts.
- Check
show spanning-treefor theP2p Edgetype to confirm the result.
Exercise
A technician plugs a managed switch into Gi0/5, which has spanning-tree portfast and spanning-tree bpduguard enable. What happens, and what command would you use afterward to see why the port is down?
Show answer
The new switch sends BPDUs. BPDU Guard sees one arrive on a PortFast port and puts the port into err-disabled state, so no loop or topology change occurs. Use show errdisable recovery to see recovery settings, or show interfaces status err-disabled to list the port and the cause. After you remove the switch, shut and re-enable the port, or wait for errdisable recovery if it is configured.
Exercise
You configured spanning-tree portfast default globally. A server connected to a trunk port still waits 30 seconds after link-up. Why, and how do you fix it?
Show answer
The global default applies only to ports that are operationally in access mode. The server port is a trunk, so it is not an edge port. Add spanning-tree portfast trunk on that interface, and add BPDU Guard, because the port must connect only to a host.