A network ACL is an optional layer of protection for your subnets. After you add inbound and outbound rules to a network ACL and associate subnets with it, you can control traffic in and out of the subnets.
A network ACL is different from a security group. A security group protects the instances in it, such as ECSs, databases, and containers, while a network ACL protects the entire subnet. Security groups are a mandatory layer of protection but network ACLs are optional. Network ACLs and security groups can be used together for fine-grained access control.
You need to specify the protocol, source port and address, and destination port and address for each inbound and outbound rule of the network ACL. Suppose you have two subnets in VPC-X of region A, as shown in Figure 1. Subnet-X01 is associated with network ACL Fw-A, and ECSs deployed in this subnet provide web services accessible from the Internet. Subnet-X02 is associated with network ACL Fw-B. Subnet-X02 and Subnet-Y01 are connected through a VPC peering connection. Now, you need to configure inbound and outbound rules to allow ECS-C01 in Subnet-Y01 to remotely log in to ECSs in Subnet-X02. The custom inbound rule allows any IP address to access the ECSs in Subnet-X01 over port 80 using TCP (HTTP). If the traffic does not match the custom rule, the default rule is applied and the traffic is denied to enter the subnet. Stateful network ACLs allow responses to inbound requests to leave the subnet without being controlled by rules. The responses from ECSs in Subnet-X01 can leave the subnet. Other outbound traffic is denied to leave Subnet-X01 because the default rule is applied. The custom rule in the inbound direction allows access from Subnet-Y01 to ECSs in Subnet-X02 through port 22 over TCP (SSH). The custom rule in the outbound direction allows all ICMP traffic over any port. The ping traffic from ECSs in Subnet-X02 can be routed to ECSs in Subnet-Y01 to test the network connectivity. Figure 1 Network ACL rules
The default network ACL rule is marked with an asterisk (*) and is the very last rule that will be used for matching.
If you add, modify, or delete a network ACL rule, or associate or disassociate a subnet with or from a network ACL, all the inbound and outbound persistent connections will remain connected. New rules will only be applied for the new connections.
After a persistent connection is disconnected, new connections will not be established immediately until the timeout period of connection tracking expires. For example, after an ICMP persistent connection is disconnected, a new connection will be established and a new rule will be applied when the timeout period (30s) expires.
Direction | Rule Number | Action | Protocol | Source | Source Port Range | Destination | Destination Port Range |
|---|---|---|---|---|---|---|---|
Inbound | * | Deny | All | 0.0.0.0/0 | All | 0.0.0.0/0 | All |
Outbound | * | Deny | All | 0.0.0.0/0 | All | 0.0.0.0/0 | All |
Direction | Description |
|---|---|
Inbound | Traffic between the instances in the same subnet |
Broadcast traffic to 255.255.255.255/32 | |
Multicast traffic to 224.0.0.0/24 | |
Outbound | Traffic between the instances in the same subnet |
Broadcast traffic to 255.255.255.255/32 | |
Multicast traffic to 224.0.0.0/24 | |
TCP metadata traffic to 169.254.169.254/32 over port 80 | |
Traffic to 100.125.0.0/16 that is reserved for public services on the cloud, such as the DNS server addresses and NTP server addresses |
A subnet can be associated with one network ACL. If there are multiple rules in a network ACL, rules are applied based on their priority. A smaller number indicates a higher priority. The value of the default rule priority is *, which has the lowest priority.
A subnet can be associated with only one network ACL. If there are multiple rules on the network ACL, rules are matched in ascending order, from the lowest to highest rule number. The default network ACL rule is marked with an asterisk (*) and is the very last rule that will be used for matching.
The matching sequence of inbound traffic is the same as that of outbound traffic. The following takes inbound traffic as an example to describe how the rules are applied.
Figure 2 Network ACL matching

Solution: You can add network ACL rules to deny access from malicious IP addresses.
Solution: You can add network ACL rules to deny access over a specific port and protocol, for example, port 445 and TCP.
Solution: You can add network ACL rules to control north-south traffic between subnets.
Solution: A network ACL allows you to adjust the rule sequence so that frequently used rules are applied before other rules.
Figure 3 Procedure for configuring a network ACL

No. | Step | Description | Reference |
|---|---|---|---|
1 | Create a network ACL. | A network ACL comes with default inbound and outbound rules that deny traffic in and out of a subnet. | |
2 | Add network ACL rules. | The default rules cannot be deleted or modified. You can add custom rules to control traffic in and out of a subnet. Traffic will be preferentially matched against the custom rules. | |
3 | Associate the network ACL with one or more subnets. | You can associate the network ACL with one or more subnets. If the network ACL is enabled, the network ACL rules control traffic in and out of the subnets. A subnet can be associated with only one network ACL. |
Transfer Client IP Address is enabled for the listeners of a load balancer.
The load balancer can still forward traffic to backend servers, even if there is a rule that denies traffic from the load balancer to the backend servers.