---
title: Mirror Configuration
slug: enterprise-v5p2/mirror-configuration
description: network management and monitoring
createdAt: 2025-11-14T03:58:40.683Z
---

### <font color="#1d50a2">show mirror session</font>

**\[Command]**
**show mirror session** **\[** *number* **]**

**\[Purpose]**
Show configuration related to mirror

**\[View]**
System view

**\[Use Cases]**

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

### <font color="#1d50a2">mirror session</font>

**\[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]**

| **Parameter**                                       | **Description**                                                                                                           |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| *session\_id*                                       | mirror session ID, value range: 1-6                                                                                       |
| *port\_name*                                        | Interface 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]**

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

### <font color="#1d50a2">mirror session rspan</font>

**\[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]**

| **Parameter**                               | **Description**                                                                |
| ------------------------------------------- | ------------------------------------------------------------------------------ |
| *id*                                        | Mirror session ID, valid range: 1-6.                                           |
| *port\_name*                                | Interface name, supports VLAN interfaces and Ethernet interfaces.              |
| **direction \{rx\|tx\|both}**               | Traffic direction to be mirrored.rx: Inbound direction.tx: Outbound direction. |
| **both**                                    | Both directions, mirroring all traffic.                                        |
| **\{src-ethernet\|src-vlan}**               | Interface to be mirrored.                                                      |
| **&#x7B;dst-ethernetdst-link-aggregation}** | Destination interface for mirrored traffic.                                    |
| *vlan\_id*                                  | RSPAN 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]**

```plaintext
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
```

### <font color="#1d50a2">mirror session erspan</font>

**\[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]**

| **Parameter**                  | **Description**                                                                |
| ------------------------------ | ------------------------------------------------------------------------------ |
| *id*                           | Mirror 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\::B* | Source IP for GRE encapsulation.                                               |
| **gre-dst-ip** *A.B.C.D/A\::B* | Destination IP for GRE encapsulation.                                          |
| *vrf\_name*                    | VRF 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]**

```plaintext
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
```

