If you need to configure a time-based ACL, create a time range and associate the time range with the ACL rules. For details, see (Optional) Creating a Time Range in Which an ACL Takes Effect.
Advanced ACLs give you greater flexibility and functionality than basic ACLs, allowing you to filter packets more accurately. For example, with advanced ACLs, you can define rules to filter IPv4 packets based on a range of criteria, including source IP addresses, destination IP addresses, IP protocol types, TCP source/destination port numbers, UDP source/destination port numbers, fragment information, and time ranges.
The system view is displayed.
Run the acl [ number ] acl-number [ match-order { auto | config } ] command to create a numbered advanced ACL (3000-3999) and enter the advanced ACL view.
Run the acl name acl-name { advance | acl-number } [ match-order { auto | config } ] command to create a named advanced ACL and enter the advanced ACL view.
By default, no ACL exists on the device.
If the parameter match-order is not specified when you create an ACL, the default matching order config is used. For details about the ACL matching order, see ACL Matching.
The default step of a created ACL is 5. If the default step cannot meet your ACL configuration requirements, you can change the step value. For details about the step, see ACL Increment; for configuration of the step, see Adjusting the Increment of ACL Rules.
A description is configured for the ACL.
By default, an ACL has no description.
The ACL description helps you understand and remember the functions or purpose of an ACL.
You can configure advanced ACL rules according to the protocols carried by IP. The parameters vary according to the protocol types.
When the protocol type is ICMP, the command format is:
rule [ rule-id ] { deny | permit } { protocol-number | icmp } [ destination { destination-address destination-wildcard | any } | { { precedence precedence | tos tos } * | dscp dscp } | { fragment | first-fragment } | logging | icmp-type { icmp-name | icmp-type [ icmp-code ] } | source { source-address source-wildcard | any } | time-range time-name | ttl-expired | { vpn-instance vpn-instance-name | public } ] *
When the protocol type is TCP, the command format is:
rule [ rule-id ] { deny | permit } { protocol-number | tcp } [ destination { destination-address destination-wildcard | any } | destination-port { eq port | gt port | lt port | range port-start port-end } | { { precedence precedence | tos tos } * | dscp dscp } | { fragment | first-fragment } | logging | source { source-address source-wildcard | any } | source-port { eq port | gt port | lt port | range port-start port-end } | tcp-flag { ack | established | fin | psh | rst | syn | urg } * | time-range time-name | ttl-expired | { vpn-instance vpn-instance-name | public } ] *
When the protocol type is UDP, the command format is:
rule [ rule-id ] { deny | permit } { protocol-number | udp } [ destination { destination-address destination-wildcard | any } | destination-port { eq port | gt port | lt port | range port-start port-end } | { { precedence precedence | tos tos } * | dscp dscp } | { fragment | first-fragment } | logging | source { source-address source-wildcard | any } | source-port { eq port | gt port | lt port | range port-start port-end } | time-range time-name | ttl-expired | { vpn-instance vpn-instance-name | public } ] *
When the protocol type is GRE, IGMP, IP, IPINIP, or OSPF, the command format is:
rule [ rule-id ] { deny | permit } { protocol-number | gre | igmp | ip | ipinip | ospf } [ destination { destination-address destination-wildcard | any } | { { precedence precedence | tos tos } * | dscp dscp } | { fragment | first-fragment } | logging | source { source-address source-wildcard | any } | time-range time-name | ttl-expired | { vpn-instance vpn-instance-name | public } ] *
The vpn-instance and public parameter is supported only when a software-based ACL is applied to the S5720-EI, S5720-HI, S5720I-SI, S5720S-SI, S5720-SI, S5735-S, S5735S-S, S5735-S-I, S5730-HI, S5730S-EI, S5730-SI, S5731-H, S5731-S, S5731S-H, S5731S-S, S5732-H, S6720-EI, S6720-HI, S6720S-EI, S6720S-SI, S6720-SI, S6730-H, S6730S-H, S6730-S, or S6730S-S. For usage scenarios of software-based ACLs, see "ACL Implementations" in the S2720, S5700, and S6700 V200R019C10 Configuration Guide - Security ACL Configuration - ACL Fundamentals.
In this example, only one permit or deny rule is configured. In actual configuration, you can configure multiple rules and decide the matching order of the rules according to service requirements.
For details about the time ranges, types of protocols carried by IP, source/destination IP addresses and their wildcard masks, TCP/UDP port numbers, TCP flaps, and IP fragment information, see ACLs Supported by Switches and Common Matching Conditions. Configuring rules for an advanced ACL provides a rule configuration example.
A description is configured for the ACL rules.
By default, an ACL rule has no description.
The ACL rule description helps you understand and remember the functions or purpose of an ACL rule.
You can configure descriptions for only the existing rules on the device. That is, you cannot configure a description for a rule before creating it.
After an ACL is configured, it must be applied to a service module so that the ACL rules can be delivered and take effect. For supported service modules and configurations, see Applying an ACL.
Configuring a packet filtering rule for ICMP protocol packets based on the source IP address (host address) and destination network segment
<HUAWEI> system-view [HUAWEI] acl 3001 [HUAWEI-acl-adv-3001] rule permit icmp source 192.168.1.3 0 destination 192.168.2.0 0.0.0.255
Configuring a packet filtering rule for TCP protocol packets based on the TCP destination port number, source IP address (host address), and destination network segment
<HUAWEI> system-view [HUAWEI] acl name deny-telnet [HUAWEI-acl-adv-deny-telnet] rule deny tcp destination-port eq telnet source 192.168.1.3 0 destination 192.168.2.0 0.0.0.255
<HUAWEI> system-view [HUAWEI] acl name no-web [HUAWEI-acl-adv-no-web] description Web access restrictions [HUAWEI-acl-adv-no-web] rule deny tcp destination-port eq 80 source 192.168.1.3 0 [HUAWEI-acl-adv-no-web] rule deny tcp destination-port eq 80 source 192.168.1.4 0
Configuring a packet filtering rule for TCP packets based on the source network segment and TCP flags
To implement unidirectional access control on a network segment, configure rules in an ACL. For example, to implement unidirectional access control on the network segment 192.168.2.0/24, configure the following rules in ACL 3002. In the following rules, the hosts on 192.168.2.0/24 can only respond to TCP handshake packets, but cannot send TCP handshake packets. Set the descriptions of the ACL rules to "Allow the ACK TCP packets through", "Allow the RST TCP packets through", and "Do not Allow the other TCP packet through."
<HUAWEI> system-view [HUAWEI] acl 3002 [HUAWEI-acl-adv-3002] rule permit tcp source 192.168.2.0 0.0.0.255 tcp-flag ack [HUAWEI-acl-adv-3002] display this // If you do not specify an ID for a created rule, you can view the rule ID allocated by the system, and configure a description for the rule by specifying the rule ID. # acl number 3002 rule 5 permit tcp source 192.168.2.0 0.0.0.255 tcp-flag ack // The rule ID allocated by the system is 5. # return [HUAWEI-acl-adv-3002] rule 5 description Allow the ACK TCP packets through [HUAWEI-acl-adv-3002] rule permit tcp source 192.168.2.0 0.0.0.255 tcp-flag rst [HUAWEI-acl-adv-3002] display this # acl number 3002 rule 5 permit tcp source 192.168.2.0 0.0.0.255 tcp-flag ack rule 5 description Allow the ACK TCP packets through rule 10 permit tcp source 192.168.2.0 0.0.0.255 tcp-flag rst // The rule ID allocated by the system is 10. # return [HUAWEI-acl-adv-3002] rule 10 description Allow the RST TCP packets through [HUAWEI-acl-adv-3002] rule deny tcp source 192.168.2.0 0.0.0.255 [HUAWEI-acl-adv-3002] display this # acl number 3002 rule 5 permit tcp source 192.168.2.0 0.0.0.255 tcp-flag ack rule 5 description Allow the ACK TCP packets through rule 10 permit tcp source 192.168.2.0 0.0.0.255 tcp-flag rst rule 10 description Allow the RST TCP packets through rule 15 deny tcp source 192.168.2.0 0.0.0.255 // The rule ID allocated by the system is 15. # return [HUAWEI-acl-adv-3002] rule 15 description Do not Allow the other TCP packet through
<HUAWEI> system-view [HUAWEI] acl 3002 [HUAWEI-acl-adv-3002] rule permit tcp source 192.168.2.0 0.0.0.255 tcp-flag established [HUAWEI-acl-adv-3002] rule 5 description Allow the Established TCP packets through [HUAWEI-acl-adv-3002] rule deny tcp source 192.168.2.0 0.0.0.255 [HUAWEI-acl-adv-3002] rule 10 description Do not Allow the other TCP packet through [HUAWEI-acl-adv-3002] display this # acl number 3002 rule 5 permit tcp source 192.168.2.0 0.0.0.255 tcp-flag established rule 5 description Allow the Established TCP packets through rule 10 deny tcp source 192.168.2.0 0.0.0.255 rule 10 description Do not Allow the other TCP packet through # return
Configuring a time-based ACL rule
For details, see Configuring a time-based ACL rule in Configuring a Basic ACL.
Configuring a packet filtering rule based on the source network segment and IP fragment information
For details, see Configuring a packet filtering rule based on the IP fragment information and source IP address segment in Configuring a Basic ACL.