In a previous blog, we explained how Spanning Tree Protocol, or STP, prevents network loops by selecting a primary path and placing redundant paths into a standby state until they are needed. This helps maintain network availability, but a reliable network must also control what is allowed to connect to it.
Industrial switches often connect directly to PLCs, drives, HMIs, workstations, and other critical equipment. If those connections are not properly secured, someone could replace an approved device, add another switch, or introduce equipment that changes the intended network topology. Even a single unprotected port can create an opportunity for unauthorized access or unexpected network behavior.
Fortunately, managed switches include tools that can help address these risks. Disabling unused ports, implementing MAC-based port security, and properly configuring BPDU Guard and Root Guard can help control device access and protect the STP topology.
Disable Unused Ports
Every active switch port provides a possible connection to the network. If an unused port remains enabled, someone could connect a laptop, switch, or other device and potentially gain network access. Administratively disabling unused ports is one of the simplest ways to reduce the network’s attack surface. A disabled port cannot forward traffic until an authorized administrator re-enables it.
This practice is especially important for switch ports located in accessible control panels, cabinets, production areas, and other locations where someone could make a physical connection. Disabling unused ports does not protect the ports that must remain active, however. Additional controls are needed to ensure those ports are used only by their intended devices.
Use MAC-Based Port Security
Disabling unused ports reduces the number of available network entry points, but the ports connected to equipment must remain active. MAC-based port security adds protection to those active ports by limiting which devices are permitted to connect.
Consider a switch with three active ports connected to a drive, a PLC, and an HMI. All unused ports have been disabled, but the three active ports still present a potential risk.
Someone could disconnect one of those devices and connect a laptop or another unauthorized device in its place. Because the port is active, the switch may allow the new device to begin communicating on the network.
MAC-based port security can reduce this risk. A switch can be configured to learn or manually define the Media Access Control, or MAC, address of the device authorized to use a particular port. The port can also be limited to a specified number of MAC addresses.
If the switch detects a device that violates the configured port-security policy, it can respond according to its configured violation mode. Depending on the switch and its configuration, the switch may block the unauthorized traffic, record the violation, or place the port into a disabled state.
For example, if Port 3 is intended only for a specific HMI, port security can restrict that connection to the HMI’s MAC address. Replacing the HMI with a laptop or connecting a switch that introduces additional MAC addresses would trigger the configured response.
MAC-based port security is a useful layer of protection, but it should not be treated as the only access-control measure. MAC addresses can be copied or imitated, and equipment replacement may require the authorized address to be updated. Port-security policies should therefore be combined with physical security, network segmentation, monitoring, and documented procedures for replacing equipment.
Protect Edge Ports with BPDU Guard
A Bridge Protocol Data Unit (BPDU) is a message exchanged by switches participating in Spanning Tree Protocol (STP). Switches use BPDUs to share information about the network topology, select the root bridge, determine the best path to that root, and identify redundant paths that should be placed in a blocking or standby state.
Industrial end devices such as PLCs, drives, HMIs, and workstations do not normally participate in STP and should not send BPDUs. This difference allows the network designer to distinguish between:
- Infrastructure ports, which are expected to connect to other switches and receive BPDUs
- Edge ports, which are expected to connect only to end devices and should not receive BPDUs
BPDU Guard protects an edge port from the unexpected connection of a switch.
Consider the earlier example in which Port 3 is reserved for an HMI. If someone disconnects the HMI and installs a switch, that unauthorized switch may begin transmitting BPDUs.
BPDU Guard provides another layer of protection for this situation. When BPDU Guard is enabled on an edge port, receiving a BPDU causes the switch to place that port into an error-disabled or similarly protected state, depending on the switch platform.
This prevents the connected switch from participating in STP through that edge port. It also alerts administrators to a connection that does not match the port’s intended purpose.
BPDU Guard should be applied only to ports designated for end devices. It should not be enabled indiscriminately on links that are expected to connect to other switches, because those connections need to exchange BPDUs for STP to operate correctly.
Protect the Root Bridge with Root Guard
BPDU Guard protects edge ports from unexpected switches. Root Guard protects the intended STP topology by preventing a switch connected through a designated port from becoming the root bridge.
The root bridge acts as the reference point for STP path calculations. In a properly designed network, administrators deliberately choose which switch should serve as the root rather than allowing the election to occur by chance.
STP elects the switch with the lowest bridge ID as the root bridge. The bridge ID includes the configured bridge priority and the switch’s MAC address. Priority is considered first. If two switches have the same priority, the switch with the lower MAC address wins the election.
Consider a network in which Switch 1 has been selected as the root bridge. A third switch is then connected with a bridge ID that is lower than the current root’s bridge ID.
Without another control in place, Switch 3 can become the new root bridge. STP must then recalculate the topology based on the newly elected root. The network may continue to pass traffic, but an unintended device is now influencing path selection throughout the switching topology.
This can be more than just an inconvenience. A topology change can alter the path network traffic follows, create unexpected performance issues, and move control of STP away from the switches selected during the network-design process.
Root Guard helps preserve the intended design. When Root Guard is enabled on a port, the switch monitors that port for superior BPDUs. A superior BPDU advertises information that could cause the connected switch to become the new root bridge. If a superior BPDU is received, the protected port is placed into a root-inconsistent state and stops forwarding traffic. The port can return to normal operation after the superior BPDU is no longer being received.
Root Guard does not simply prevent a device with a lower MAC address from becoming the root. It prevents a device connected through the protected port from presenting superior STP information, whether that superiority results from a lower configured priority or, when priorities are equal, a lower MAC address. Root Guard should be used on ports where another switch may legitimately be connected but should never become the root bridge. BPDU Guard remains the appropriate choice for edge ports where no switch should be connected at all.
How the Controls Work Together
These security features address different network risks, so they are most effective when used together as part of a layered design.
- Disabling unused ports removes unnecessary physical entry points.
- MAC-based port security restricts which end devices can use active ports.
- BPDU Guard prevents a switch connected to an edge port from participating in STP.
- Root Guard prevents a switch connected through a protected infrastructure port from taking over as the root bridge.
The configuration should reflect the intended purpose of each port. An edge port connected to an HMI may use port security and BPDU Guard. A port connected to another authorized switch may use Root Guard if the downstream switch should never become root. A port with no current purpose should remain disabled.
Key Takeaways
- Disable unused ports. An unused port should not remain active and available as an unmonitored network connection.
- Use MAC-based port security on appropriate edge ports. Restricting the MAC addresses allowed on a port can help prevent an unauthorized device from replacing legitimate equipment.
- Enable BPDU Guard on edge ports. If a port is intended for a PLC, drive, HMI, workstation, or other end device, receiving a BPDU should be treated as an unexpected condition.
- Use Root Guard where the network design requires it. Root Guard prevents switches connected through protected ports from changing the intended STP root.
- Document the purpose of each switch port. Port-security settings are easier to configure and maintain when administrators know which ports are unused, which connect to end devices, and which connect to network infrastructure.
STP provides the foundation for a loop-free, resilient Ethernet topology. Port security, BPDU Guard, and Root Guard build on that foundation by helping control which devices can connect and which switches are allowed to influence the topology. Together, these controls support a more predictable and secure industrial network.
Larry has over 16 years of experience spanning ISP deployments, campus-wide BACnet systems, statewide physical security networks, and manufacturing consulting. He holds a Bachelor’s in Electrical Engineering and a Master’s in Enterprise Architecture from Penn State. Larry is known for his ability to simplify complex networking concepts and his passion for continuous learning. He’s especially focused on emerging trends like micro segmentation and edge computing.
