13 ACL Configuration
13 ACL Configuration
i
Configuring ACLs
Overview
An access control list (ACL) is a set of rules for identifying traffic based on criteria such as source IP
address, destination IP address, and port number. The rules are also called permit or deny
statements.
ACLs are primarily used for packet filtering. "Configuring packet filtering with ACLs" provides an
example. You can use ACLs in QoS, security, routing, and other modules for identifying traffic. The
packet drop or forwarding decisions depend on the modules that use ACLs.
ACL types
Type ACL number IP version Match criteria
IPv4 Source IPv4 address.
Basic ACLs 2000 to 2999
IPv6 Source IPv6 address.
Source IPv4 address, destination IPv4
IPv4 address, packet priority, protocol number, and
other Layer 3 and Layer 4 header fields.
Advanced ACLs 3000 to 3999
Source IPv6 address, destination IPv6
IPv6 address, packet priority, protocol number, and
other Layer 3 and Layer 4 header fields.
Layer 2 header fields, such as source and
Layer 2 ACLs 4000 to 4999 IPv4 and IPv6 destination MAC addresses, 802.1p priority,
and link layer protocol type.
User specified matching patterns in protocol
User-defined ACLs 5000 to 5999 IPv4 and IPv6
headers.
Match order
The rules in an ACL are sorted in a specific order. When a packet matches a rule, the device stops
the match process and performs the action defined in the rule. If an ACL contains overlapping or
conflicting rules, the matching result and action to take depend on the rule order.
The following ACL match orders are available:
• config—Sorts ACL rules in ascending order of rule ID. A rule with a lower ID is matched before
a rule with a higher ID. If you use this method, check the rules and their order carefully.
NOTE:
The match order of user-defined ACLs can only be config.
1
• auto—Sorts ACL rules in depth-first order. Depth-first ordering makes sure any subset of a rule
is always matched before the rule. Table 1 lists the sequence of tie breakers that depth-first
ordering uses to sort rules for each type of ACL.
Table 1 Sort ACL rules in depth-first order
A wildcard mask, also called an inverse mask, is a 32-bit binary number represented in dotted
decimal notation. In contrast to a network mask, the 0 bits in a wildcard mask represent "do care" bits,
and the 1 bits represent "don't care" bits. If the "do care" bits in an IP address are identical to the "do
care" bits in an IP address criterion, the IP address matches the criterion. All "don't care" bits are
ignored. The 0s and 1s in a wildcard mask can be noncontiguous. For example, 0.255.0.255 is a
valid wildcard mask.
Rule numbering
ACL rules can be manually numbered or automatically numbered. This section describes how
automatic ACL rule numbering works.
Rule numbering step
If you do not assign an ID to the rule you are creating, the system automatically assigns it a rule ID.
The rule numbering step sets the increment by which the system automatically numbers rules. For
example, the default ACL rule numbering step is 5. If you do not assign IDs to rules you are creating,
they are automatically numbered 0, 5, 10, 15, and so on. The wider the numbering step, the more
rules you can insert between two rules.
By introducing a gap between rules rather than contiguously numbering rules, you have the flexibility
of inserting rules in an ACL. This feature is important for a config-order ACL, where ACL rules are
matched in ascending order of rule ID.
2
Automatic rule numbering and renumbering
The ID automatically assigned to an ACL rule takes the nearest higher multiple of the numbering
step to the current highest rule ID, starting with 0.
For example, if the step is 5, and there are five rules numbered 0, 5, 9, 10, and 12, the newly defined
rule is numbered 15. If the ACL does not contain a rule, the first rule is numbered 0.
Whenever the step changes, the rules are renumbered, starting from 0. For example, changing the
step from 5 to 2 renumbers rules 5, 10, 13, and 15 as rules 0, 2, 4, and 6.
3
Configuration task list
Tasks at a glance
(Required.) Configure ACLs according to the characteristics of the packets to be matched:
• Configuring a basic ACL
{ Configuring an IPv4 basic ACL
{ Configuring an IPv6 basic ACL
• Configuring an advanced ACL
{ Configuring an IPv4 advanced ACL
{ Configuring an IPv6 advanced ACL
• Configuring a Layer 2 ACL
• Configuring a user-defined ACL
4
Step Command Remarks
4. (Optional.) Set the rule
numbering step. step step-value The default setting is 5.
5
Step Command Remarks
any } | time-range filtering) that uses the ACL
time-range-name | vpn-instance supports logging.
vpn-instance-name ] * If an IPv6 basic ACL is used for
outbound QoS traffic classification
or outbound packet filtering, do
not specify the routing keyword.
The vpn-instance
vpn-instance-name option is not
supported in the outbound
direction.
6. (Optional.) Add or edit a rule By default, no rule comment is
comment. rule rule-id comment text
configured.
6
Step Command Remarks
advanced acl-number command.
3. (Optional.) Configure a
description for the IPv4 By default, an IPv4 advanced ACL
description text
advanced ACL. does not have a description.
7
Step Command Remarks
numbered IPv6 advanced ACL.
To enter the view of a named IPv6
advanced ACL, use the acl ipv6
name acl-name or acl ipv6
advanced name acl-name
command.
The acl ipv6 name acl-name
command supports entering the
view of an existing IPv6 basic and
advanced ACL.
To enter the view of a numbered
IPv6 advanced ACL, use the acl
ipv6 number acl-number or acl
ipv6 advanced acl-number
command.
3. (Optional.) Configure a
description for the IPv6 By default, an IPv6 advanced ACL
description text
advanced ACL. does not have a description.
8
To configure a Layer 2 ACL:
9
Step Command Remarks
Use the acl number acl-number
or acl user-defined acl-number
command to enter the view of a
numbered user-defined ACL.
Use the acl user-defined name
acl-name command to enter the
view of a named user-defined
ACL.
3. (Optional.) Configure a
description for the By default, a user-defined ACL
description text
user-defined ACL. does not have a description.
Copying an ACL
You can create an ACL by copying an existing ACL (source ACL). The new ACL (destination ACL)
has the same properties and content as the source ACL, but uses a different number or name than
the source ACL.
To successfully copy an ACL, make sure:
• The destination ACL number is from the same type as the source ACL number.
• The source ACL already exists, but the destination ACL does not.
To copy an ACL:
Step Command
1. Enter system view. system-view
acl [ ipv6 | mac | user-defined ] copy
2. Copy an existing ACL to create a new ACL. { source-acl-number | name source-acl-name } to
{ dest-acl-number | name dest-acl-name }
10
Step Command Remarks
packet-filter [ ipv6 | mac |
3. Apply an ACL to the interface user-defined ] { acl-number | By default, an interface does not
to filter packets. name acl-name } { inbound | filter packets.
outbound } [ hardware-count ]
11
Setting the packet filtering default action
Step Command Remarks
1. Enter system view. system-view N/A
Task Command
Display ACL configuration and match display acl [ ipv6 | mac | user-defined ] { acl-number | all |
statistics. name acl-name }
display packet-filter { interface [ interface-type
Display ACL application information for interface-number ] [ inbound | outbound ] | interface
packet filtering (in standalone mode). vlan-interface vlan-interface-number [ inbound | outbound ]
[ slot slot-number ] }
display packet-filter { interface [ interface-type
Display ACL application information for interface-number ] [ inbound | outbound ] | interface
packet filtering (in IRF mode). vlan-interface vlan-interface-number [ inbound | outbound ]
[ chassis chassis-number slot slot-number ] }
display packet-filter statistics interface interface-type
Display match statistics and default action
interface-number { inbound | outbound } [ [ ipv6 | mac |
statistics for packet filtering ACLs.
user-defined ] { acl-number | name acl-name } ] [ brief ]
display packet-filter statistics sum { inbound | outbound }
Display the accumulated statistics for
[ ipv6 | mac | user-defined ] { acl-number | name acl-name }
packet filtering ACLs.
[ brief ]
display packet-filter verbose interface interface-type
Display detailed ACL packet filtering interface-number { inbound | outbound } [ [ ipv6 | mac |
information (in standalone mode). user-defined ] { acl-number | name acl-name } ] [ slot
slot-number ]
display packet-filter verbose interface interface-type
Display detailed ACL packet filtering interface-number { inbound | outbound } [ [ ipv6 | mac |
information (in IRF mode). user-defined ] { acl-number | name acl-name } ] [ chassis
chassis-number slot slot-number ]
Display QoS and ACL resource usage (in
display qos-acl resource [ slot slot-number ]
standalone mode).
Display QoS and ACL resource usage (in display qos-acl resource [ chassis chassis-number slot
IRF mode). slot-number ]
reset acl [ ipv6 | mac | user-defined ] counter { acl-number |
Clear ACL statistics.
all | name acl-name }
Clear match statistics, accumulated match reset packet-filter statistics interface [ interface-type
statistics, and default action statistics for interface-number ] { inbound | outbound } [ [ ipv6 | mac |
packet filtering ACLs. user-defined ] { acl-number | name acl-name } ]
12
ACL configuration examples
Interface-based packet filtering configuration example
Network requirements
A company interconnects its departments through the device. Configure packet filtering to:
• Permit access from the President's office at any time to the financial database server.
• Permit access from the Finance department to the financial database server only during
working hours (from 8:00 to 18:00) on working days.
• Deny access from any other department to the financial database server.
Figure 1 Network diagram
Configuration procedure
# Create a periodic time range from 8:00 to 18:00 on working days.
<Device> system-view
[Device] time-range work 08:0 to 18:00 working-day
# Configure a rule to permit access from the President's office to the financial database server.
[Device-acl-ipv4-adv-3000] rule permit ip source 192.168.1.0 0.0.0.255 destination
192.168.0.100 0
# Configure a rule to permit access from the Finance department to the financial database server
during working hours.
[Device-acl-ipv4-adv-3000] rule permit ip source 192.168.2.0 0.0.0.255 destination
192.168.0.100 0 time-range work
# Apply IPv4 advanced ACL 3000 to filter outgoing packets on interface GigabitEthernet 1/0/1.
[Device] interface gigabitethernet 1/0/1
[Device-GigabitEthernet1/0/1] packet-filter 3000 outbound
13
[Device-GigabitEthernet1/0/1] quit
# Verify that a PC in the Marketing department cannot ping the financial database server during
working hours.
C:\> ping 192.168.0.100
# Display configuration and match statistics for IPv4 advanced ACL 3000 on the device during
working hours.
[Device] display acl 3000
Advanced IPv4 ACL 3000, 3 rules,
ACL's step is 5
rule 0 permit ip source 192.168.1.0 0.0.0.255 destination 192.168.0.100 0
rule 5 permit ip source 192.168.2.0 0.0.0.255 destination 192.168.0.100 0 time-range work
(Active)
rule 10 deny ip destination 192.168.0.100 0
14