Example for Configuring ACL-based Traffic Statistics Collection
Networking Requirements
In Figure 11-3, the server with the MAC address of 0000-0000-0003 connects to 10GE1/0/1 on the Switch to communicate with other devices. The Switch is required to collect statistics on packets with the source MAC address of 0000-0000-0003.
Configuration Roadmap
- Configure interfaces so that the Switch can connect to the router and server.
- Configure an ACL to match packets with the source MAC address of 0000-0000-0003.
- Configure traffic statistics collection in the inbound direction of 10GE1/0/1 so that the Switch collects statistics on packets with the source MAC address of 0000-0000-0003.
Procedure
- Create VLANs and configure interfaces.
# Create VLAN 20 on the Switch.
<HUAWEI> system-view [~HUAWEI] sysname Switch [*HUAWEI] commit [~Switch] vlan 20 [*Switch-vlan20] commit [~Switch-vlan20] quit
# Configure 10GE1/0/1 as an access interface and 10GE1/0/2 as a trunk interface, and add them to VLAN 20.
[~Switch] interface 10ge 1/0/1 [~Switch-10GE1/0/1] port link-type access [*Switch-10GE1/0/1] port default vlan 20 [*Switch-10GE1/0/1] quit [*Switch] interface 10ge 1/0/2 [*Switch-10GE1/0/2] port link-type trunk [*Switch-10GE1/0/2] port trunk allow-pass vlan 20 [*Switch-10GE1/0/2] quit [*Switch] commit
# Create VLANIF 20 and set its IP address to 10.10.10.2/24.
[~Switch] interface vlanif 20 [*Switch-Vlanif20] ip address 10.10.10.2 24 [*Switch-Vlanif20] quit [*Switch] commit
Configure IP address 10.10.10.1/24 for the router interface connected to the Switch.
- Configure an ACL.
# Create ACL 4000 (Layer 2 ACL) on the Switch to match packets with the source MAC address of 0000-0000-0003.
[~Switch] acl 4000 [*Switch-acl-L2-4000] rule permit source-mac 0000-0000-0003 ffff-ffff-ffff [*Switch-acl-L2-4000] quit [*Switch] commit
- Configure traffic statistics collection.
# Configure ACL-based traffic statistics collection in the inbound direction of 10GE1/0/1.
[~Switch] interface 10ge 1/0/1 [~Switch-10GE1/0/1] traffic-statistics acl 4000 inbound [*Switch-10GE1/0/1] quit [*Switch] commit
- Verify the configuration.
# Check the traffic statistics.
[~Switch] display traffic-statistics interface 10ge 1/0/1 inbound Inbound(IPv4): -------------------------------------------------------------------------------- Slot: 1 Item Packets Bytes pps bps ------------------------------------------------------------------------------- Matched 262685 26268500 2000 1600744 Passed 262685 26268500 2000 1600744 Dropped 0 0 0 0 Filter 0 0 0 0 CAR 0 0 0 0 -------------------------------------------------------------------------------
Configuration Files
Switch configuration file
# sysname Switch # vlan batch 20 # acl number 4000 rule 5 permit source-mac 0000-0000-0003 # interface Vlanif20 ip address 10.10.10.2 255.255.255.0 # interface 10GE1/0/1 port default vlan 20 traffic-statistics acl 4000 inbound # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # return