Example for Using User-Defined ACLs to Filter the Specified Packets
Networking Requirements
As shown in Figure 3-8, users are connected to the Switch through 10GE1/0/1. The Switch needs to discard certain packets sent by users (4 bytes behind the 14th byte in the packet match 0x0180C200).
Configuration Roadmap
The following configurations are performed on the Switch. The configuration roadmap is as follows:
- Configure a user-defined ACL and an ACL-based traffic classifier to filter certain packets (4 bytes behind the 14th byte in the packet match 0x0180C200).
- Configure a traffic behavior to discard the packets matching the ACL.
- Configure and apply a traffic policy to make the ACL and traffic behavior take effect.
Procedure
- Configure an ACL.
# Configure a user-defined ACL.
<HUAWEI> system-view [~HUAWEI] sysname Switch [*Switch] acl 5000 [*Switch-acl-user-5000] rule deny l2-head 0x0180C200 0xFFFFFFFF 14 [*Switch-acl-user-5000] quit
- Creating a traffic classifier based on the user-defined
ACL.
# Configure the traffic classifier tc1 to classify packets that match ACL 5000.
[*Switch] traffic classifier tc1 [*Switch-classifier-tc1] if-match acl 5000 [*Switch-classifier-tc1] quit
- Configure a traffic behavior.
# Configure the traffic behavior tb1 to reject packets.
[*Switch] traffic behavior tb1 [*Switch-behavior-tb1] deny [*Switch-behavior-tb1] quit
- Configure a traffic policy.
# Configure a traffic policy, and bind the traffic classifier and traffic behavior to the traffic policy.
[*Switch] traffic policy tp1 [*Switch-trafficpolicy-tp1] classifier tc1 behavior tb1 [*Switch-trafficpolicy-tp1] quit
- Apply the traffic policy to an interface.
# Apply the traffic policy to the inbound direction of 10GE1/0/1.
[*Switch] interface 10ge 1/0/1 [*Switch-10GE1/0/1] traffic-policy tp1 inbound [*Switch-10GE1/0/1] quit [*Switch] commit
- Verify the configuration.
# Check the ACL configuration.
[~Switch] display acl 5000 User ACL 5000, 1 rule ACL's step is 5 rule 5 deny 0x0180c200 0xffffffff 14 (0 times matched)
# Check the traffic classifier configuration.
[~Switch] display traffic classifier tc1 Traffic Classifier Information: Classifier: tc1 Type: OR Rule(s): if-match acl 5000
# Check the traffic policy configuration.
[~Switch] display traffic policy tp1 Traffic Policy Information: Policy: tp1 Classifier: tc1 Type: OR Behavior: tb1 Deny
Configuration Files
# Switch configuration file
#
sysname Switch
#
acl number 5000
rule 5 deny 0x0180c200 0xffffffff 14
#
traffic classifier tc1 type or
if-match acl 5000
#
traffic behavior tb1
deny
#
traffic policy tp1
classifier tc1 behavior tb1 precedence 5
#
interface 10GE1/0/1
traffic-policy tp1 inbound
#
return