Port mirroring is a feature of managed network switches that copies frames seen on one or more source ports or VLANs and sends those copies to a designated destination port, where an analyzer, intrusion detection sensor or packet recorder can inspect them. In Ethernet & switching it is the standard way to observe live traffic without inserting a device into the forwarding path, and it is widely known as a SPAN port (Switched Port Analyzer), the name used by one major vendor that became common shorthand across Networking.
Mirroring exists because a switch, unlike a hub, delivers each unicast frame only to the port behind which the destination MAC address lives. A laptop plugged into a spare port therefore sees almost nothing of the conversations it needs to diagnose. Port mirroring restores that visibility selectively and on demand, at the cost of extra load on the switch and a copy that is not always complete.
How port mirroring copies traffic inside a switch
Port mirroring works by instructing the switching ASIC to replicate every frame that matches a session definition and enqueue the duplicate on the destination port. A mirror session names the sources, the direction of traffic and the destination. The original frame is forwarded normally, so production traffic is not interrupted, while the copy follows a separate, usually lower-priority path through the switch fabric.
Sources can be physical ports, link aggregation groups or entire VLANs. Direction matters: ingress mirroring copies frames as they enter a source port, egress mirroring copies them as they leave, and both directions gives a full picture of a conversation. The destination port normally stops participating in normal switching; it neither learns MAC addresses nor forwards ordinary traffic, which prevents mirrored frames from leaking back into the network.
The table below summarizes the elements that every mirror session defines and the effect each one has on what the analyzer receives.
| Element | Typical options | Effect on the copy |
|---|---|---|
| Source | Port, port channel, VLAN | Determines which traffic is replicated |
| Direction | Ingress, egress, both | Controls whether one or both halves of a flow appear |
| Destination | Local port, remote VLAN, tunnel | Defines where the analyzer must be connected |
| Filter | ACL, VLAN list, sampling rate | Reduces volume to what the analyzer needs |
| Encapsulation | Native, keep VLAN tags, GRE | Decides whether original tags and context survive |
Local, remote and encapsulated mirroring
Port mirroring comes in three main variants that differ in how far the copied traffic can travel. Local mirroring keeps source and destination on the same switch or stack. Remote mirroring carries the copy across Layer 2 trunks inside a dedicated VLAN, and encapsulated remote mirroring wraps it in an IP tunnel so it can cross routed Layer 3 boundaries.
Vendor names differ, but the concepts are consistent. RSPAN uses a reserved remote VLAN that must exist on every switch along the path, and ERSPAN encapsulates frames in GRE over IP, adding a header that records the session and, in later versions, a timestamp. Some platforms instead offer a generic tunnel-based mirroring option with similar behavior.
| Variant | Transport of the copy | Reach | Main constraint |
|---|---|---|---|
| Local mirroring | Direct to a local port | Same switch or stack | Analyzer must be physically present |
| Remote VLAN mirroring | Dedicated VLAN over trunks | Layer 2 domain | Remote VLAN on every transit switch |
| Encapsulated mirroring | GRE or similar IP tunnel | Any routed network | Header overhead and possible fragmentation |
Encapsulated mirroring is the most flexible, yet it adds roughly 50 bytes of overhead per frame, and full-size or jumbo frames may exceed the MTU of the transport path. When fragmentation is not possible, the copy is truncated or dropped, which an analyst can easily mistake for a fault in the monitored application.
Port mirroring compared with network taps and flow export
Port mirroring is one of three common ways to gain traffic visibility, and each answers a different need. A network tap is a passive or active hardware device inserted into a link that copies every bit, including physical errors. Flow export protocols such as NetFlow and IPFIX send summarized records of conversations rather than packets.
The comparison below shows why mirroring is attractive for quick, flexible access and why taps remain the choice for forensic-grade capture.
| Method | Completeness | Cost and effort | Best fit |
|---|---|---|---|
| Port mirroring | Best effort, may drop under load | Built into managed switches | Troubleshooting, flexible monitoring |
| Network tap | Every frame, including errored ones | Extra hardware and a link outage to install | Security sensors, legal evidence |
| Flow export | Metadata only, no payload | Low bandwidth, needs a collector | Capacity planning, traffic accounting |
Mirroring also differs from simply plugging into an unmanaged switch or a hub. Those devices either do not offer the feature at all or flood traffic indiscriminately, so the defined, filtered copy that a mirror session provides is effectively a privilege of managed switches.
Configuring a mirror session that delivers useful data
A useful mirror session starts with sizing the destination against the sources. A single 1 Gbit/s destination port cannot carry the combined traffic of two busy 1 Gbit/s source ports in both directions, which can reach 4 Gbit/s in total. Choosing a faster destination port, narrowing the sources or applying filters keeps the copy complete.
Engineers also decide whether the analyzer needs VLAN tags preserved. Without tags, traffic from several VLANs arrives mixed together and is hard to interpret. Many platforms strip tags by default on the destination port, so an explicit setting is often required.
| Situation | Recommended setup | Reason |
|---|---|---|
| Short troubleshooting on one server | Local port, both directions | Quick to enable and easy to remove |
| Permanent intrusion detection feed | Tap or dedicated packet broker | Guaranteed completeness under load |
| Analyzer in a central data center | Encapsulated remote mirroring | Copy crosses routed boundaries |
| Busy uplink with many VLANs | VLAN source with ACL filter | Keeps volume below destination capacity |
- Label every session and document it, because forgotten sessions silently consume capacity for years.
- Check the platform limit; many switches support only two to four simultaneous sessions.
- Use traffic filters to mirror only the protocols or hosts under investigation.
Limitations, risks and common mistakes
The most important limitation is that port mirroring is not lossless. When the switch is congested, it drops mirrored copies before production frames, and it typically discards malformed frames such as those with CRC errors before they are ever copied. Timing can also shift, so latency measured from a SPAN port is an approximation rather than a precise value.
Mirroring also creates a security exposure. Anyone with access to the destination port can read unencrypted credentials, voice calls and file transfers, so the analyzer should sit in a controlled location, and session changes should be restricted to authorized administrators and recorded in configuration audits.
| Symptom | Likely cause | Fix |
|---|---|---|
| Capture shows only one side of a flow | Single direction configured | Mirror both ingress and egress |
| Gaps and retransmissions in the capture | Oversubscribed destination port | Filter sources or use a faster port |
| Loop or broadcast storm after setup | Destination port forwarding normally | Dedicate the destination port to the session |
| Traffic from all VLANs looks merged | Tags removed on egress | Enable tag preservation on the destination |
In simple terms
A network switch normally acts like a careful mail sorter: each letter goes only to the person it is addressed to. That is efficient, but it means nobody else can see the mail. Port mirroring tells the switch to make photocopies of the letters going to and from certain people and drop those copies into a special box.
Whoever sits at that box, usually a monitoring computer, can then read the copies to find problems or suspicious activity. The original letters still arrive on time. The catch is that when the sorter gets very busy, some photocopies are skipped, so the copies are good for investigation but not a perfect record.
A practical example
A hospital network team receives complaints that a radiology viewing station takes several seconds to open images from the archive server. Both systems connect to the same 48-port access switch in the imaging department, and nothing in the switch counters looks wrong.
The engineer creates a local mirror session with the archive server port as the source, both directions selected, and an unused 10 Gbit/s port as the destination. A laptop running a packet analyzer captures ten minutes of traffic while a radiologist opens several studies. The capture reveals that each image request first waits for a DNS lookup that times out after five seconds before falling back to a secondary resolver.
After the DNS configuration on the viewing station is corrected, images open in under one second. The engineer then removes the mirror session and records the change, so the destination port does not remain an open window onto patient data traffic.