Example for Configuring Local Traffic Mirroring
Networking Requirements
In Figure 2-43, the Technical department and Marketing department of a company use 192.168.1.0/24 and 192.168.2.0/24 respectively to communicate with each other through SwitchA. The monitoring device Server is directly connected to SwitchA.
The packets sent from the Technical department to the Marketing department need to be monitored through the Server.
Configuration Roadmap
- Configure 10GE1/0/2 on SwitchA as the local observing port so that Server can receive mirrored packets.
- Configure a traffic classifier to match the packets sent from the Technical department to the Marketing department, and configure a traffic behavior to mirror packets to the observing port.
- Configure a traffic policy, bind the traffic classifier and traffic behavior to the traffic policy, and apply the traffic policy to the inbound direction of 10GE1/0/1.
Procedure
- Configure an observing port.
# Configure 10GE1/0/2 on SwitchA as the observing port.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] observe-port 1 interface 10ge 1/0/2 [*SwitchA] commit
- Configure a traffic classifier.
# Create a traffic classifier named c1 on SwitchA to match the packets with the source IP address 192.168.1.0 and destination IP address 192.168.2.0/24.
[~SwitchA] acl number 3000 [*SwitchA-acl4-advance-3000] rule permit ip source 192.168.1.0 24 destination 192.168.2.0 24 [*SwitchA-acl4-advance-3000] quit [*SwitchA] traffic classifier c1 [*SwitchA-classifier-c1] if-match acl 3000 [*SwitchA-classifier-c1] commit [~SwitchA-classifier-c1] quit
- Configure a traffic behavior.
# Create a traffic behavior named b1 on SwitchA and configure it.
[~SwitchA] traffic behavior b1 [*SwitchA-behavior-b1] mirroring observe-port 1 [*SwitchA-behavior-b1] commit [~SwitchA-behavior-b1] quit
- Configure a traffic policy and apply the traffic policy to the interface.
# Create a traffic policy named p1 on SwitchA, bind the traffic classifier and traffic behavior to the traffic policy, and apply the traffic policy to the inbound direction of 10GE1/0/1 to monitor packets with the 802.1p priority of 6 sent from HostA.
[~SwitchA] traffic policy p1 [*SwitchA-trafficpolicy-p1] classifier c1 behavior b1 [*SwitchA-trafficpolicy-p1] commit [~SwitchA-trafficpolicy-p1] quit [~SwitchA] interface 10ge 1/0/1 [~SwitchA-10GE1/0/1] traffic-policy p1 inbound [*SwitchA-10GE1/0/1] commit [~SwitchA-10GE1/0/1] quit [~SwitchA] quit
Verifying the Configuration
# View the traffic classifier configuration.
<SwitchA> display traffic classifier c1 Traffic Classifier Information: Classifier: c1 Type: OR Rule(s): if-match acl 3000
# View the traffic policy configuration.
<SwitchA> display traffic policy p1 Traffic Policy Information: Policy: p1 Classifier: c1 Type: OR Behavior: b1 Mirroring observe-port 1
# Check the mirroring configuration.
<SwitchA> display port-mirroring Traffic mirroring: ----------------------------------------------------------------------------- TrafficBehavior ObservePort : Interface ----------------------------------------------------------------------------- b1 1 : 10GE1/0/2 -----------------------------------------------------------------------------
Configuration Files
Configuration file of SwitchA
# sysname SwitchA # observe-port 1 interface 10GE1/0/2 # acl number 3000 rule 5 permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255 # traffic classifier c1 type or if-match acl 3000 # traffic behavior b1 mirroring observe-port 1 # traffic policy p1 classifier c1 behavior b1 precedence 5 # interface 10GE1/0/1 traffic-policy p1 inbound # return