ACL Configuration
ACL Configuration
Section titled “ACL Configuration”show acl table [ table_name]
Section titled “show acl table [ table_name]”[Command]
show acl table [ table_name ]
[Purpose]
Show existing ACL tables
[Parameter]
| Parameter | Description |
|---|---|
| table_name | Specify the table name |
[View]
System view
[Use Cases]
sonic# show acl tableName Type Binding Description Stage------- ----------- --------- ------------- -------TABLE_2 L3 Ethernet8 TABLE_2 ingressshow acl rule [ table_name ] [ rule_id]
Section titled “show acl rule [ table_name ] [ rule_id]”[Command]
show acl rule [ table_name ] [ rule_id ]
[Purpose]
Show existing ACL rules
[Parameter]
| Parameter | Description |
|---|---|
| table_name | Specify the table name |
| rule_id | Specify the rule name |
[View]
System view
[Use Cases]
sonic# show acl ruleTable Rule Priority Action Match Status----------- ------ ---------- -------- ---------------------------- --------dianxin_in 1 1001 FORWARD DST_IP: 192.168.2.249/32 N/A SET_POLICER: POLICER|dianxindianxin_out 1 1001 FORWARD SET_POLICER: POLICER|dianxin N/A SRC_IP: 192.168.2.249/32show counters acl [acl-table-name ] [ rule-id]
Section titled “show counters acl [acl-table-name ] [ rule-id]”[Command] * show counters acl [ acl-table-name ] [ rule-id ]
[Purpose]
Show ACL hit count
[Parameter]
| Parameter | Description |
|---|---|
| acl-table-name | ACL Table Name |
| rule-id | rule id |
[View]
System view
[Notes]
Allows multiple tables and rules to be entered, either as individual tables or as table + rule.
Table and table are separated by ”,”, rule and rule are separated by ”,”; table and rule are separated by spaces.
[Use Cases]
sonic# show counters acl RULE NAME TABLE NAME PRIO PACKETS COUNT BYTES COUNT----------- ------------ ------ --------------- ------------- 1 dianxin_in 1001 33 5358 RULE NAME TABLE NAME PRIO PACKETS COUNT BYTES COUNT----------- ------------ ------ --------------- ------------- 1 dianxin_out 1001 10 980clear counters acl
Section titled “clear counters acl”[Command]
clear counters acl
[Purpose]
Clear ACL hit count
[Use Cases]
sonic# clear counters aclaccess-list table_type table-name table_stage [srv service type]
Section titled “access-list table_type table-name table_stage [srv service type]”[Command]
access-list table_type table-name table_stage [srv service type]
no access-list table-name
[Purpose]
Create ACL table and enter ACL view
[Parameter]
| Parameter | Description |
|---|---|
| table_type | ACL table type, optional L3, L3v6, CTRLPLANE |
| table-name | ACL Table Name |
| table_stage | Specify the inbound/outbound direction, ingress/egress |
| service type | When specifying the table type as CTRLPLANE or CTRLPLANEV6, the SRV can be selected from NTP, SNMP, SSH, and TELNET |
[View]
System configuration view
[Notes]
ACL table is for ports. Binding ports means that the ACL table is effective for traffic on those ports. An ACL table can bind multiple ports, and multiple ACL tables can exist on a single port, i.e., a “many-to-many” relationship.
Note that when the ACL table type is CTRLPLANE or CTRLPLANEV6, SRV is a mandatory item that specifies the service type.And CTRLPLANE and CTRLPLANEV6 do not support configuring the egress direction, only the ingress direction.
[Use Cases]
sonic# configure terminalsonic(config)# access-list l3 TABLE_1 ingress[Command]
rule rule_id [{packet-action {deny|permit|trap-to-cpu|no-nat} interface-type interface-name | traffic behavior name }] [src-mac mac-address ] [src-ip ip-address ] [dst-ip ip-address ] [src-port port ] [dst-port port ] \ [ip-type type] [src-dns-group name] [dst-dns-group name] [dscp] [set-hqos-user hqos-user-name] [set-hqos-guser-range-srcip-auto hqos-user-group-name] [set-hqos-guser-range-dstip-auto hqos-user-group-name] [geosite geosite value] [geoip geoip value]
no rule rule_id
[Purpose]
Add ACL rules
[Parameter]
| Parameter | Description |
|---|---|
| rule_id | Rule ID, the range of values: 0-500; also indicates the rule priority, the larger the number the higher the priority, not repeatable |
| packet-action | Packet processing actions for hit rules deny Drop permit Allowed to pass trap-to-cpu Upload to CPU for processing no-nat Not using the nat function |
| src-ip | Source IP address, format: A.B.C.D/M |
| dst-ip | Destination IP address, format: A.B.C.D/M |
[View]
ACL view
[Notes]
Multiple ACL rules can exist per table.
<rule_id> The higher the value, the higher the priority, the same table does not allow the configuration of the same priority rules.
[Use Cases]
sonic# configure terminalsonic(config)# access-list l3 TABLE_1 ingresssonic(config-l3-acl-table_1)# rule 1 src-ip 10.0.0.3/24 packet-action permitacl string priority num
Section titled “acl string priority num”[Command]
acl string priority num
no acl string
[Purpose]
Bind ACL rules on the interface and set the priority of ACL tables relative to this interface.
[Parameter]
| Parameter | Description |
|---|---|
| string | Name of ACL table |
| num | ACL table priority at interface level, range: 1~65535 |
| dst-ip | Destination IP address, format: A.B.C.D/M |
[View]
Interface view, supporting physical port interface, lag if, vlan if, and sub interface binding ACL table
[Notes]
The priority of the same table can be different on different interfaces; All tables bound to the same interface must not have duplicate priorities and cannot be modified. Only deletion before addition is supported, which means unbinding first and then modifying the priority before binding the table;
Note that for VLAN if and its member ports, if they are all bound to the same table, the priority must be the same; If different tables are bound, the priority must also be different.
[Use Cases]
sonic# configure terminalsonic(config)# interface ethernet 13sonic(config-if-13)# acl test priority 300acl counter enable [all|rule table name rule id|table table name]
Section titled “acl counter enable [all|rule table name rule id|table table name]”[Command]
acl counter enable [all|rule table name rule id|table table name]
no acl string
[Purpose]
Enable or disable the hit statistics function of ACL rules. Once enabled, the underlying hardware will record the number of messages and bytes that match the rule.
The command provides three different granularity control methods: All: globally effective, one click to enable or disable the counting function of all ACL tables and their internal rules on the device.
Table table name: Effective at the table level, enabling or disabling the counting function of all rules within the specified ACL table.
Rule table name rule id: Effective at the rule level, only the counting function of a specific rule in the specified ACL table is precisely turned on or off.
[View]
System Configuration View
[Use Cases]
sonic# configure terminalsonic(config)# acl counter enable allsonic(config)# acl counter enable rule test1 1