This section provides a sample to configure, modify, and delete port mirroring using the rpc method.
Operation |
XPATH |
---|---|
rpc |
|
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. |
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>
<?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>
<?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>
<?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>
<?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>
<?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>
<?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>
<?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>
<?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>