ACL Rule Management
This section describes the configuration model of ACL rule management and provides examples of XML packets.
Data Model
The configuration model files for ACL rule management are ietf-acl.yang and huawei-acl.yang.
Object |
Description |
Value |
Remarks |
---|---|---|---|
/ietf-acl:access-lists/access-list/access-control-list-name |
Indicates the name or ID of an ACL. |
|
When the /ietf-acl:access-lists/access-list/huawei-acl:ipv6-flag object is set to true, the system identifies the created ACL as an IPv6 ACL. When this object is set to false, the system identifies the created ACL as an IPv4 ACL. |
/ietf-acl:access-lists/access-list/huawei-acl:ipv6-flag |
Indicates whether the created ACL is an IPv4 ACL or an IPv6 ACL. |
The value is of the Boolean type:
The default value is false. |
N/A |
/ietf-acl:access-lists/access-list/access-control-list-type |
Indicates the ACL type. |
The value is IP-access-control-list. |
N/A |
/ietf-acl:access-lists/access-list/huawei-acl:acl-name-type |
Indicates the type of an ACL created by name. |
The value is of the numerated type:
|
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/rule-name |
Indicates the ID of an ACL rule. |
|
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/actions |
Indicates the action in the ACL rule:
|
The value can be spaces or left empty. |
The action in an ACL rule depends on the content of access-control-list. |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/dscp |
Indicates the Differentiated Services Code Point (DSCP). |
The value is an integer that ranges from 0 to 63. |
This object is not supported by basic IPv6 and user ACLs. |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/protocol |
Indicates the type of protocol packets matching the ACL rule. |
The value is an integer that ranges from 1 or 255.
|
This object is not supported by basic IPv6 ACLs. |
|
Indicates the source port of the UDP or TCP packets matching the ACL rule. The value is valid only when the protocol of packets is TCP or UDP. If this parameter is not specified, TCP or UDP packets with any source port are matched. lower-port indicates the start port number, and upper-port indicates the end port number. The two parameters specify a source port number range. |
The value of lower-port or upper-port is a port number that ranges from 0 to 65535. |
|
|
Indicates the destination port of the UDP or TCP packets matching the ACL rule. If this parameter is not specified, TCP or UDP packets with any destination port are matched. lower-port indicates the start port number, and upper-port indicates the end port number. The two parameters specify a destination port number range. |
The value of lower-port or upper-port is a port number that ranges from 0 to 65535. |
|
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/source-ipv4-network |
Indicates the source addresses of packets that match the IPv4 ACL rule. If no source address is specified, the packets with any source address are matched. |
The value is in the format of source-address/source-wildcard.
|
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/destination-ipv4-network |
Indicates the destination addresses of packets that match the IPv4 ACL rule. If no destination address is specified, the packets with any destination address are matched. |
The value is in the format of destination-address/destination-wildcard.
|
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/source-ipv6-network |
Indicates the source addresses of packets that match the IPv6 ACL rule. If no source address is specified, the packets with any source address are matched. |
The value is in the format of source-ipv6-address/prefix-length.
|
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/destination-ipv6-network |
Indicates the destination addresses of packets that match the IPv6 ACL rule. If no destination address is specified, the packets with any destination address are matched. |
The value is in the format of destination-ipv6-address/prefix-length.
|
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/huawei-acl:vpn-instance |
Indicates the name of a VPN instance on the inbound interface. |
The value is a string of 1 to 31 case-sensitive characters without spaces. If the string is enclosed in double quotation marks (" "), the string can contain spaces. |
The value must be an existing VPN instance name. |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/huawei-acl:fqdn |
Indicates the name of a destination domain. |
The value is a string of 1 to 64 characters. |
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/huawei-acl: source-ucl-group/ucl-name |
Indicates the name of the UCL group to which the source IP address of packets belongs that match ACL rules. |
The value is a string of 1 to 31 case-sensitive characters without spaces. |
The value must be the name of an existing UCL group. |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/huawei-acl: source-ucl-group/ucl-index |
Indicates the ID of the UCL group to which the source IP address of packets belongs that match ACL rules. |
The value is an integer that ranges from 0 to 64000. |
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/huawei-acl: destination-ucl-group/ucl-name |
Indicates the name of the UCL group to which the destination IP address of packets belongs that match ACL rules. |
The value is a string of 1 to 31 case-sensitive characters without spaces. |
The value must be the name of an existing UCL group. |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/huawei-acl: destination-ucl-group/ucl-index |
Indicates the ID of the UCL group to which the destination IP address of packets belongs that match ACL rules. |
The value is an integer that ranges from 0 to 64000. |
N/A |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/huawei-acl: tcp-flag/flag-name |
Indicates the SYN Flag in the TCP packet header that match ACL rules. |
The value is of the numerated type:
|
This object is supported only when the /ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/matches/protocol object is set to 6 (TCP packets). |
/ietf-acl:access-lists/access-list/access-list-entries/access-list-entry/huawei-acl:time-range |
Indicates the time range name of an ACL rule. |
The value is a string of 1 to 32 characters. |
Before configuring this object, configure the /huawei-time-range:time-ranges/time-range/name object first. |
Configuring an ACL Rule
This section describes how to configure, modify, and delete an ACL rule using the edit-config method.
Operation |
XPATH |
---|---|
edit-config:create edit-config:replace edit-config:delete |
|
Data Requirement 1: Creating an ACL Rule for Matching TCP Protocol Packets
Item |
Data |
Description |
---|---|---|
ACL name |
test1 |
Create an ACL named test1. |
ACL type |
IP-access-control-list |
Set the ACL type to IP-access-control-list. |
ACL rule name |
1 |
Set the ACL rule name to 1. |
Action in the ACL rule |
NA |
Discard packets that match the ACL rule. |
Type of protocol packets matching the ACL rule |
6 |
Specify TCP protocol packets to match the ACL rule. |
Source port of the TCP packets matching the ACL rule |
lower-port: 1 upper-port: N/A |
Specify port 1 to any port as the source port range of TCP packets that match the ACL rule. |
Destination port of the TCP packets matching the ACL rule |
lower-port: 1 upper-port: 3 |
Specify ports 1 to 3 as the destination port range of TCP packets that match the ACL rule. |
Source addresses of packets that match the ACL rule |
10.1.1.1/16 |
Specify 10.1.1.1/16 as the source addresses of packets that match the ACL rule. |
Destination addresses of packets that match the ACL rule |
10.2.1.1/24 |
Specify 10.2.1.1/24 as the destination addresses of packets that match the ACL rule. |
DSCP |
0 |
Set the DSCP value to 0 for the ACL rule. |
Name of the time range within which the ACL rule takes effect |
abc |
Apply the ACL rule in a time range named abc. |
Request example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="5" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <access-control-list:access-lists xmlns:access-control-list="urn:ietf:params:xml:ns:yang:ietf-acl"> <access-control-list:access-list> <access-control-list:access-control-list-name>test1</access-control-list:access-control-list-name> <access-control-list:access-control-list-type>IP-access-control-list</access-control-list:access-control-list-type> <access-control-list:access-list-entries> <access-control-list:access-list-entry> <access-control-list:rule-name>1</access-control-list:rule-name> <access-control-list:matches> <access-control-list:source-port-range> <access-control-list:lower-port>1</access-control-list:lower-port> </access-control-list:source-port-range> <access-control-list:destination-port-range> <access-control-list:lower-port>1</access-control-list:lower-port> <access-control-list:upper-port>3</access-control-list:upper-port> </access-control-list:destination-port-range> <access-control-list:dscp>0</access-control-list:dscp> <access-control-list:protocol>6</access-control-list:protocol> <access-control-list:destination-ipv4-network>10.2.1.1/24</access-control-list:destination-ipv4-network> <access-control-list:source-ipv4-network>10.1.1.1/16</access-control-list:source-ipv4-network> </access-control-list:matches> <access-control-list:actions> <access-control-list:deny></access-control-list:deny> </access-control-list:actions> <hw-acl:time-range xmlns:hw-acl="urn:huawei:params:xml:ns:yang:huawei-acl">abc</hw-acl:time-range> </access-control-list:access-list-entry> </access-control-list:access-list-entries> </access-control-list:access-list> </access-control-list:access-lists> </config> </edit-config> </rpc>
Response example
Sample of successful response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3"> <ok/> </rpc-reply>
Sample of failed response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="7"> <rpc-error> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-message>parse rpc config error.</error-message> </rpc-error> </rpc-reply>
Data Requirement 2: Modifying the Destination Port Number Range in an ACL Rule
The following provides only the item to be modified. For other items, see data requirement 1.
Item |
Data |
Description |
---|---|---|
Destination port of the TCP packets matching the ACL rule |
lower-port: 1 upper-port: 6 |
Modify the destination port range of TCP packets that match the ACL rule from ports 1 to 3 to ports 1 to 6. |
Request example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="8" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <access-control-list:access-lists xmlns:access-control-list="urn:ietf:params:xml:ns:yang:ietf-acl"> <access-control-list:access-list> <access-control-list:access-control-list-name>test1</access-control-list:access-control-list-name> <access-control-list:access-control-list-type>IP-access-control-list</access-control-list:access-control-list-type> <access-control-list:access-list-entries> <access-control-list:access-list-entry> <access-control-list:rule-name>1</access-control-list:rule-name> <access-control-list:matches> <access-control-list:source-port-range> <access-control-list:lower-port>1</access-control-list:lower-port> </access-control-list:source-port-range> <access-control-list:destination-port-range> <access-control-list:lower-port>1</access-control-list:lower-port> <access-control-list:upper-port xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="replace">6</access-control-list:upper-port> </access-control-list:destination-port-range> <access-control-list:dscp>0</access-control-list:dscp> <access-control-list:protocol>6</access-control-list:protocol> <access-control-list:destination-ipv4-network>10.2.1.1/24</access-control-list:destination-ipv4-network> <access-control-list:source-ipv4-network>10.1.1.1/16</access-control-list:source-ipv4-network> </access-control-list:matches> <hw-acl:time-range xmlns:hw-acl="urn:huawei:params:xml:ns:yang:huawei-acl">abc</hw-acl:time-range> </access-control-list:access-list-entry> </access-control-list:access-list-entries> </access-control-list:access-list> </access-control-list:access-lists> </config> </edit-config> </rpc>
Response example
Sample of successful response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3"> <ok/> </rpc-reply>
Sample of failed response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4"> <rpc-error> <error-app-tag>-1</error-app-tag> <error-message>Service process failed.</error-message> <error-info>Error on node /ietf-acl:access-lists/access-list[access-control-list-name="test1"]</error-info> </rpc-error> </rpc-reply>
Data Requirement 3: Canceling the Upper Destination Port Number Limit in an ACL Rule
The following provides only the item to be modified. For other items, see data requirement 1.
Item |
Data |
Description |
---|---|---|
Destination port of the TCP packets matching the ACL rule |
lower-port: 1 upper-port: N/A |
Modify the destination port range of TCP packets that match the ACL rule to port 1 to any port. |
Request example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="9" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <access-control-list:access-lists xmlns:access-control-list="urn:ietf:params:xml:ns:yang:ietf-acl"> <access-control-list:access-list> <access-control-list:access-control-list-name>test1</access-control-list:access-control-list-name> <access-control-list:access-control-list-type>IP-access-control-list</access-control-list:access-control-list-type> <access-control-list:access-list-entries> <access-control-list:access-list-entry> <access-control-list:rule-name>1</access-control-list:rule-name> <access-control-list:matches> <access-control-list:source-port-range> <access-control-list:lower-port>1</access-control-list:lower-port> </access-control-list:source-port-range> <access-control-list:destination-port-range> <access-control-list:lower-port>1</access-control-list:lower-port> <access-control-list:upper-port xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="delete">6</access-control-list:upper-port> </access-control-list:destination-port-range> <access-control-list:dscp>0</access-control-list:dscp> <access-control-list:protocol>6</access-control-list:protocol> <access-control-list:destination-ipv4-network>10.2.1.1/24</access-control-list:destination-ipv4-network> <access-control-list:source-ipv4-network>10.1.1.1/16</access-control-list:source-ipv4-network> </access-control-list:matches> <hw-acl:time-range xmlns:hw-acl="urn:huawei:params:xml:ns:yang:huawei-acl">abc</hw-acl:time-range> </access-control-list:access-list-entry> </access-control-list:access-list-entries> </access-control-list:access-list> </access-control-list:access-lists> </config> </edit-config> </rpc>
Response example
Sample of successful response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3"> <ok/> </rpc-reply>
Sample of failed response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="7"> <rpc-error> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-message>edit operation failed.</error-message> </rpc-error> </rpc-reply>
Configuring an IPv6 ACL Rule
This section describes how to configure and delete an IPv6 ACL rule using the edit-config method.
Operation |
XPATH |
---|---|
edit-config |
|
Data Requirement 1: Creating an IPv6 ACL Rule for Matching TCP Protocol Packets
Item |
Data |
Description |
---|---|---|
Name or ID of an ACL to be created |
ipv6:3600 |
- |
Whether the created ACL is an IPv4 ACL or an IPv6 ACL |
true |
- |
ACL type |
IP-access-control-list |
- |
ACL rule ID |
1 |
- |
Action in the ACL rule |
Space (The permit action is used.) |
Allow packets matching the ACL rule to pass. |
Type of protocol packets matching the ACL rule |
6 |
- |
Source port of the TCP packets matching the ACL rule |
|
- |
Destination port of the TCP packets matching the ACL rule |
|
- |
Source addresses of packets that match the IPv6 ACL rule |
2001:db8:1::1/64 |
- |
Destination addresses of packets that match the IPv6 ACL rule |
2001:db8:1::2/64 |
- |
DSCP |
60 |
- |
Name of the time range within which the ACL rule takes effect |
t1 |
- |
Start time of the time range |
12:23:34 |
- |
End time of the time range |
23:34:56 |
- |
Validity period |
friday |
- |
Request example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <hw-time-range:time-ranges xmlns:hw-time-range="urn:huawei:params:xml:ns:yang:huawei-time-range"> <hw-time-range:time-range> <hw-time-range:vsys>public</hw-time-range:vsys> <hw-time-range:name>t1</hw-time-range:name> <hw-time-range:period-time> <hw-time-range:start>12:23:34</hw-time-range:start> <hw-time-range:end>23:34:56</hw-time-range:end> <hw-time-range:weekday>friday</hw-time-range:weekday> </hw-time-range:period-time> </hw-time-range:time-range> </hw-time-range:time-ranges> <access-control-list:access-lists xmlns:access-control-list="urn:ietf:params:xml:ns:yang:ietf-acl"> <access-control-list:access-list> <access-control-list:access-control-list-name>ipv6:3600</access-control-list:access-control-list-name> <access-control-list:access-control-list-type>IP-access-control-list</access-control-list:access-control-list-type> <access-control-list:access-list-entries> <access-control-list:access-list-entry> <access-control-list:rule-name>1</access-control-list:rule-name> <access-control-list:matches> <access-control-list:source-port-range> <access-control-list:lower-port>50</access-control-list:lower-port> <access-control-list:upper-port>60</access-control-list:upper-port> </access-control-list:source-port-range> <access-control-list:destination-port-range> <access-control-list:lower-port>70</access-control-list:lower-port> <access-control-list:upper-port>80</access-control-list:upper-port> </access-control-list:destination-port-range> <access-control-list:dscp>60</access-control-list:dscp> <access-control-list:protocol>6</access-control-list:protocol> <access-control-list:source-ipv6-network>2001:db8:1::1/64</access-control-list:source-ipv6-network> <access-control-list:destination-ipv6-network>2001:db8:1::2/64</access-control-list:destination-ipv6-network> <hw-acl:time-range xmlns:hw-acl="urn:huawei:params:xml:ns:yang:huawei-acl">t1</hw-acl:time-range> </access-control-list:matches> <access-control-list:actions> <access-control-list:permit> </access-control-list:permit> </access-control-list:actions> </access-control-list:access-list-entry> </access-control-list:access-list-entries> <hw-acl:ipv6-flag xmlns:hw-acl="urn:huawei:params:xml:ns:yang:huawei-acl">true</hw-acl:ipv6-flag> </access-control-list:access-list> </access-control-list:access-lists> </config> </edit-config> </rpc>
Response example
# Sample of successful response
##### Ok Reply or Operation Successful ##### <?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <ok/> </rpc-reply>
# Sample of failed response
##### Error Reply or Operation Failed ##### <?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <rpc-error> <error-app-tag>-1</error-app-tag> <error-message>The acl6 must start with "ipv6:".</error-message> <error-info>Error on node /ietf-acl:access-lists/access-list[access-control-list-name="ipv:3600"]</error-info> </rpc-error> </rpc-reply>
Data Requirement 2: Deleting the IPv6 ACL Rule for Matching TCP Protocol Packets
Delete the configuration performed in Data Requirement 1.
Request example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="2" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <hw-time-range:time-ranges xmlns:hw-time-range="urn:huawei:params:xml:ns:yang:huawei-time-range"> <hw-time-range:time-range xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="delete"> <hw-time-range:vsys>public</hw-time-range:vsys> <hw-time-range:name>t1</hw-time-range:name> <hw-time-range:period-time> <hw-time-range:start>12:23:34</hw-time-range:start> <hw-time-range:end>23:34:56</hw-time-range:end> <hw-time-range:weekday>friday</hw-time-range:weekday> </hw-time-range:period-time> </hw-time-range:time-range> </hw-time-range:time-ranges> <access-control-list:access-lists xmlns:access-control-list="urn:ietf:params:xml:ns:yang:ietf-acl"> <access-control-list:access-list xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="delete"> <access-control-list:access-control-list-name>ipv6:3600</access-control-list:access-control-list-name> <access-control-list:access-control-list-type>IP-access-control-list</access-control-list:access-control-list-type> <access-control-list:access-list-entries> <access-control-list:access-list-entry> <access-control-list:rule-name>1</access-control-list:rule-name> <access-control-list:matches> <access-control-list:source-port-range> <access-control-list:lower-port>50</access-control-list:lower-port> <access-control-list:upper-port>60</access-control-list:upper-port> </access-control-list:source-port-range> <access-control-list:destination-port-range> <access-control-list:lower-port>70</access-control-list:lower-port> <access-control-list:upper-port>80</access-control-list:upper-port> </access-control-list:destination-port-range> <access-control-list:dscp>60</access-control-list:dscp> <access-control-list:protocol>6</access-control-list:protocol> <access-control-list:source-ipv6-network>2001:db8:1::1/64</access-control-list:source-ipv6-network> <access-control-list:destination-ipv6-network>2001:db8:1::2/64</access-control-list:destination-ipv6-network> <hw-acl:time-range xmlns:hw-acl="urn:huawei:params:xml:ns:yang:huawei-acl">t1</hw-acl:time-range> </access-control-list:matches> <access-control-list:actions> <access-control-list:permit> </access-control-list:permit> </access-control-list:actions> </access-control-list:access-list-entry> </access-control-list:access-list-entries> <hw-acl:ipv6-flag xmlns:hw-acl="urn:huawei:params:xml:ns:yang:huawei-acl">true</hw-acl:ipv6-flag> </access-control-list:access-list> </access-control-list:access-lists> </config> </edit-config> </rpc>
Response example
# Sample of successful response
##### Ok Reply or Operation Successful ##### <?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"> <ok/> </rpc-reply>
# Sample of failed response
##### Error Reply or Operation Failed ##### <?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"> <rpc-error> <error-app-tag>-1</error-app-tag> <error-message>Service process failed.</error-message> <error-info>Error on node /ietf-acl:access-lists/access-list[access-control-list-name="test1"]</error-info> </rpc-error> </rpc-reply>