---
title: Network Monitoring Configuration Guide
slug: aidc/network-monitoring-configuration-guide
description: Network Management and Monitoring Configuration Guide
createdAt: 2025-11-12T12:13:54.334Z
---

# <font color="#1d50a2">MIRROR</font>

## <font color="#1d50a2">Introduction</font>

Mirror is a network management technology commonly used for network detection, traffic analysis, and troubleshooting. With the mirroring function, traffic at one or more ports on a switch can be copied to the destination port of the mirror and sent out for analysis and monitoring of the traffic on the mirrored port.

## <font color="#1d50a2">Basic Concepts</font>

The switch currently supports two mirroring methods: SPAN and ERSPAN.

<font color="#1d50a2">**SPAN**</font>

SPAN refers to a mirroring configuration where the source and destination ports are on the same switch. In this configuration, the switch copies the data traffic from the specified source port (mirror source) to another port (destination port) on the same switch and forwards it. The source and destination ports of this mirror are both on the same switch, making the configuration relatively simple and not involving device network connections. Support mirroring traffic from one or more source ports to the destination port.

<font color="#1d50a2">**ERSPAN**</font>

ERSPAN refers to a mirroring configuration where the source and destination ports are located on different switches. In this configuration, the switch replicates the data traffic from the specified source port to the destination port on the remote switch through a layer three protocol. This type of image needs to be forwarded through an IP address, and the configuration is relatively complex. Remote mirroring needs to be used in conjunction with ACL policies.
Mirror v4 ACL match field support is as follows:

<font color="#1d05a2">Table 1 Mirror v4 ACL match fields</font>

| **Fields**                        | **Description**                                                                |
| --------------------------------- | ------------------------------------------------------------------------------ |
| **outer-vlan** *outer-vlan*       | range \[1,4094]                                                                |
| **source-port** *sport*           | range 0-65535                                                                  |
| **destination-port** *dport*      | range 0-65535                                                                  |
| **tcp-flags** *tcp-flags*         | range 0-63                                                                     |
| **source-ip** *sip*               | A.B.C.D(/M)                                                                    |
| **destination-ip** *dip*          | A.B.C.D(/M)                                                                    |
| **icmp-type** *icmp-type*         | range 0-16                                                                     |
| **icmp-code** *icmp-code*         | range 0-5                                                                      |
| **dscp** *dscp*                   | range 0-63                                                                     |
| **ip-type** *ip-type*             | any/ip/non\_ip/ipv4any/non\_ipv4/ipv6any/non\_ipv6/arp/arp\_request/arp\_reply |
| **bth-opcode** *bth-opcode*       | range 0-255                                                                    |
| **aeth-syndrome** *aeth-syndrome* | range 0-255                                                                    |
| **outer-vlan** *outer-vlan*       | range \[1,4094]                                                                |

Mirror v6 ACL match field support is as follows:

<font color="#1d05a2">Table 2 Mirror v6 ACL match fields</font>

| **Fields**                        | **Description** |
| --------------------------------- | --------------- |
| **source-ipv6** *sipv6*           | X\:X\::X\:X(/M) |
| **destination-ipv6** *dipv6*      | X\:X\::X\:X(/M) |
| **bth-opcode** *bth-opcode*       | range 0-255     |
| **aeth-syndrome** *aeth-syndrome* | range 0-255     |

## <font color="#1d50a2">SPAN</font><font color="#1d50a2"> Configuration</font>

When configuring span, it supports configuring one or more source ports for simultaneous mirroring, but supports configuring one destination port.

<font color="#1d05a2">Table 3 Configure SPAN</font>

| **Purpose**                         | **Commands**                                        | **Description**                                                                          |
| ----------------------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| Enter global configuration view     | **configure terminal**                              | -                                                                                        |
| Create span                         | **mirror session** *session-id* **type span**       | The range of session id is from 1 to 63.                                                 |
| Configure the span source port      | **source interface ethernet** *interface-name*      | -                                                                                        |
| Configure the span destination port | **destination interface ethernet** *interface-name* | -                                                                                        |
| Configure mirror direction          | **direction** \{**in**\|**out**\|**both**}          | The default is **both**, which means that both the inlet and outlet traffic are mirrored |
| commit                              | **commit**                                          | After the configuration is completed, **commit** needs to be executed to take effect.    |

## <font color="#1d50a2">ERSPAN </font><font color="#1d50a2">Configuration</font>

<font color="#1d05a2">Table 4 Configure ERSPAN</font>

| **Purpose**                                              | **Commands**                                                                              | **Description**                                                                      |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| Enter global configuration view                          | **configure terminal**                                                                    | -                                                                                    |
| Create erspan                                            | **mirror session** *session-id* **type erspan**                                           | The range of session id is from 1 to 63.                                             |
| Configure erspan source IP                               | **origin ip address** *A.B.C.D*                                                           | -                                                                                    |
| Configure erspan destination IP                          | **destination ip address** *A.B.C.D*                                                      | -                                                                                    |
| Configure TTL value for erspan tunnel                    | **ip ttl** *ttl\_value*                                                                   | The range of TTL value is 1-255.                                                     |
| Configure DSCP value for erspan tunnel                   | **ip dscp** *dscp\_value*                                                                 | DSCP value range is 0-63.                                                            |
| (Optional)Configure the queue bound to the erspan tunnel | **queue** *queue\_value*                                                                  | Queue ID, with a value range of 0-7                                                  |
| (Optional)Configure erspan tunnel type                   | **gre\_type** *type*                                                                      | GRE type, format 0xHHHH                                                              |
| commit                                                   | **commit**                                                                                | After the configuration is completed, **commit** needs to be executed to take effect |
| Exit mirror configuration view                           | **exit**                                                                                  | -                                                                                    |
| Create mirror ACL table and enter configuration view     | **access-list** *table\_name* **mirror ingress**                                          | -                                                                                    |
| Bind interface                                           | **bind interface** \{\{ **ethernet**\|**link-aggregation**} *interface-name* \| **all**}} | -                                                                                    |
| Configure mirror rules                                   | **rule** *rule\_id* *rule* **action mirror-session** *session-id*                         | *rule* is the match fields, and the supported fields are detailed in                 |

## <font color="#1d50a2">Display and Maintenance</font>

<font color="#1d05a2">Table 5 Display and Maintenance</font>

| **Purpose**               | **Commands**    | **Description** |
| ------------------------- | --------------- | --------------- |
| show mirror configuration | **show mirror** | -               |

## <font color="#1d50a2">Typical Configuration Example</font>

1. Network Requirements
   A certain PC1, with an IP of 10.0.0.2, passes through a switch and achieves mutual access with PC2, with an IP of 20.0.0.2. Now it is necessary to monitor the traffic sent by PC1 to PC2 on the server, and obtain the traffic sent by PC1 without affecting the business
2. Topology

::Image[]{src="https://app.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/-G4-Rzj-ovYtXOEumGdU5-20251201-075550.png" size="60" width="345" height="161" position="center" caption="Figure 3 Topology Of Erspan" showCaption="true"}

3. Procedure

\#Configure interface IP address

```plaintext
sonic(config)# interface ethernet 0/60
sonic(config-if-0/60)# ip address 60.0.0.1/24
```

\#Configure erspan

```plaintext
sonic# configure
sonic(config)# mirror session 1 type erspan
sonic(config-erspan-mirror-1)# origin ip address 60.0.0.1
Please enter 'commit' to make mirror session command take effect
sonic(config-erspan-mirror-1)# destination ip address 60.0.0.2
Please enter 'commit' to make mirror session command take effect
sonic(config-erspan-mirror-1)# ip ttl 40
Please enter 'commit' to make mirror session command take effect
sonic(config-erspan-mirror-1)# ip dscp 24
Please enter 'commit' to make mirror session command take effect
sonic(config-erspan-mirror-1)# commit
```

\#Configure ACL policy

```plaintext
sonic# configure
sonic(config)# access-list test1 mirror ingress
sonic(config-mirror-acl-test1)# bind interface ethernet 0/0
sonic(config-mirror-acl-test1)# rule 1 source-ip 10.0.0.2 action mirror-session 1
```

**Server**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/24
sonic(config-if-0/24)# ip address 60.0.0.2
```

4. Configuration verification

```plaintext
sonic# show mirror
ERSPAN Sessions
  Name  Status    SRC IP    DST IP    GRE      DSCP    TTL  Queue    Policer    Monitor Port    SRC Port    Direction
------  --------  --------  --------  -----  ------  -----  -------  ---------  --------------  ----------  -----------
     1  active    60.0.0.1  60.0.0.2             24     40                      0/60
SPAN Sessions
Name    Status    DST Port    SRC Port    Direction    Queue    Policer
------  --------  ----------  ----------  -----------  -------  ---------
sonic# show acl rule
Table    Rule      Priority  Action             Match
-------  ------  ----------  -----------------  ----------------
test1    rule_1        1001  MIRROR INGRESS: 1  SRC_IP: 10.0.0.2
```

5. Traffic verification
   PC1 streams to PC2 and receives mirrored traffic on the server, which is the traffic sent by PC1.

# <font color="#1d50a2">sFlow</font>

## <font color="#1d50a2">Introduction</font>

sFlow (Sampled Flow) is a network traffic monitoring technology based on packet sampling, mainly used for statistical analysis of network traffic.

## <font color="#1d50a2">Basic Concepts</font>

<font color="#1d50a2">**sFlow System**</font>

The sFlow system consists of several sFlow Agents (embedded in forwarding device such as switch or router) and a core sFlow Collector, as shown in figure below. sFlow Agents use specific sampling techniques to obtain statistics and packet information about the interface. The sFlow packets are encapsulated in UDP packets and sent to the designated sFlow Collector for analysis by the Collector when the buffer holding the sFlow packets is full or when the sFlow packet delivery timer (timer interval is fixed at 1 second) times out, helping network administrators to manage the network traffic of entire site (usually an enterprise site) more effectively by generating flow views or reports to display the results.

::Image[]{src="https://app.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/gTNOfMfgyW2W7FVzoIRTb-20251201-075642.png" size="60" width="374" height="85" position="center" caption="Figure 4 sFlow Topology" showCaption="true"}

::Image[]{src="https://app.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/_-whyHlSoBrVwO0HW6dlV-20251201-075744.png" size="70" width="539" height="115" position="center" caption="Figure 5 sFlow System" showCaption="true"}

<font color="#1d50a2">**sFlow Sample**</font>

sFlow Agent provides two sampling methods for users to analyze network traffic conditions from different perspectives, namely Flow sampling and Counter sampling.

- Flow sample is used by the sFlow Agent device to sample and analyze packets on a specified interface according to a specific sampling direction and sampling ratio, and is used to obtain information about the data content of the packets. This sampling method focuses on the details of the flow so that it can monitor and analyze popular behavior on the network.
- Counter sampling is the sFlow Agent device that periodically obtains traffic statistics on interfaces. In contrast to Flow sampling, Counter sampling focuses only on the number of flows on interfaces and not on the details of the flows.

## <font color="#1d50a2">Default sFlow Configuration</font>

The default configuration of sFlow is shown in the table below.

<font color="#1d05a2">Table 6 sFlow Default Configuration</font>

| **Parameters**              | **Default value**                                                                                              |
| --------------------------- | -------------------------------------------------------------------------------------------------------------- |
| sFlow Agent information     | The Agent automatically selects the IP of the routing out interface to the Collector as the source IP address. |
| sFlow Collector information | Not configured.                                                                                                |
| sFlow sampling rate         | 10000                                                                                                          |

## <font color="#1d50a2">sFlow Configuration</font>

<font color="#1d05a2">Table 7 Overview of sFlow Configuration Tasks</font>

| **Configuration Tasks**                                    | **Description** |
| ---------------------------------------------------------- | --------------- |
| <font color="#1d50a2">Enable sFlow</font>                  | Optional        |
| <font color="#1d50a2">Configure the sFlow Collector</font> | Optional        |
| <font color="#1d50a2">Configure sFlow for Interface</font> | Optional        |

### <font color="#1d50a2">**Enable sFlow**</font>

<font color="#1d05a2">Table 8 Enable sFlow</font>

| **Purpose**                     | **Commands**           | **Description** |
| ------------------------------- | ---------------------- | --------------- |
| Enter global configuration view | **configure terminal** | -               |
| Enable sFlow                    | **sflow enable**       | -               |

:::hint{type="success"}
**NOTE:**&#x20;
When sFlow is enabled, the interface sFlow is all enabled by default.
:::

### <font color="#1d50a2">**Configure the sFlow Collector**</font>

- sFlow needs to be enabled before configuration
- The source interface and source IP of sFlow Collector cannot be configured at the same time.

<font color="#1d05a2">Table 9 Configure the sFlow Collector</font>

| **Purpose**                                   | **Commands**                                                                                 | **Description**                                                                                                                                    |
| --------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enter global configuration view               | **configure terminal**                                                                       | -                                                                                                                                                  |
| Configure the sFlow Collector                 | **sflow collector** *collector-name ip-address* \[**VRF** *vrf* \|*dst\_port*]               | *ip-address*: collector's destination IP*vrf*: specifies the VRF where the sampling interface is located*dst\_port*: collector's destination port. |
| Configure source IP of sFlow Collector        | **sflow collector** *collector-name* **source** \{*A.B.C.D*\|*A\::B*}                        | -                                                                                                                                                  |
| Configure source interface of sFlow Collector | **sflow collector** *collector-name* **source-interface** *interface-type* *interface\_name* | *interface-type*: optional parameters: **vlan, ethernet, loopback, link-aggregation, mgmt**.                                                       |
| Configure the polling interval                | **sflow polling-interval** *time*                                                            | Sets the counter sample interval for sampling.*time*: unit s, range 6-3600.                                                                        |
| Set sFlow sampling rate                       | **sflow sample-rate** *rate*                                                                 | *rate*: indicates how many packets are sampled once, range 8000-1000000, and the default value is 10000.                                           |

### <font color="#1d50a2">**Configure sFlow for Interface**</font>

<font color="#1d05a2">Table 10 Interface sFlow Configuration</font>

| **Purpose**                     | **Commands**                            | **Description**                                                                                          |
| ------------------------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Enter global configuration view | **configure terminal**                  | -                                                                                                        |
| Enter Ethernet interface view   | **interface ethernet** *interface-name* | -                                                                                                        |
| Disable sFlow for interface     | **sflow disable**                       | -                                                                                                        |
| Set sFlow sampling rate         | **sflow sample-rate** *rate*            | *rate*: indicates how many packets are sampled once, range 8000-1000000, and the default value is 10000. |

## <font color="#1d50a2">Display and Maintenance</font>

<font color="#1d05a2">Table 10 sFlow Display and Maintenance</font>

| **Purpose**                     | **Commands**                                      | **Description** |
| ------------------------------- | ------------------------------------------------- | --------------- |
| Show global configuration       | **show sflow**                                    | -               |
| Display interface configuration | **show sflow interface ethernet** *interface-num* | -               |

## <font color="#1d50a2">Typical Configuration Example</font>

### <font color="#1d50a2">Configure the sFlow Collector</font>

1. Network Requirements
   TC1 and TC2 communicate via Switch. Management and maintenance personnel require viewing traffic information, forwarding status on Interface 0/0, and the overall operational status of the device. This enables timely detection of abnormal traffic, thereby ensuring normal and stable network operation.
2. Topology

::Image[]{src="https://app.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/ajeoAHpC4JTFIVd6nO_f8-20251201-075835.png" size="70" width="345" height="161" position="center" caption="Figure 6 sFlow Topology" showCaption="true"}

3. Procedure

\#Configure the interface IP

**DUT**

```plaintext
sonic# config terminal
sonic(config)# interface ethernet 0/0
sonic(config-if-0/0)# ip address 10.0.0.2/24
```

**Server**

```plaintext
sonic# config terminal
sonic(config)# interface ethernet 0/0
sonic(config-if-0/0)# ip address 10.0.0.3/24
```

\#Configure sFlow Collector on Switch

```plaintext
sonic# config terminal
sonic(config)# sflow enable
sonic(config)# sflow collector 1 10.0.0.3 6345
```

\#Configure the polling interval (optional)

```plaintext
sonic# config terminal
sonic(config)# sflow polling-interval 30
```

\#Configure the sampling rate (optional)

```plaintext
sonic# config terminal
sonic(config)# interface ethernet 0/0
sonic(config-if-0/0)# sflow sample-rate 80000
```

4. Verify the configuration.

\#Configuration verification.

```plaintext
sonic(config)# show sflow
sFlow Global Information:
      sFlow Admin State: up
      sFlow Polling Interval: default
      sFlow AgentID: default
      1 Collectors configured:
        Name: 1 IP addr: 10.0.0.3 UDP port: 6345
sonic# show sflow interface ethernet 0/0
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| 0/0         |   up          |           80000 |
+-------------+---------------+-----------------+
```

\#Flow verification.

TC1 streams to TC2 at wire speed, capturing packets on the corresponding interface of Server. Server can receive sflow packets with destination port 6345.

