14 ACL Principles and Configuration
14 ACL Principles and Configuration
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of their respective holders.
Notice
The purchased products, services and features are stipulated by the contract made between Huawei and the
customer. All or part of the products, services and features described in this document may not be within the
purchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information, and
recommendations in this document are provided "AS IS" without warranties, guarantees or representations of any
kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been made in the preparation
of this document to ensure accuracy of the contents, but all statements, information, and recommendations in this
document do not constitute a warranty of any kind, express or implied.
Website: https://e.huawei.com/
Huawei Certification System
Huawei Certification follows the "platform + ecosystem" development strategy, which is a new
collaborative architecture of ICT infrastructure based on "Cloud-Pipe-Terminal". Huawei has set up
a complete certification system consisting of three categories: ICT infrastructure certification,
platform and service certification, and ICT vertical certification. It is the only certification system
that covers all ICT technical fields in the industry. Huawei offers three levels of certification:
Huawei Certified ICT Associate (HCIA), Huawei Certified ICT Professional (HCIP), and Huawei
Certified ICT Expert (HCIE). Huawei Certification covers all ICT fields and adapts to the industry
trend of ICT convergence. With its leading talent development system and certification standards,
it is committed to fostering new ICT talent in the digital era, and building a sound ICT talent
ecosystem.
Huawei Certified ICT Associate-Datacom (HCIA-Datacom) is designed for Huawei's frontline
engineers and anyone who want to understand Huawei's datacom products and technologies. The
HCIA-Datacom certification covers routing and switching principles, basic WLAN principles,
network security basics, network management and O&M basics, SDN and programmability and
automation basics.
The Huawei certification system introduces the industry, fosters innovation, and imparts cutting-
edge datacom knowledge.
Contents
1.1 Foreword
Rapid network development brings challenges to network security and quality of service (QoS).
Access control lists (ACLs) are closely related to network security and QoS.
By accurately identifying packet flows on a network and working with other technologies, ACLs can
control network access behaviors, prevent network attacks, and improve network bandwidth
utilization, thereby ensuring network environment security and QoS reliability.
This course describes the basic principles and functions of ACLs, types and characteristics of ACLs,
basic composition of ACLs, ACL rule ID matching order, usage of wildcards, and ACL configurations.
1.2 Objectives
On completion of this course, you will be able to:
⚫ Describe the basic principles and functions of ACLs.
⚫ Understand the types and characteristics of ACLs.
⚫ Describe the basic composition of ACLs and ACL rule ID matching order.
⚫ Understand how to use wildcards in ACLs.
⚫ Complete the basic configurations of ACLs.
ACL Principles and Configuration Page 2
Matching IP traffic
Invoked in a traffic filter
Invoked in network address translation (NAT)
Invoked in a routing policy
Invoked in a firewall policy
Invoked in QoS
Others
ACLs accurately identify and control packets on a network to manage network access behaviors,
prevent network attacks, and improve bandwidth utilization. In this way, ACLs ensure security and
QoS.
An ACL is a set of sequential rules composed of permit or deny statements. It classifies packets by
matching fields in packets.
An ACL can match elements such as source and destination IP addresses, source and destination port
numbers, and protocol types in IP datagrams. It can also match routes.
In this course, traffic filtering is used to describe ACLs.
ACL Principles and Configuration Page 4
1.4.2 Rule ID
Rule ID:
Each rule in an ACL has an ID, which identifies the rule. Rule IDs can be manually defined or
automatically allocated by the system.
Step:
A step is an increment between neighboring rule IDs automatically allocated by the system. The
default step is 5. Setting a step facilitates rule insertion between existing rules of an ACL.
When the system automatically allocates IDs to ACL rules, the increment between neighboring rule
IDs is called a step. The default step is 5. Therefore, rule IDs are 5, 10, 15, and so on.
If a rule is manually added to an ACL but no ID is specified, the system allocates to this rule an ID that
is greater than the largest rule ID in the ACL and is the smallest integer multiple of the step value.
The step can be changed. For example, if the step is changed to 2, the system automatically
renumbers the rule IDs as 2, 4, 6...
Rule ID allocation:
If a rule is added to an empty ACL but no ID is manually specified for the rule, the system allocates a
step value (5 for example) as the ID of the rule. If an ACL contains rules with manually specified IDs
and a rule with no manually specified ID is added, the system allocates to this rule an ID that is
greater than the largest rule ID in the ACL and is the smallest integer multiple of the step value.
What is the function of a step? Why can't rules 1, 2, 3, and 4 be directly used?
First, let's look at a question. How do I add a rule?
We can manually add rule 11 between rules 10 and 15.
Therefore, setting a step of a certain length facilitates rule insertion between existing rules.
When an IP address is matched, a 32-bit mask is followed. The 32-bit mask is called a wildcard.
A wildcard is also expressed in dotted decimal notation. After the value is converted to a binary
number, the value 0 indicates that the equivalent bit must match and the value 1 indicates that the
equivalent bit does not matter.
Let's look at two rules:
1. rule 5: denies the packets with the source IP address 10.1.1.1. Because the wildcard comprises
all 0s, each bit must be strictly matched. Specifically, the host IP address 10.1.1.1 is matched.
2. rule 15: permits the packets with the source IP address on the network segment 10.1.1.0/24.
The wildcard is 0.0.0.11111111, and the last eight bits are 1s, indicating that the bits do not
matter. Therefore, the last eight bits of 10.1.1.xxxxxxxx can be any value, and the 10.1.1.0/24
network segment is matched.
For example, if we want to exactly match the network segment address corresponding to
192.168.1.1/24, what is the wildcard?
It can be concluded that the network bits must be strictly matched and the host bits do not matter.
Therefore, the wildcard is 0.0.0.255.
ACL Principles and Configuration Page 7
User-
5000 to Defines rules based on packet headers, offsets, character string
defined
5999 masks, and user-defined character strings.
ACL
Defines rules based on source IPv4 addresses or user control list (UCL)
6000 to groups, destination IPv4 addresses or destination UCL groups, IPv4
User ACL
6999 protocol types, ICMP types, TCP source/destination port numbers,
and UDP source/destination port numbers.
Category Description
Note: You can specify a number for an ACL. The ACLs of different types have different number
ranges. You can also specify a name for an ACL to help you remember the ACL's purpose. A named
ACL consists of a name and number. That is, you can specify an ACL number when you define an ACL
name. If you do not specify a number for a named ACL, the system automatically allocates a number
to it.
ACL Principles and Configuration Page 9
Note: ACLs are usually used together with other technologies, and the meanings of the permit and
deny actions may vary according to scenarios.For example, if an ACL is used together with traffic
filtering technology (that is, the ACL is invoked in traffic filtering), the permit action allows traffic to
pass and the deny action rejects traffic.
Position 2:Configure an ACL on the interface.To enable the ACL to take effect for the data packet
shown in the figure,apply the ACL to the outbound direction.
Figure 1-13
[Huawei-acl-basic-2000] rule [ rule-id ] { deny | permit } [ source { source-address source-wildcard | any } | time-
range time-name ]
In the basic ACL view, you can run this command to configure a rule for the basic ACL.
1. rule-id: specifies the ID of an ACL rule.
2. deny: denies the packets that match the rule.
3. permit: permits the packets that match the rule.
4. source { source-address source-wildcard | any }: specifies the source IP address of packets that
match the ACL rule. If no source address is specified, packets with any source addresses are
matched.
1) source-address: specifies the source IP address of packets.
2) source-wildcard: specifies the wildcard of the source IP address.
3) any: indicates any source IP address of packets. That is, the value of source-address is
0.0.0.0 or the value of source-wildcard is 255.255.255.255.
5. time-range time-name: specifies a time range in which the ACL rule takes effect. time-name
specifies the name of a time range. If no time range is specified, the ACL rule is always valid.
ACL Principles and Configuration Page 14
Configuration roadmap:
Configure a basic ACL and traffic filtering to filter packets from a specified network segment.
Procedure:
Configure IP addresses and routes on the router.
Create ACL 2000 and configure ACL rules to deny packets from the network segment
192.168.1.0/24 and permit packets from other network segments.
Configure traffic filtering.
Note:
The traffic-filter command applies an ACL to an interface to filter packets on the interface.
Command format: traffic-filter { inbound | outbound } acl { acl-number | name acl-name }
1) inbound: configures ACL-based packet filtering in the inbound direction of an interface.
2) outbound: configures ACL-based packet filtering in the outbound direction of an interface.
3) acl: filters packets based on an IPv4 ACL.
Step of configuration:
In the advanced ACL view, you can run this command to configure a rule for the advanced ACL.
1. ip: indicates that the protocol type is IP.
2. destination { destination-address destination-wildcard | any }: specifies the destination IP
address of packets that match the ACL rule. If no destination address is specified, packets
with any destination addresses are matched.
3. dscp dscp: specifies the differentiated services code point (DSCP) of packets that match the
ACL rule. The value ranges from 0 to 63.
4. tos tos: specifies the ToS of packets that match the ACL rule. The value ranges from 0 to 15.
5. precedence precedence: specifies the precedence of packets that match the ACL rule. The
value ranges from 0 to 7.
ACL Principles and Configuration Page 16
In the advanced ACL view, you can run this command to configure a rule for the advanced ACL.
1. tcp: indicates that the protocol type is TCP. You can set protocol-number to 6 to indicate
TCP.
2. destination-port { eq port | gt port | lt port | range port-start port-end }: specifies the TCP
destination port number of packets that match the ACL rule. The value is valid only when
the protocol type is TCP. If no destination port number is specified, packets with any TCP
destination port numbers are matched.
1) eq port: equal to the destination port number
2) gt port: greater than the destination port number
3) lt port: less than the destination port number
4) range port-start port-end: specifies a source port number range.
3. tcp-flag: indicates the SYN Flag in the TCP packet header.
Requirements:
ACL Principles and Configuration Page 17
The departments of a company are connected through the router. To facilitate network
management, the administrator allocates IP addresses of different network segments to the R&D
and marketing departments.
The company requires that the router prevent the user hosts on different network segments from
communicating to ensure information security.
Configuration roadmap:
Configure an advanced ACL and traffic filtering to filter the packets exchanged between the R&D and
marketing departments.
Procedure:
Configure IP addresses and routes on the router.
Create ACL 3001 and configure rules for the ACL to deny packets from the R&D department to
the marketing department.
Create ACL 3002 and configure rules for the ACL to deny packets from the marketing
department to the R&D department.
Configure traffic filtering in the inbound direction of GE 0/0/1 and GE 0/0/2.
Note:
The traffic-filter command applies an ACL to an interface to filter packets on the interface.
Command format: traffic-filter { inbound | outbound } acl { acl-number | name acl-name }
1) inbound: configures ACL-based packet filtering in the inbound direction of an interface.
2) outbound: configures ACL-based packet filtering in the outbound direction of an interface.
3) acl: filters packets based on an IPv4 ACL.
Step of configuration:
Step3 Create ACL 3002 and configure rules for the ACL to deny packets from the marketing
department to the R&D department.
Step4 Configure traffic filtering in the inbound direction of GE 0/0/1 and GE 0/0/2.
ACL Principles and Configuration Page 18
1.6 Summary
ACL is a widely used network technology. Its principle is as follows: packets are matched against
configured ACL rules and actions are taken on the packets as configured in the ACL rules. The
matching rules and actions are configured based on network requirements. Due to the variety of
matching rules and actions, ACLs can implement a lot of functions.
ACLs are often used with other technologies, such as firewall, routing policy, QoS, and traffic
filtering.
ACL Principles and Configuration Page 19
1.7 Quiz
1. (Single) Which one of the following rules is a valid basic ACL rule? ( )
A. rule permit ip
B. rule deny ip
C. rule permit source any
D. rule deny tcp source any
2. (Single) Which of the following ACL rules can the traffic destined for 192.168.1.1/24 be
permitted? ( )
A. rule permit source 192.168.1.1 0.0.0.255
B. rule permit source 192.168.1.0 0.0.0.254
C. rule permit source 192.168.0.0 0.0.0.255
D. rule deny source any
3. (Single) Which of the following cannot be controlled by ACL 3001? ( )
A. Destination address
B. Source address
C. Destination port number
D. Packet length
4. (Multiple) What are the applications of ACLs? ( )
A. Provide means of controlling communication traffic
B. Is a basic means of providing network security access
C. Called in QoS
D. Matches routes.
5. (True or False) The default step for configuring an ACL is 5. The step can be changed. ( )
A. True
B. False
6. (True or False) The configuration commands of ACL 2001 are as follows:
Rule 5 permit source 192.168.1.1 0.0.0.0
Rule 10 deny source 192.168.1.1 0.0.0.0
Then, the traffic with the destination address 192.168.1.1 is permitted. ( )
A. True
B. False
7. Which parameters can you use to define advanced ACL rules?