The rule command creates or modifies an ACL rule in the Layer 2 ACL view.
The undo rule command deletes an ACL rule in the Layer 2 ACL view.
By default, no Layer 2 ACL rule is created.
rule [ rule-id ] [ name rule-name ] { permit | deny } [ [ type { type | arp | ip | ipv6 | mpls | rarp } [ type-mask ] ] | source-mac source-mac [ source-mac-mask ] | destination-mac dest-mac [ dest-mac-mask ] | 8021p 8021p | cvlan-8021p cvlan-8021p | time-range time-name ] *
undo rule rule-id [ to end-rule-id ]
undo rule [ name rule-name ] { permit | deny } [ [ type { type | arp | ip | ipv6 | mpls | rarp } [ type-mask ] ] | source-mac source-mac [ source-mac-mask ] | destination-mac dest-mac [ dest-mac-mask ] | 8021p 8021p | cvlan-8021p cvlan-8021p | time-range time-name ] *
Parameter | Description | Value |
---|---|---|
rule-id |
Specifies the ID of an ACL rule. |
The value is an integer ranging from 0 to 4294967294. |
name rule-name |
Specifies the name of an ACL rule. |
The value is a string of 1 to 32 case-sensitive characters that cannot begin with an underscore (_), spaces not supported. |
permit |
Permits packets that match conditions. |
- |
deny |
Denies packets that match conditions. |
- |
type type |
Matches packets based on a Layer 2 protocol type. If type is not specified, all Ethernet frames are matched. |
The value must be a hexadecimal number and start with 0x. The length ranges from 3 to 6 digits.
|
arp |
Address Resolution Protocol. |
- |
ip |
Any IP protocol. |
- |
ipv6 |
Any IPv6 protocol. |
- |
mpls |
Multiprotocol Label Switching. |
- |
rarp |
Reverse Address Resolution Protocol. |
- |
type-mask |
Specifies the mask for an Ethernet frame protocol. |
The value is a hexadecimal number and starts with 0x. The length ranges from 3 to 6 digits. The type and type-mask parameters together identify the value range of the field. For example, to match all IEEE 802.3 frames (with the value of type less than 0x600), two commands are required: rule { permit | deny } type 0x0000 0xFc00 and rule { permit | deny } type 0x0400 0xFe00. To match IPv4 traffic, run the rule { permit | deny } type 0x0800 0xFFFF command. |
source-mac source-mac |
Specifies a source MAC address. |
The value is a 12-digit hexadecimal number, in the format of H-H-H. Each H is 4 digits. If an H contains fewer than 4 digits, the left-most digits are padded with zeros. For example, e0 is displayed as 00e0. |
source-mac-mask |
Specifies the mask for a source MAC address. |
The value is a 12-digit hexadecimal number, in the format of H-H-H. Each H is 4 digits. If an H contains fewer than 4 digits, the left-most digits are padded with zeros. For example, e0 is displayed as 00e0. |
destination-mac dest-mac |
Specifies a destination MAC address. |
The value is a 12-digit hexadecimal number, in the format of H-H-H. Each H is 4 digits. If an H contains fewer than 4 digits, the left-most digits are padded with zeros. For example, e0 is displayed as 00e0. |
dest-mac-mask |
Specifies a destination MAC address mask. |
The value is in the format of H-H-H. Each H is a 4-digit hexadecimal number. |
time-range time-name |
Specifies a time range during which an ACL rule takes effect. A time range is configured using the time-range command. |
The value is a string of 1 to 32 case-sensitive characters, spaces not supported. |
8021p 8021p |
Specifies the 802.1p priority in an inner VLAN tag. |
The value is an integer ranging from 0 to 7. |
cvlan-8021p cvlan-8021p |
Specifies the 802.1p priority in an inner VLAN tag. |
The value is an integer ranging from 0 to 7. |
undo |
Cancel current setting. |
- |
to end-rule-id |
Specifies an end rule ID for Layer 2 ACL rules in batches. end-rule-id must be greater than rule-id. |
The value is an integer ranging from 0 to 4294967294. |
Usage Scenario
After a Layer 2 ACL is created, run the rule command to add rules to the ACL.
Prerequisites
A Layer 2 ACL has been created using the acl command in the system view. A time range has been configured using the time-range command in the system view if you want to specify a validity period when creating a Layer 2 ACL rule.
Configuration Impact
When specifying an ACL rule ID, note the following:
Precautions
If auto is configured when you run the acl command to create an ACL, you cannot specify a rule ID when creating a rule. The system automatically uses the ACL increment as the start rule ID, and the subsequent rules are numbered by an ACL increment in ascending order.
You must specify the rule ID when deleting a rule. To check rule IDs, run the display acl command. Before deleting an ACL rule, run the display acl command to check whether the ACL rule has been applied to other services. Delete the rule only when it is not applied to other services.<HUAWEI> system-view [~HUAWEI] acl number 4999 [*HUAWEI-acl-L2-4999] rule permit destination-mac 0-0-1 source-mac 0-0-2 type 0x0800