Skip to content
Ask AI

Mirror Configuration

[Command] show mirror session [ number ]

[Purpose] Show configuration related to mirror

[View] System view

[Use Cases]

sonic# show mirror session
+--------------+------------------+-------------+------+-----------+
| Session Name | Destination Port | Source Port | Type | Direction |
+==============+==================+=============+======+===========+
| 1 | Ethernet1 | Ethernet2 | SPAN | BOTH |
+--------------+------------------+-------------+------+-----------+

[Command] mirror session session_id span [direction {rx|tx|both}] {src-ethernet|src-vlan} port_name {dst-ethernet|dst-vlan|dst-link-aggregation} port_name no mirror session id span

[Purpose] Create a mirror session or add port to the mirror session

[Parameter]

ParameterDescription
session_idmirror session ID, value range: 1-6
port_nameInterface name, support VLAN interface and Ethernet interface
direction {rx|tx|both}Direction of traffic to be mirroredrx is the entry directiontx is the outgoing directionboth is mirror in both directions
{src-ethernet|src-vlan}The interface on which traffic needs to be mirrored
{dst-ethernet|dst-vlan|dst-link-aggregation}The destination interface for mirrored traffic

[View] System configuration view

[Use Cases]

sonic# configure
sonic(config)# mirror session 1 span direction both
sonic(config)# mirror session 1 span src-ethernet 1 dst-ethernet 20

[Command] mirror session id rspan [direction {rx|tx|both}] {src-ethernet|src-vlan} port_name {dst-ethernet|dst-link-aggregation} port_name remote vlan vlan_id no mirror session id rspan

[Purpose] Create a remote mirroring session or add source/destination interfaces to an existing mirroring session

[Parameter]

ParameterDescription
idMirror session ID, valid range: 1-6.
port_nameInterface name, supports VLAN interfaces and Ethernet interfaces.
direction {rx|tx|both}Traffic direction to be mirrored.rx: Inbound direction.tx: Outbound direction.
bothBoth directions, mirroring all traffic.
{src-ethernet|src-vlan}Interface to be mirrored.
{dst-ethernetdst-link-aggregation}Destination interface for mirrored traffic.
vlan_idRSPAN dedicated VLAN for mirroring traffic

[View] System view

[Usage Scenario] RSPAN’s main function is to copy the traffic of ports on one switch to an analysis port on another remote switch, allowing network administrators to monitor and analyze traffic on the remote switch without direct access to the target device. Remote Switched Port Analyzer (RSPAN) builds upon local port mirroring by encapsulating packets with a specified VLAN, transmitting them through intermediate devices, and ultimately reaching the destination switch. The VLAN is then stripped off at the destination switch before being forwarded to the backend analyzer.

[Notes] As the RSPAN dedicated VLAN, “remote vlan” is not recommended for other purposes. The destination interface needs to be added to the “remote vlan.”

[Use Cases]

sonic# configure
sonic(config)# mirror session 1 rspan direction rx
sonic(config)# mirror session 1 rspan src-ethernet 1 dst-ethernet 20 remote vlan 200

[Command] mirror session id erspan [direction {rx|tx|both}] {src-ethernet|src-vlan} port_name gre-src-ip A.B.C.D/A::B gre-dst-ip A.B.C.D/A::B [gre-vrf vrf_name ] no mirror session id erspan

[Purpose] Create a remote mirroring session and add the source and destination addresses for GRE encapsulation

[Parameter]

ParameterDescription
idMirror session ID, valid range: 1-6.
direction {rx|tx|both}Traffic direction to be mirrored.rx: Inbound direction.tx: Outbound direction.
{src-ethernet|src-vlan}Interface to be mirrored.
gre-src-ip A.B.C.D/A::BSource IP for GRE encapsulation.
gre-dst-ip A.B.C.D/A::BDestination IP for GRE encapsulation.
vrf_nameVRF for GRE encapsulation, with the default VRF set to “default”

[View] System view

[Usage Scenario] ERSPAN is a Layer 3 remote mirroring technology that duplicates packets from specified ports or VLANs. It sends the duplicated packets to a remote data monitoring device through a GRE tunnel, allowing users to analyze these packets using the monitoring device for network monitoring and troubleshooting.

[Notes] To configure encapsulation parameters for Layer 3 remote mirroring, you only need to specify the mirror source and destination port on the source device. Additionally, all devices must have a unicast routing protocol configured, ensuring a seamless Layer 3 network between the devices.

[Use Cases]

sonic# configure
sonic(config)# mirror session 1 erspan direction rx gre-src-ip 10.1.1.1 gre-dst-ip 30.1.1.2 src-vlan 20