On the network shown in Figure 1, the user packets of VLAN 10 and VLAN 20 are sent to DeviceB through SwitchA. To monitor the upstream and downstream VLAN 10 packets that are sent from SwitchA to DeviceB through interface2, configure interface1 on DeviceB as the observing port for the upstream VLAN packets of interface2 and interface4 on DeviceB as the observing port for the downstream VLAN packets of interface2. Then, configure port mirroring on interface2 to copy all upstream packets of interface2 to interface1 for analysis by HostD and copy all downstream packets of interface2 to interface4 for analysis by HostE.
Device Name |
Interface Number |
Interface IP Address |
Interface MAC Address |
---|---|---|---|
DeviceB |
GE0/1/0 |
10.10.1.1/24 |
- |
DeviceB |
GE0/1/16 |
- |
- |
DeviceB |
GE0/1/17 |
10.1.1.2/24 |
- |
DeviceB |
GE0/1/1 |
10.20.1.1/24 |
- |
The configuration roadmap is as follows:
On DeviceB, configure GE0/1/0 as the observing port for the upstream packets of the mirrored port and GE0/1/1 as the observing port for the downstream packets of the mirrored port.
On DeviceB, configure GE0/1/16 as the mirrored port and enable the port mirroring function.
To complete the configuration, you need the following data:
Interface types and numbers for the observing and mirrored ports
<DeviceB> system-view [~DeviceB] interface gigabitethernet0/1/0 [~DeviceB-GigabitEthernet0/1/0] port-observing observe-index 1 [*DeviceB-GigabitEthernet0/1/0] commit [~DeviceB-GigabitEthernet0/1/0] quit
<DeviceB> system-view [~DeviceB] interface gigabitethernet0/1/1 [~DeviceB-GigabitEthernet0/1/1] port-observing observe-index 2 [*DeviceB-GigabitEthernet0/1/1] commit [~DeviceB-GigabitEthernet0/1/1] quit
[~DeviceB] vlan 10 [*DeviceB-vlan10] commit [~DeviceB-vlan10] quit [~DeviceB] interface gigabitethernet0/1/16 [~DeviceB-GigabitEthernet0/1/16] portswitch [*DeviceB-GigabitEthernet0/1/16] port default vlan 10 [*DeviceB-GigabitEthernet0/1/16] port-mirroring inbound vlan 10 [*DeviceB-GigabitEthernet0/1/16] port-mirroring outbound vlan 10 [*DeviceB-GigabitEthernet0/1/16] commit [~DeviceB-GigabitEthernet0/1/16] quit
[~DeviceB] interface gigabitethernet0/1/16 [~DeviceB-GigabitEthernet0/1/16] port-mirroring to observe-index 1 inbound [*DeviceB-GigabitEthernet0/1/16] port-mirroring to observe-index 2 outbound [*DeviceB-GigabitEthernet0/1/16] commit [~DeviceB-GigabitEthernet0/1/16] quit
After the preceding configurations are complete, the upstream and downstream packets of GE0/1/16 are mirrored to GE0/1/0 and GE0/1/1, respectively.
To view traffic mirroring information, run the ping command or use other traffic generation methods. For example, if SwitchA sends 10 ping packets to GE0/1/16 of DeviceB, HostD is expected to receive all the upstream packets sent from SwitchA.
Check traffic statistics about GE0/1/0 on DeviceB.
<DeviceB> display interface gigabitethernet0/1/0 GigabitEthernet0/1/0 current state : UP Line protocol current state : UP Description:HUAWEI, GigabitEthernet0/1/0 Interface Route Port,The Maximum Transmit Unit is 1500 Internet protocol processing : disabled IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fc7d-a497 The Vendor PN is HFBR-5710L Port BW: 1G, Transceiver max BW: 1G, Transceiver Mode: MultiMode WaveLength: 850nm, Transmission Distance: 550m Loopback:none, full-duplex mode, negotiation: disable, Pause Flowcontrol:Send and Receive Enable Statistics last cleared:never Last 300 seconds input rate: 0 bits/sec, 0 packets/sec Last 300 seconds output rate: 0 bits/sec, 0 packets/sec Input: 107628 bytes, 1016 packets Output: 107628 bytes, 1016 packets Input: Unicast: 0, Multicast: 0 Broadcast: 0, JumboOctets: 0 CRC: 0, Symbol: 0 Overrun: 0 , InRangeLength: 0 LongPacket: 0 , Jabber: 0, Alignment: 0 Fragment: 0, Undersized Frame: 0 RxPause: 0 Output: Unicast: 10, Multicast: 0 Broadcast: 0, Jumbo: 0 Lost: 0, Overflow: 0, Underrun: 0 TxPause: 0
DeviceB configuration file
# sysname DeviceB vlan 10 # interface GigabitEthernet0/1/16 portswitch port default vlan 10 port-mirroring inbound vlan 10 port-mirroring outbound vlan 10 port-mirroring to observe-index 1 inbound port-mirroring to observe-index 2 outbound # interface GigabitEthernet0/1/17 ip address 10.1.1.2 255.255.255.0 # interface GigabitEthernet0/1/0 ip address 10.10.1.1 255.255.255.0 port-observing observe-index 1 # interface GigabitEthernet0/1/1 ip address 10.20.1.1 255.255.255.0 port-observing observe-index 2 # return