跳转到内容
Ask AI

ACL Configuration Guide

此内容尚不支持你的语言。

Communication between information points and internal and external networks are essential business requirements in enterprise network. In order to ensure the security of the intranet, security policy is needed to ensure that unauthorized users can only access specific network resources. ACL (Access Control List) is packet processing policy consisting of a series of rules, which are generally judgment statements describing the matching conditions of packets, such as the source MAC, destination MAC, source IP, destination IP, source port number, destination port number, etc. The switch filters packets based on these rules. After configuring ACL rules, the switch will allow certain packets to pass and block certain packets to achieve the purpose of access control and traffic filtering. In short, ACL as a network technology means to control access, improve the security of the network environment and the reliability of network transmission.

ACL table is port specific. Binding ports means that the ACL table is valid for traffic on those ports. A single ACL table can bind multiple ports, and multiple ACL tables can exist on a single port, i.e. a “many-to-many” relationship.

ACL table naming rule

The ACL tables’ name is supposed to be different.

ACL table type

ACL table type affects the match fields of the ACL, in other words, determines which characteristics are used to match traffic. ACL table type is available as L2, L3, L3v6, MIRROR, MIRRORv6, FLOW_CONTROL. In particular, FLOW_CONTROL is used as a special ACL table type in combination with the traffic behavior module for the speed-limiting of specific flows.

ACL table direction

The ACL table stage indicates the direction, optionally ingress and egress, which corresponds to whether the ACL table is applied to the ingress or egress direction respectively. If stage is not specified, the default is ingress. Currently, the same ACL table does not support matching in both the ingress and egress directions. For the CX family, the matches available in different directions are different. The ACL match fields in the ingress direction are not available in the egress direction, and there are fewer types of match fields for egress than for ingress. See ACL rule match fields for a detailed description of the match fields.

ACL rule is table-specific rule that defines the priority of the rule, the matching conditions and the action to be taken if the match is successful. An ACL rule can only be added to one table, but a table can have multiple rules, i.e. the rule and the table are in a “many-to-one” relationship. The match field of an ACL rule must match the match field of the table in which it is located, and cannot exceed the match field defined by the table.

ACL rule naming rule

The ACL rules’ name is supposed to be different.

ACL rule priority

Priority indicates the priority of rule, the higher the value, the higher the priority, and is specified to be less than 500. Priority is used to match the highest priority rule when there are multiple rules to match. The same table does not allow rules of the same priority to be configured.

ACL rule action

-Ingress

Table 1 ACL rule ingress action

ActionKey wordsDescription
Basic actionspacket_actionOptional permit|deny|drop|trap-to-cpu|copy-to-cpu, permit means forward; deny means the packet is not forwarded but can be normally trapped; drop means the packet is neither forwarded nor trapped; trap-to-cpu means the packet is only sent to the CPU without forwarding; copy means the packet is sent to the CPU and also forwarded.
Modify DSCPset_dscpModify the packet dscp value, range 0-63
Modify PCPset_pcpModify the packet pcp value, range 0-7
Modify TCset_tcModify the tc value, range 0-7, generally used in conjunction with forcing modification of the packet DSCP ingress.
Redirectionredirect_actionRedirect, which support redirecting to an interface or to the next hop, are available in the following forms.Interface name, e.g. “Ethernet10”.Lag name, e.g. “PortChannel0005”.The global IP of the next hop, e.g. “10.0.0.1”.The IP and VRF of the next hop, e.g. “10.0.0.2@Vnet2”.The IP and interface name of the next hop, e.g. “10.0.0.3@Ethernet1”.Next hop group, e.g. “10.0.0.1,10.0.0.3@Ethernet1”
Traffic behaviortraffic-behaviorACLs and traffic behavior are used to limit the speed of specific traffic on a port.

-Egress

Table 2 ACL rule egress action

ActionKey wordsDescription
Basic actionspacket_actionOptional permit|deny, forward means forward, permit means forward; deny means the packet is not forwarded.
Modify DSCPset_dscpModify the packet dscp value, range 0-63
Modify PCPset_pcpModify the packet pcp value, range 0-7

ACL rule match fields

The supported match fields for different types of ACL tables vary, and the specific match fields for each type of ACL table are described below.

-L2 match fields

Table 3 L2 Keywords

Key wordsDescription of parametersNotes
vlan-pri3-bit VLAN priority value, range 0-7-
ethernet-type16-bit Ethernet type value, HEX<0-FFFF>, for example 0800Supported only in the ingress direction.
outer-vlanVLAN ID value, supports mask: vlan-id(1-4094)/mask(0x01-0x0fff) or vlan-id(1-4094).-
source-macSource MAC, supports mask: HH:HH:HH:HH:HH:HH or HH:HH:HH:HH:HH:HH/mask(HH:HH:HH:HH:HH:HH)Supported only in the ingress direction.
destination-macDestination MAC, supports mask: HH:HH:HH:HH:HH:HH or HH:HH:HH:HH:HH:HH/mask(HH:HH:HH:HH:HH:HH)Supported only in the ingress direction.

-L3 match fields

Table 4 L3 Keywords

Key wordsDescription of parametersNotes
ethernet-type16-bit Ethernet type value, HEX<0-FFFF>, for example 0800Supported only in the ingress direction.
outer-vlanVLAN ID value, supports mask: vlan-id(1-4094)/mask(0x01-0x0fff) or vlan-id(1-4094).-
ip-typeIP packtet type, optional any|ip|non_ip|ipv4any|non_ipv4|ipv6any|non_ipv6|arp|arp_request|arp_reply.Not supported on CX308P-48Y-N-V2 and CX532P-N-V2; supported on other device models.
ip-protocol8-bit IP protocol value, range 0-255-
tcp-flagstcp_flag value, range 0-63-
source-ipSource IPv4 address (can with prefix), e.g. “10.1.1.1/24”-
destination-ipDestination IPv4 address (can with prefix), e.g. “10.1.1.1/24”-
icmp-type8-bit icmp type value, range 0-16-
icmp-code8-bit icmp code value, range 0-5-
source-portsource port,range 0-65535-
destination-portdestination port,range 0-65535-
dscpValue of Dscp, range 0-63-
ip-precedenceIP Precedence value, range 0-7-
ecnThe value of ecn, in the range 0-3-
vlan-privlan priority, range0-7-
vxlan-vniVXLAN VNI, range 1-16777215Supported only in the ingress direction.

-L3v6 match fields

Table 5 L3v6 Keywords

Key wordsDescription of parametersNotes
ip-protocol8-bit IP protocol value, range 0-255Supported only in the ingress direction.
source-ipv6Source IPv6 address (can with prefix), e.g. “2001::1/128”-
destination-ipv6Destination IPv6 address (can with prefix), e.g. “2001::1/96”-
icmpv6-type8-bit icmpv6 type value, range 1-137Supported only in the ingress direction.
icmpv6-code8-bit icmpv6 code value, range 0-4Supported only in the ingress direction.
source-portsource port,range 0-65535Supported on CX308P-48Y-N-V2 and CX532P-N-V2; not supported on other device models.
destination-portdestination port,range 0-65535Supported on CX308P-48Y-N-V2 and CX532P-N-V2; not supported on other device models.

-MIRROR match fields

Table 6 MIRROR Keywords

Key wordsDescription of parametersNotes
in-portsIngress traffic interface; multiple interfaces separated by commas.Supported only in the ingress direction.
outer-vlanVLAN ID value, supports mask: vlan-id(1-4094)/mask(0x01-0x0fff) or vlan-id(1-4094).-
ip-typeIP packtet type, optional any|ip|non_ip|ipv4any|non_ipv4|ipv6any|non_ipv6|arp|arp_request|arp_reply.-
tcp-flagstcp_flag value, range 0-63-
source-ipIP address range with prefix, e.g. “1.1.1.1/32”-
destination-ipIP address range with prefix, e.g. “1.1.1.0/24”-
icmp-type8-bit icmp type value, range 0-16-
icmp-code8-bit icmp code value, range 0-5-
source-portsource port,range 0-65535-
destination-portdestination port,range 0-65535-
dscpValue of Dscp, range 0-63.-
ip-precedenceIP Precedence value, range 0-7-
bth-opcodeValue of bth-opcode, range 0-255Not supported on CX308P-48Y-N-V2 and CX532P-N-V2; supported on other device models.
aeth_syndromeaeth_syndrome value, supports mask, aeth_syndrome(0-255)/mask(0x01-0xff) or aeth_syndrome(0-255)Not supported on CX308P-48Y-N-V2 and CX532P-N-V2; supported on other device models.

-MIRRORv6 match fields

Table 7 MIRRORv6 keywords

Key wordsDescription of parametersNotes
source-ipv6Source IPv6 address (can with prefix), e.g. “2001::1/128”-
destination-ipv6Destination IPv6 address (can with prefix), e.g. “2001::1/96”-
bth-opcodeValue of bth-opcode, range 0-255Not supported on CX308P-48Y-N-V2 and CX532P-N-V2; supported on other device models.
aeth_syndromeeth_syndrome value, supports mask, aeth_syndrome(0-255)/mask(0x01-0xff) or aeth_syndrome(0-255)Not supported on CX308P-48Y-N-V2 and CX532P-N-V2; supported on other device models.

-Flow Control match fields

Table 8 Flow Control Keywords

Key wordsDescription of parametersNotes
in-portsList of bound interfaces, multiple interfaces separated by commasSupported only in the ingress direction.
out-portsList of bound interfaces, multiple interfaces separated by commasSupported only in the egress direction.
source -macSource MAC, supports mask: HH:HH:HH:HH:HH:HH or HH:HH:HH:HH:HH:HH/mask(HH:HH:HH:HH:HH:HH)Supported only in the ingress direction.
destination-macDestination MAC, supports mask: HH:HH:HH:HH:HH:HH or HH:HH:HH:HH:HH:HH/mask(HH:HH:HH:HH:HH:HH)Supported only in the ingress direction.
outer-vlanVLAN ID value, supports mask: vlan-id(1-4094)/mask(0x01-0x0fff) or vlan-id(1-4094).Supported only in the ingress direction.
ip-protocol8-bit IP protocol value, range 0-255-
source-ipSource IPv4 address (can with prefix), e.g. “10.1.1.1/24”-
destination-ipDestination IPv4 address (can with prefix), e.g. “10.1.1.1/24”-
source-portsource port,range 0-65535-
destination-portdestination port,range 0-65535-
vxlan-vniVXLAN VNI, range 1-16777215Supported only in the ingress direction.

Table 9 Configure L2 ACL Table

PurposeCommandsDescription
Enter global configuration view.configure terminal-
Create an ACL table and enter the configuration view.access-list table_name l2 {ingress|egress}-
Apply the ACL table to the interface.bind interface {ethernet interface-name|link-aggregation lag-id|all}all: Binds to all interfaces.
Create an ACL rule.rule rule-id [rule_options] action_optionsrule-id also indicates the priority level, in the range 0-500.
rule_options: see ACL rule match fields for details.
action_options: see ACL rule action for details.

Table 10 Configure L3 ACL Table

PurposeCommandsDescription
Enter global configuration view.configure terminal-
Create an ACL table and enter the configuration view.access-list table_name l3 {ingress|egress}-
Apply the ACL table to the interface.bind interface {ethernet interface-name|link-aggregation lag-id|all}all: Binds to all interfaces.
Create an ACL rule.rule rule-id [rule_options] action_optionsrule-id also indicates the priority level, in the range 0-500.
rule_options: see ACL rule match fields for details.
action_options: see ACL rule action for details.

Table 11 Configure L3v6 ACL Table

PurposeCommandsDescription
Enter global configuration view.configure terminal-
Create an ACL table and enter the configuration view.access-list table_name l3v6 {ingress|egress}-
Apply the ACL table to the interface.bind interface {ethernet interface-name|link-aggregation lag-id|all}all: Binds to all interfaces.
Create an ACL rule.rule rule-id [rule_options] action_optionsrule-id also indicates the priority level, in the range 0-500.
rule_options: see ACL rule match fields for details.
action_options: see ACL rule action for details.

ACL redirection can be configured to a specified interface, next hop, or next hop group.

Table 12 Configure ACL redirection

PurposeCommandsDescription
Enter global configuration view.configure terminal-
Create an ACL table and enter the configuration view.access-list table_name {l3|l3v6} ingress-
Apply the ACL table to the interface.bind interface {ethernet interface-name|link-aggregation lag-id|all}all: Binds to all interfaces.
Create an ACL rule.rule rule-id [rule_options] action_optionsrule-id also indicates the priority level, in the range 0-500.
rule_options: see ACL rule match fields for details.
action_options: see ACL rule action for details.

ACL redirection can be configured to a specified interface, next hop, or next hop group.

Table 13 Configure ACL redirection next-hop-group

PurposeCommandsDescription
Enter global configuration view.configure terminal-
Create an ACL redirection next-hop-group.access-list nexthop-group group_numbergroup_number: the range is 1-12.
Add next hop.ip-address {A.B.C.D|A::B}Multiple next hops can be configured; the next hops must be reachable.
Commitcommit-
Exitexit-
Create an ACL table and enter the configuration view.access-list table_name {l3|l3v6} ingress-
Apply the ACL table to the interface.bind interface {ethernet interface-name|link-aggregation lag-id|all}all: Binds to all interfaces.
Create an ACL rule.rule rule-id [rule_options] redirect-action nexthop-group group_numberrule-id also indicates the priority level, in the range 0-500.
rule_options: see ACL rule match fields for details.

Configure ACL-Based Complex Traffic Behavior

Section titled “Configure ACL-Based Complex Traffic Behavior”

Please refer to* Configure ACL-Based Complex Traffic Behavior***in Traffic Behavior Configuration Guide for details.

Table 14 Configure user-defined ACL Type

PurposeCommandsDescription
Enter global configuration view.configure terminal-
Create a user-defined ACL type.access-list user-defined-type{ipv4|ipv6|non_ip} type-nametype-name: the name of user-defined ACL type.
Configure the type of bound interface.bind-points {port|switch}port:indicates that the port must be specified in the ACL Table.
switch:indicates that it is applied to the entire device.
Configure match optionsmatches match_options500.rule_options: see for details.
Configure actionactions action_optionsaction_options: see ACL rule action for details.

Use user-defined ACL Type to configure the ACL Table.

Table 15 Configure ACL Table

PurposeCommandsDescription
Enter global configuration view.configure terminal-
Create an ACL table and enter the configuration view.access-list table_name u ser-define-type type-name {ingress|egress}-
(Optional) Apply the ACL table to the interface.bind interface {ethernet interface-name|link-aggregation lag-id|all}all: Binds to all interfaces.
This command is available only when the bind-ports field in the user-defined Type is set to “port”.
Create an ACL rule.rule rule-id [rule_options] action_optionsrule-id also indicates the priority level, in the range 0-500.
rule_options: see ACL rule match fields for details.
action_options: see ACL rule action for details.

Table 16 Configure ACL Table

PurposeCommandsDescription
Enter global configuration view.configure terminal-
Create an ACL table and enter the configuration view.access-list table_name ctrlplane {SSH|SNMP|TELNET|NTP|BGP}-
(Optional) Apply the ACL table to the interface.bind interface {ethernet interface-name|link-aggregation lag-id|all}all: Binds to all interfaces.
Create an ACL rule.rule {default_drop [interface all]}|rule-id {source-ip|source-ipv6} packet-action {deny|accept}default_drop means drop all packets.
rule-id indicates the rule index, in the range 0-500.

Please refer to Configure Packet Remarking in ACL Configuration Guide for details.

Table 17 ACL Display and Maintenance

PurposeCommandsDescription
Show ACL rulesshow acl rule [table_name] [rule_id ]Table, rule can be specified
Show ACL tablesshow acl table [table_name]Table can be specified
Show ACL matchesshow counters acl [acl-table-name] [rule-id ]Show hit count, you can specify table, rule.
Clear ACL match countclear counters aclClear hit count
  1. Networking Requirements A company interconnects its departments via the switch. The Server stores confidential technical information about the company and also backs it up to the cloud. To ensure information security, it is required that ACL rules are correctly configured to achieve:
  • Prohibit Department A from accessing resources on the server or in the cloud.
  • Department B is prohibited from accessing the server resources directly, but can access the information by accessing the cloud.
  1. Topology

  1. Procedure

#Configure the IP of each port of the switch

sonic# configure terminal
sonic(config)# interface ethernet 0/0
sonic(config-if-0/0)# ip address 192.168.4.1/24
sonic(config-if-0/0)# ex
sonic# configure terminal
sonic(config)# interface ethernet 0/1
sonic(config-if-0/1)# ip address 192.168.5.1/24
sonic(config-if-0/1)# ex
sonic# configure terminal
sonic(config)# interface ethernet 0/48
sonic(config-if-0/48)# ip address 192.168.10.1/24
sonic(config-if-0/48)# ex
sonic# configure terminal
sonic(config)# interface ethernet 0/52
sonic(config-if-0/52)# ip address 192.168.10.2/24
sonic(config-if-0/52)# ex

#Configure ACL rules Ethernet0 ingress direction: packets with destination IP 192.168.20.2 received are discarded

sonic# configure terminal
sonic(config)# access-list TABLE_A l3 ingress
sonic(config-l3-acl-TABLE_A)# bind interface ethernet 0/0
sonic(config-l3-acl-TABLE_A)# rule 100 destination-ip 192.168.20.2 packet-action deny
sonic(config-l3-acl-TABLE_A)# ex
#Ethernet1 ingress direction: received packet with destination IP 192.168.20.2 redirected to Ethernet48
sonic# configure terminal
sonic(config)# access-list TABLE_B l3 ingress
sonic(config-l3-acl-TABLE_B)# bind interface ethernet 0/1
sonic(config-l3-acl-TABLE_B)# rule 200 destination-ip 192.168.20.2 redirect-action 192.168.10.2
sonic(config-l3-acl-TABLE_B)# ex
  1. Verify the configuration. Verify that the ACL rule is configured successfully.
sonic# show acl table
Name Type Binding Description Stage
------ ------ --------- ------------- -------
TABLE_B L3 0/1 TABLE_B ingress
TABLE_A L3 0/0 TABLE_A ingress
sonic# show acl rule
Table Rule Priority Action Match
------- ------ ---------- --------------------------------- -------------------
TABLE_B rule_200 200 DROP DST_IP: 192.168.20.2
TABLE_A rule_100 100 DROP DST_IP: 192.168.20.2
TABLE_A rule_101 101 DROP DST_IP: 192.168.10.2

A PC pinging the server from department A does not work, and when pinging the server from a PC in department B the packets go to Ethernet48.