Example for Using a Layer 2 ACL to Configure a Traffic Classifier
Networking Requirements
As shown in Figure 3-7, the Switch that functions as the gateway is connected to the server leased by the tenant. An ACL needs to be configured to prevent the packets with the source MAC address 00e0-f201-0101 and the destination MAC address 0260-e207-0002 from passing through.
Configuration Roadmap
The configuration roadmap is as follows:
- Configure an ACL.
- Configure a traffic classifier.
- Configure a traffic behavior.
- Configure a traffic policy.
- Apply the traffic policy to an interface.
Procedure
- Configure an ACL.
# Configure a Layer 2 ACL.
<HUAWEI> system-view [~HUAWEI] sysname Switch [*HUAWEI] commit [~Switch] acl 4000 [*Switch-acl-L2-4000] rule deny source-mac 00e0-f201-0101 ffff-ffff-ffff destination-mac 0260-e207-0002 ffff-ffff-ffff [*Switch-acl-L2-4000] quit
- Configure a traffic classifier based on the ACL.
# Configure the traffic classifier tc1 to classify packets that match ACL 4000.
[*Switch] traffic classifier tc1 [*Switch-classifier-tc1] if-match acl 4000 [*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 the traffic policy.
# Configure the traffic policy tp1, and bind tc1 and tb1 to the traffic policy.
[*Switch] traffic policy tp1 [*Switch-trafficpolicy-tp1] classifier tc1 behavior tb1 [*Switch-trafficpolicy-tp1] quit
- Apply the traffic policy.
# Apply the traffic policy tp1 to 10GE2/0/1.
[*Switch] interface 10ge 2/0/1 [*Switch-10GE2/0/1] traffic-policy tp1 inbound [*Switch-10GE2/0/1] commit [~Switch-10GE2/0/1] quit
- Verify the configuration.
# Check the configuration of the ACL.
[~Switch] display acl 4000 L2 ACL 4000, 1 rule ACL's step is 5 rule 5 deny source-mac 00e0-f201-0101 destination-mac 0260-e207-0002 (0 times matched)
# Check the configuration of the traffic classifier.
[~Switch] display traffic classifier tc1 Traffic Classifier Information: Classifier: tc1 Type: OR Rule(s): if-match acl 4000
# Check the configuration of the traffic policy.
[~Switch] display traffic policy tp1 Traffic Policy Information: Policy: tp1 Classifier: tc1 Type: OR Behavior: tb1 Deny
[~Switch] display traffic-policy applied-record Total records : 1 ------------------------------------------------------------------------------- Policy Name/Name Apply Parameter Slot State ------------------------------------------------------------------------------- tp1 10GE2/0/1(IN) 2 success -------------------------------------------------------------------------------
Configuration Files
# Switch configuration file
# sysname Switch # acl number 4000 rule 5 deny source-mac 00e0-f201-0101 destination-mac 0260-e207-0002 # traffic classifier tc1 type or if-match acl 4000 # traffic behavior tb1 deny # traffic policy tp1 classifier tc1 behavior tb1 precedence 5 # interface 10GE2/0/1 traffic-policy tp1 inbound # return