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(config)# mirror session 1 span
sonic(config-span-mirror-1)# src-ethernet 4
sonic(config-span-mirror-1)# dst-ethernet 7
sonic(config-span-mirror-1)#

[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(config)# mirror session 1 rspan
sonic(config-rspan-mirror-1)# src-ethernet 4
sonic(config-rspan-mirror-1)# dst-ethernet 7
sonic(config-rspan-mirror-1)# remote-vlan 100

[Command]

mirror session* id erspan [direction {rx|tx|both}] {src-ethernet|src-vlan} port-namesrc-ip ip-addressdst-ip ip-address***[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-7
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
ip-addressSource IP address and destination IP address for GRE encapsulation
vrf-nameVRF for GRE encapsulation

[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.

[Comment] 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]

Terminal window
sonic# configure
sonic(config)# mirror session 1 erspan
sonic(config-erspan-mirror-1)# src-ethernet 1
sonic(config-erspan-mirror-1)# src-ip 10.1.5.1
sonic(config-erspan-mirror-1)# dst-ip 20.1.5.1
sonic(config-erspan-mirror-1)# exit