---
title: Mirror Configuration
slug: routing/mirror-configuration
createdAt: 2025-12-04T03:54:13.433Z
---

##

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

**\[Command]**
**show mirror**

**\[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 *name*</font>

**\[Command]**
**mirror session *id* span \[direction \{rx|tx|both}] \{src-ethernet|src-vlan} *port-name* &#x7B;dst-ethernet} *port-name***
**no mirror session *id* span**

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

**\[Parameter]**

| **Parameter**               | **Description**                                               |
| --------------------------- | ------------------------------------------------------------- |
| *id*                        | mirror session ID, value range: 1-6                           |
| *interface-name*            | Interface name, support VLAN interface and Ethernet interface |
| *direction \{rx\|tx\|both}* | Direction of traffic to be mirrored                           |
| rx                          | the entry direction                                           |
| *tx*                        | the outgoing direction                                        |
| *both*                      | mirror in both directions                                     |
| *\{src-ethernet\|src-vlan}* | The interface on which traffic needs to be mirrored           |
| &#x7B;dst-ethernet}         | The destination interface for mirrored traffic                |

**\[View]**
System configuration view

**\[Use Cases]**

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

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

**\[Command]**
**mirror session *id* erspan \[direction \{rx|tx|both}] &#x7B;src-ethernet} *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.                                              |
| *&#x7B;src-ethernet}*       | Interface to be mirrored.                                        |
| *gre-src-ip*                | Source IP for GRE encapsulation                                  |
| *gre-dst-ip*                | 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. 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.It should be noted that ERSPAN needs to be configured after the destination IP actually takes effect. For example, if the destination IP corresponds to a static ARP, then the static ARP needs to be configured first before configuring the ERSPAN function.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# mirror session 1 erspan direction rx src-ethernet 3 gre-src-ip 10.1.1.1 gre-dst-ip 30.1.1.2
```

