- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
01-ACL Configuration | 137.45 KB |
Contents
Configuring an Ethernet frame header ACL
Displaying and maintaining ACLs
IPv4 packet filtering configuration example
IPv6 packet filtering configuration example
ACL configuration
This chapter includes these sections:
· Displaying and maintaining ACLs
|
NOTE: · Unless otherwise stated, ACLs refer to both IPv4 and IPv6 ACLs throughout this document. · The term "switch" or "device" in this chapter refers to the switching engine on a WX3000E wireless switch. · The WX3000E series comprises WX3024E and WX3010E wireless switches. · The port numbers in this chapter are for illustration only. |
ACL overview
An access control list (ACL) is a set of rules (or permit or deny statements) for identifying traffic based on criteria such as source IP address, destination IP address, and port number.
ACLs are primarily used for packet filtering. “Packet filtering with ACLs” provides an example. You can use ACLs in QoS, firewall, routing, and other feature modules for identifying traffic. The packet drop or forwarding decisions varies with the modules that use ACLs.
ACL categories
Category |
ACL number |
IP version |
Match criteria |
Basic ACLs |
2000 to 2999 |
IPv4 |
Source IPv4 address |
IPv6 |
Source IPv6 address |
||
Advanced ACLs |
3000 to 3999 |
IPv4 |
Source IPv4 address, destination IPv4 address, packet priority, protocols over IPv4, and other Layer 3 and Layer 4 header fields |
IPv6 |
Source IPv6 address, destination IPv6 address, packet priority, protocols over IPv6, and other Layer 3 and Layer 4 header fields |
||
Ethernet frame header ACLs |
4000 to 4999 |
IPv4 and IPv6 |
Layer 2 header fields, such as source and destination MAC addresses, 802.1p priority, and link layer protocol type |
ACL numbering and naming
Each ACL category has a unique range of ACL numbers. When creating an ACL, you must assign it a number. In addition, you can assign the ACL a name for the ease of identification. After creating an ACL with a name, you can neither rename it nor delete its name.
For an Ethernet frame header ACL, the ACL number and name must be globally unique. For an IPv4 basic or advanced ACLs, its ACL number and name must be unique among all IPv4 ACLs, and for an IPv6 basic or advanced ACL, among all IPv6 ACLs. You can assign an IPv4 ACL the same number and name as an IPv6 ACL.
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 approach, carefully check the rule content and order.
· auto—Sorts ACL rules in depth-first order. Depth-first ordering ensures that 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
ACL category |
Sequence of tie breakers |
IPv4 basic ACL |
1. More 0s in the source IP address wildcard (more 0s means a narrower IP address range) 2. Smaller rule ID |
IPv4 advanced ACL |
1. Specific protocol type rather than IP (IP represents any protocol over IP) 2. More 0s in the source IP address wildcard mask 3. More 0s in the destination IP address wildcard 4. Narrower TCP/UDP service port number range 5. Smaller rule ID |
IPv6 basic ACL |
1. Longer prefix for the source IP address (a longer prefix means a narrower IP address range) 2. Smaller rule ID |
IPv6 advanced ACL |
1. Specific protocol type rather than IP (IP represents any protocol over IPv6) 2. Longer prefix for the source IPv6 address 3. Longer prefix for the destination IPv6 address 4. Narrower TCP/UDP service port number range 5. Smaller rule ID |
Ethernet frame header ACL |
1. More 1s in the source MAC address mask (more 1s means a smaller MAC address) 2. More 1s in the destination MAC address mask 3. Smaller rule ID |
|
NOTE: A wildcard mask, also called an “inverse mask,” is a 32-bit binary and 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. |
ACL rule comments
You can add a comment about an ACL rule to make it easy to understand. The rule comment appears below the rule statement.
ACL rule numbering
What is the ACL rule numbering step
If you do not assign an ID for 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 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.
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 numbering step is 5 (the default), and there are five ACL rules numbered 0, 5, 9, 10, and 12, the newly defined rule is numbered 15. If the ACL does not contain any rule, the first rule is numbered 0.
Whenever the step changes, the rules are renumbered, starting from 0. For example, if there are five rules numbered 5, 10, 13, 15, and 20, changing the step from 5 to 2 causes the rules to be renumbered 0, 2, 4, 6 and 8.
Fragments filtering with ACLs
Traditional packet filtering matches only first fragments of packets, and allows all subsequent non-first fragments to pass through. Attackers can fabricate non-first fragments to attack networks.
To avoids the risks, the H3C ACL implementation:
· Filters all fragments by default, including non-first fragments.
· Allows for matching criteria modification, for example, filters non-first fragments only.
ACL configuration task list
Complete the following tasks to configure an ACL:
Task |
Remarks |
Optional Applicable to IPv4 and IPv6 ACLs |
|
Required Configure at least one task. Applicable to IPv4 and IPv6 |
|
Optional Applicable to IPv4 and IPv6 |
|
Optional Applicable to IPv4 and IPv6 |
Configuring an ACL
Configuring a time range
You can implement ACL rules based on the time of day by applying a time range to them. A time-based ACL rule takes effect only in any time periods specified by the time range.
The following basic types of time range are available:
· Periodic time range—Recurs periodically on a day or days of the week.
· Absolute time range—Represents only a period of time and does not recur.
You can create multiple statements in a time range. The active period of a time range is calculated as follows:
1. Combining all periodic statements
2. Combining all absolute statements
3. Taking the intersection of the two statement sets as the active period of the time range
You can create a maximum of 256 time ranges, each with a maximum of 32 periodic statements and 12 absolute statements.
Follow these steps to configure a time range:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
–– |
Configure a time range |
time-range time-range-name { start-time to end-time days [ from time1 date1 ] [ to time2 date2 ] | from time1 date1 [ to time2 date2 ] | to time2 date2 } |
Required By default, no time range exists. Repeat this command with the same time range name to create multiple statements for a time range. |
Configuring a basic ACL
Configuring an IPv4 basic ACL
IPv4 basic ACLs match packets based only on source IP addresses.
Follow these steps to configure an IPv4 basic ACL:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
–– |
Create an IPv4 basic ACL and enter its view |
acl number acl-number [ name acl-name ] [ match-order { auto | config } ] |
Required By default, no ACL exists. IPv4 basic ACLs are numbered in the range 2000 to 2999. You can use the acl name acl-name command to enter the view of a named IPv4 ACL. |
Configure a description for the IPv4 basic ACL |
description text |
Optional By default, an IPv4 basic ACL has no ACL description. |
Set the rule numbering step |
step step-value |
Optional 5 by default. |
Create or edit a rule |
rule [ rule-id ] { deny | permit } [ fragment | source { sour-addr sour-wildcard | any } | time-range time-range-name ] * |
Required By default, an IPv4 basic ACL does not contain any rule. |
Add or edit a rule comment |
rule rule-id comment text |
Optional By default, an IPv4 ACL rule has no rule description. |
Configuring an IPv6 basic ACL
Follow these steps to configure an IPv6 basic ACL:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
–– |
Create an IPv6 basic ACL view and enter its view |
acl ipv6 number acl6-number [ name acl6-name ] [ match-order { auto | config } ] |
Required By default, no ACL exists. IPv6 basic ACLs are numbered in the range 2000 to 2999. You can use the acl ipv6 name acl6-name command to enter the view of a named IPv6 ACL. |
Configure a description for the IPv6 basic ACL |
description text |
Optional By default, an IPv6 basic ACL has no ACL description. |
Set the rule numbering step |
step step-value |
Optional 5 by default |
Create or edit a rule |
rule [ rule-id ] { deny | permit } [ fragment | source { ipv6-address prefix-length | ipv6-address/prefix-length | any } | time-range time-range-name ] * |
Required By default, an IPv6 basic ACL does not contain any rule. |
Add or edit a rule comment |
rule rule-id comment text |
Optional By default, an IPv6 basic ACL rule has no rule description. |
Configuring an advanced ACL
Configuring an IPv4 advanced ACL
IPv4 advanced ACLs match packets based on source IP addresses, destination IP addresses, packet priorities, protocols over IP, and other protocol header information, such as TCP/UDP source and destination port numbers, TCP flags, ICMP message types, and ICMP message codes.
Compared to IPv4 basic ACLs, IPv4 advanced ACLs allow more flexible and accurate filtering.
Follow these steps to configure an IPv4 advanced ACL:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
–– |
Create an IPv4 advanced ACL and enter its view |
acl number acl-number [ name acl-name ] [ match-order { auto | config } ] |
Required By default, no ACL exists. IPv4 advanced ACLs are numbered in the range 3000 to 3999. You can use the acl name acl-name command to enter the view of a named IPv4 ACL. |
Configure a description for the IPv4 advanced ACL |
description text |
Optional By default, an IPv4 advanced ACL has no ACL description. |
Set the rule numbering step |
step step-value |
Optional 5 by default. |
Create or edit a rule |
rule [ rule-id ] { deny | permit } protocol [ { { ack ack-value | fin fin-value | psh psh-value | rst rst-value | syn syn-value | urg urg-value } * | established } | destination { dest-addr dest-wildcard | any } | destination-port operator port1 [ port2 ] | dscp dscp | fragment | icmp-type { icmp-type [ icmp-code ] | icmp-message } | precedence precedence | source { sour-addr sour-wildcard | any } | source-port operator port1 [ port2 ] | time-range time-range-name | tos tos ] * |
Required By default, an IPv4 advanced ACL does not contain any rule. |
Add or edit a rule comment |
rule rule-id comment text |
Optional By default, an IPv4 advanced ACL rule has no rule description. |
Configuring an IPv6 advanced ACL
IPv6 advanced ACLs match packets based on the source IPv6 addresses, destination IPv6 addresses, packet priorities, protocols carried over IPv6, and other protocol header fields such as the TCP/UDP source port number, TCP/UDP destination port number, ICMPv6 message type, and ICMPv6 message code.
Compared to IPv6 basic ACLs, IPv6 advanced ACLs allow more flexible and accurate filtering.
Follow these steps to configure an IPv6 advanced ACL:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
–– |
Create an IPv6 advanced ACL and enter its view |
acl ipv6 number acl6-number [ name acl6-name ] [ match-order { auto | config } ] |
Required By default, no ACL exists. IPv6 advanced ACLs are numbered in the range 3000 to 3999. You can use the acl ipv6 name acl6-name command to enter the view of a named IPv6 ACL. |
Configure a description for the IPv6 advanced ACL |
description text |
Optional By default, an IPv6 advanced ACL has no ACL description. |
Set the rule numbering step |
step step-value |
Optional 5 by default. |
Create or edit a rule |
rule [ rule-id ] { deny | permit } protocol [ { { ack ack-value | fin fin-value | psh psh-value | rst rst-value | syn syn-value | urg urg-value } * | established } | destination { dest dest-prefix | dest/dest-prefix | any } | destination-port operator port1 [ port2 ] | dscp dscp | fragment | icmpv6-type { icmpv6-type icmpv6-code | icmpv6-message } | source { source source-prefix | source/source-prefix | any } | source-port operator port1 [ port2 ] | time-range time-range-name ] * |
Required By default IPv6 advanced ACL does not contain any rule. The flow-label and fragment keywords are not supported when the ACL is for QoS traffic classification. |
Add or edit a rule comment |
rule rule-id comment text |
Optional By default, an IPv6 advanced ACL rule has no rule description. |
Configuring an Ethernet frame header ACL
Ethernet frame header ACLs, also called "Layer 2 ACLs," match packets based on Layer 2 protocol header fields such as source MAC address, destination MAC address, 802.1p priority (VLAN priority), and link layer protocol type.
Follow these steps to configure an Ethernet frame header ACL:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
–– |
Create an Ethernet frame header ACL and enter its view |
acl number acl-number [ name acl-name ] [ match-order { auto | config } ] |
Required By default, no ACL exists. Ethernet frame header ACLs are numbered in the range 4000 to 4999. You can use the acl name acl-name command to enter the view of a named Ethernet frame header ACL. |
Configure a description for the Ethernet frame header ACL |
description text |
Optional By default, an Ethernet frame header ACL has no ACL description. |
Set the rule numbering step |
step step-value |
Optional 5 by default. |
Create or edit a rule |
rule [ rule-id ] { deny | permit } [ cos vlan-pri | dest-mac dest-addr dest-mask | { lsap lsap-type lsap-type-mask | type protocol-type protocol-type-mask } | source-mac sour-addr source-mask | time-range time-range-name ] * |
Required By default, an Ethernet frame header ACL does not contain any rule. The lsap keyword is not supported when the ACL is for QoS traffic classification. |
Add or edit a rule comment |
rule rule-id comment text |
Optional By default, an Ethernet frame header ACL rule has no rule 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 not the same ACL number and name.
To successfully copy an ACL, make sure that:
· The destination ACL number is from the same category as the source ACL number.
· The source ACL already exists but the destination ACL does not.
Copying an IPv4 ACL
Follow these steps to copy an IPv4 ACL:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Copy an existing IPv4 ACL to create a new IPv4 ACL |
acl copy { source-acl-number | name source-acl-name } to { dest-acl-number | name dest-acl-name } |
Required |
Copying an IPv6 ACL
Follow these steps to copy an IPv6 ACL:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Copy an existing IPv6 ACL to generate a new one of the same category |
acl ipv6 copy { source-acl6-number | name source-acl6-name } to { dest-acl6-number | name dest-acl6-name } |
Required |
Packet filtering with ACLs
You can use an ACL to filter incoming IPv4 or IPv6 packets on an Ethernet interface or a VLAN interface.
|
NOTE: ACLs on VLAN interfaces filter only IPv4 packets forwarded at Layer 3. |
Applying an IPv4 ACL for packet filtering
Follow these steps to apply an IPv4 ACL for packet filtering:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Enter interface view |
interface interface-type interface-number |
— |
Apply an IPv4 basic, IPv4 advanced, or Ethernet frame header ACL to the interface to filter packets |
packet-filter { acl-number | name acl-name } inbound |
Required By default, no ACL is applied to any interface. |
Applying an IPv6 ACL for packet filtering
Follow these steps to apply an IPv6 ACL for packet filtering:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Enter interface view |
interface interface-type interface-number |
— |
Apply an IPv6 basic or IPv6 advanced ACL to the interface to filter IPv6 packets |
packet-filter ipv6 { acl6-number | name acl6-name } inbound |
Required By default, no IPv6 ACL is applied to the interface. |
Displaying and maintaining ACLs
To do... |
Use the command… |
Remarks |
Display configuration and match statistics for one or all IPv4 ACLs |
display acl { acl-number | all | name acl-name } [ slot slot-number ] [ | { begin | exclude | include } regular-expression ] |
Available in any view |
Display configuration and match statistics for one or all IPv6 ACLs |
display acl ipv6 { acl6-number | all | name acl6-name } [ slot slot-number ] [ | { begin | exclude | include } regular-expression ] |
Available in any view |
Display the usage of ACL rules |
display acl resource [ slot slot-number ] [ | { begin | exclude | include } regular-expression ] |
Available in any view |
Display the application status of packet filtering ACLs on interfaces |
display packet-filter { { all | interface interface-type interface-number } [ inbound ] | interface vlan-interface vlan-interface-number [ inbound ] [ slot slot-number ] } [ | { begin | exclude | include } regular-expression ] |
Available in any view |
Display the configuration and status of one or all time ranges |
display time-range { time-range-name | all } [ | { begin | exclude | include } regular-expression ] |
Available in any view |
Clear statistics for one or all IPv4 ACLs |
reset acl counter { acl-number | all | name acl-name } |
Available in user view |
Clear statistics for one or all IPv6 basic and advanced ACLs |
reset acl ipv6 counter { acl6-number | all | name acl6-name } |
Available in user view |
ACL configuration examples
IPv4 packet filtering configuration example
Network requirements
As shown in Figure 1, apply an ACL to filter incoming traffic on interface GigabitEthernet 1/0/1 on Device A so that everyday from 8:00 to 18:00 the interface allows only packets sourced from Host A to pass.
Figure 1 Network diagram for applying an IPv4 ACL to an interface for packet filtering
Configuration procedure
# Create a time range from 08:00 to 18:00 every day.
<DeviceA> system-view
[DeviceA] time-range study 8:00 to 18:00 daily
# Create IPv4 ACL 2009, and configure two rules in the ACL. One rule permits packets sourced from Host A and the other denies packets sourced from any other host during the time range study.
[DeviceA] acl number 2009
[DeviceA-acl-basic-2009] rule permit source 192.168.1.2 0 time-range study
[DeviceA-acl-basic-2009] rule deny source any time-range study
[DeviceA-acl-basic-2009] quit
# Apply IPv4 ACL 2009 to filter incoming packets on GigabitEthernet 1/0/1.
[DeviceA] interface gigabitethernet 1/0/1
[DeviceA-GigabitEthernet1/0/1] packet-filter 2009 inbound
[DeviceA-GigabitEthernet1/0/1] quit
IPv6 packet filtering configuration example
Network requirements
As shown in Figure 2, apply an IPv6 ACL to filter incoming traffic on GigabitEthernet 1/0/1 on Device A so that everyday from 8:00 to 18:00 the interface allows only packets from Host A to pass through.
Figure 2 Network diagram for applying an IPv6 ACL to an interface for packet filtering
Configuration procedure
# Create a time range from 08:00 to 18:00 every day.
<DeviceA> system-view
[DeviceA] time-range study 8:0 to 18:0 daily
# Create IPv6 ACL 2009, and configure two rules for the ACL. One permits packets sourced from Host A and the other denies packets sourced from any other host during the time range study.
[DeviceA] acl ipv6 number 2009
[DeviceA-acl6-basic-2009] rule permit source 1001::2 128 time-range study
[DeviceA-acl6-basic-2009] rule deny source any time-range study
[DeviceA-acl6-basic-2009] quit
# Apply IPv6 ACL 2009 to filter incoming packets on GigabitEthernet 1/0/1.
[DeviceA] interface gigabitethernet 1/0/1
[DeviceA-GigabitEthernet1/0/1] packet-filter ipv6 2009 inbound
[DeviceA-GigabitEthernet1/0/1] quit