< Home

Configuring Port Mirroring

This section provides a sample to configure, modify, and delete port mirroring using the rpc method.

Table 1 Configuring port mirroring

Operation

XPATH

rpc

  • /huawei-span:observe-ports/observe-port/index
  • /huawei-span:observe-ports/observe-port/observe-interfaces/observe-interface
  • /huawei-span:observe-ports/observe-port/observe-interfaces/to-interface
  • /huawei-span:observe-ports/observe-port/rspan-vlan
  • /ietf-interfaces:interfaces/interface/huawei-span:mirrors/mirror/direction
  • /ietf-interfaces:interfaces/interface/huawei-span:mirrors/mirror/observe-ports-index

Data requirement

Item

Data

Description

Physical port for an observing port

GigabitEthernet0/0/3

Indicates that the physical port for an observing port is GigabitEthernet0/0/3.

Observing port index

3

Indicates that the observing port index is 3.

VLAN encapsulated in mirrored packets during the configuration of a Layer 2 remote observing port

10

Indicates that VLAN 10 is encapsulated in mirrored packets during the configuration of a Layer 2 remote observing port.

Physical port for a mirrored port

GigabitEthernet0/0/4

Indicates that the physical port for a mirrored port is GigabitEthernet0/0/4.

Copying packets in the specified direction of a mirrored port to an observing port

inbound

Indicates that incoming packets of a mirrored port are copied to an observing port.

Observing port index bound to a mirrored port

3

Indicates that packets of a mirrored port are copied to the observing port 3.

Request example

# Configure a physical port for an observing port.

Before configuring observing and mirrored ports, you must configure their physical ports. You can also configure their physical ports when configuring observing and mirrored ports. The following example describes how to configure a physical port for an observing port, how to configure an observing port, and how to configure both a mirrored port and its physical port.

<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <if:interfaces xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <if:interface>
          <if:name>GigabitEthernet0/0/3</if:name>
          <if:type xmlns:iana-if-type="urn:ietf:params:xml:ns:yang:iana-if-type">iana-if-type:ethernetCsmacd</if:type>
          <if:enabled>true</if:enabled>
        </if:interface>
      </if:interfaces>
    </config>
  </edit-config>
</rpc>
# Configure a Layer 2 remote observing port.
<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="2" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <span:observe-ports xmlns:span="urn:huawei:params:xml:ns:yang:huawei-span">
        <span:observe-port>
          <span:index>3</span:index>
          <span:observe-interfaces>
            <span:observe-interface>GigabitEthernet0/0/3</span:observe-interface>
          </span:observe-interfaces>
          <span:rspan-vlan>10</span:rspan-vlan>
        </span:observe-port>
      </span:observe-ports>
    </config>
  </edit-config>
</rpc>
# Configure a mirrored port.
<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="3" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <if:interfaces xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <if:interface>
          <if:name>GigabitEthernet0/0/4</if:name>
          <if:type xmlns:iana-if-type="urn:ietf:params:xml:ns:yang:iana-if-type">iana-if-type:ethernetCsmacd</if:type>
          <if:enabled>true</if:enabled>
          <span:mirrors xmlns:span="urn:huawei:params:xml:ns:yang:huawei-span">
            <span:mirror>
              <span:direction>inbound</span:direction>
              <span:observe-ports-index>3</span:observe-ports-index>
            </span:mirror>
          </span:mirrors>
        </if:interface>
      </if:interfaces>
    </config>
  </edit-config>
</rpc>
# Modify the mirrored port configuration. The following example copies outgoing packets of a mirrored port to an observing port.
<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="4" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <if:interfaces xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <if:interface>
          <if:name>GigabitEthernet0/0/4</if:name>
          <if:type xmlns:iana-if-type="urn:ietf:params:xml:ns:yang:iana-if-type">iana-if-type:ethernetCsmacd</if:type>
          <span:mirrors xmlns:span="urn:huawei:params:xml:ns:yang:huawei-span">
            <span:mirror xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="replace">
              <span:direction>outbound</span:direction>
              <span:observe-ports-index>3</span:observe-ports-index>
            </span:mirror>
          </span:mirrors>
        </if:interface>
      </if:interfaces>
    </config>
  </edit-config>
</rpc>
# Cancel configuring GigabitEthernet0/0/4 as a mirrored port.
<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="5" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <if:interfaces xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <if:interface>
        <if:name>GigabitEthernet0/0/4</if:name>
        <if:type xmlns:iana-if-type="urn:ietf:params:xml:ns:yang:iana-if-type">iana-if-type:ethernetCsmacd</if:type>
        <span:mirrors xmlns:span="urn:huawei:params:xml:ns:yang:huawei-span">
          <span:mirror xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="delete">
            <span:direction>outbound</span:direction>
            <span:observe-ports-index>3</span:observe-ports-index>
          </span:mirror>
        </span:mirrors>
      </if:interface>
      </if:interfaces>
    </config>
  </edit-config>
</rpc>
# Modify the observing port configuration. The following example modifies the VLAN encapsulated in mirrored ports to 23. Make sure that no mirrored port on the switch is bound to this observing port before you perform this operation.
<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="6" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <span:observe-ports xmlns:span="urn:huawei:params:xml:ns:yang:huawei-span">
        <span:observe-port>
          <span:index>3</span:index>
          <span:observe-interfaces>
            <span:observe-interface>GigabitEthernet0/0/3</span:observe-interface>
          </span:observe-interfaces>
          <span:rspan-vlan xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="replace">23</span:rspan-vlan>
        </span:observe-port>
      </span:observe-ports>
    </config>
  </edit-config>
</rpc>
# Cancel configuring GigabitEthernet0/0/3 as an observing port. Make sure that no mirrored port on the switch is bound to this observing port before you perform this operation.
<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="7" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <span:observe-ports xmlns:span="urn:huawei:params:xml:ns:yang:huawei-span">
        <span:observe-port xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="delete">
          <span:index>3</span:index>
          <span:observe-interfaces>
            <span:observe-interface>GigabitEthernet0/0/3</span:observe-interface>
          </span:observe-interfaces>
          <span:rspan-vlan>23</span:rspan-vlan>
        </span:observe-port>
      </span:observe-ports>
    </config>
  </edit-config>
</rpc>

Response example

# Sample of successful response
<?xml version='1.0' encoding='UTF-8'?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <ok/>
</rpc-reply>
# Sample of failed response
<?xml version='1.0' encoding='UTF-8'?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <rpc-error>
    <error-app-tag>-1</error-app-tag>
    <error-message>Service process failed.</error-message>
    <error-info>Error on node /ietf-interfaces:interfaces/interface[name="GigabitEthernet0/0/3"]/huawei-span:mirrors/mirror[direction="inbound"]</error-info>
  </rpc-error>
</rpc-reply>
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic