All Products
Search
Document Center

Cloud Firewall:Create an access control policy for a NAT firewall

Last Updated:Mar 31, 2026

A NAT firewall controls outbound traffic from resources in a virtual private cloud (VPC) — such as Elastic Compute Service (ECS) instances and elastic container instances — to the Internet over a NAT gateway. Without access control policies, all outbound traffic passes through unrestricted, leaving your workloads exposed to risks like unauthorized access, data leakage, and traffic attacks.

By creating access control policies, you allow only the traffic your workloads require. Each policy matches traffic by source address, destination address, protocol, port, and application, then applies an Allow, Deny, or Monitor action. The NAT firewall enforces these policies on all outbound traffic from VPC resources to the NAT gateway, including traffic from resources in the same VPC and across VPCs.

After an access control policy is created, the access control engine mode of the NAT firewall defaults to Loose Mode. In this mode, traffic whose application type or domain name is identified as Unknown is automatically allowed, so your existing workloads are not disrupted. If your security posture requires denying Unknown traffic, switch to Strict Mode after you create your policies. See Configure the ACL engine mode for instructions.

Prerequisites

Before you begin, ensure that you have:

  • A NAT firewall that is created and enabled. For more information, see NAT firewalls.

  • Sufficient quota for access control policies. Check your current quota on the Prevention Configuration > Access Control > NAT Border page. For details on how quota is calculated, see Overview of access control policies. If your quota is insufficient, click Increase Quota to increase the value of Quota for Additional Policy. For more information, see Purchase Cloud Firewall.

image..png
  • (Optional) An address book, if you want to specify multiple IP addresses or port ranges as a reusable source or destination group. For more information, see Manage address books.

Create an access control policy

  1. Log on to the Cloud Firewall console.

  2. In the left-side navigation pane, choose Prevention Configuration > Access Control > NAT Border.

  3. On the NAT Border page, find the NAT gateway for which you want to create a policy, then click Create Policy. NAT gateways within the current Alibaba Cloud account are automatically synchronized to Cloud Firewall.

    image..png

  4. In the Create Policy - NAT Border panel, configure the parameters described below, then click OK.

Parameter dependencies

The following constraints apply across parameters. Review them before configuring to avoid validation errors:

If you set...Then...
Source Type = IPEnter CIDR blocks for Source. Up to 2,000 CIDR blocks.
Source Type = Address BookSelect a pre-configured IP address book.
Destination Type = Domain NameYou must also select a Domain Name Identification Mode.
Domain Name Identification Mode = FQDN-based Dynamic ResolutionApplication is limited to HTTP, HTTPS, SMTP, SMTPS, or SSL.
Domain Name Identification Mode = DNS-based Dynamic ResolutionAll applications are available. Wildcard domain names are not supported.
Domain Name Identification Mode = FQDN and DNS-based Dynamic ResolutionApplication is limited to HTTP, HTTPS, SMTP, SMTPS, or SSL. Takes effect only in Strict Mode.

Source parameters

ParameterDescription
Source TypeSelect IP to enter CIDR blocks directly, or Address Book to use a pre-configured IP address book.
SourceEnter the source address based on the selected Source Type. If you set Source Type to IP, enter one or more CIDR blocks (for example, 192.168.0.0/16), separated by commas. Up to 2,000 CIDR blocks are supported. When multiple CIDR blocks are entered, Cloud Firewall automatically creates an address book containing them and prompts you to name it when you save the policy.

Destination parameters

ParameterDescription
Destination TypeSelect the type of destination: IP, Address Book, Domain Name, or Region.
DestinationEnter or select the destination based on the selected Destination Type: <br>- IP: Enter one or more CIDR blocks, separated by commas. Up to 2,000 CIDR blocks are supported. Multiple entries are automatically grouped into an address book. <br>- Address Book: Select a pre-configured IP address book. <br>- Domain Name: Select a Domain Name Identification Mode (see the table below). <br>- Region: Select one or more locations in or outside China.

Domain Name Identification Mode (applies when Destination Type is Domain Name):

ModeUse whenLimitation
FQDN-based Dynamic Resolution (Extract Host and SNI Fields)Managing HTTP, HTTPS, SMTP, SMTPS, or SSL traffic
DNS-based Dynamic ResolutionManaging traffic other than HTTP, HTTPS, SMTP, SMTPS, or SSLDoes not support wildcard domain names
FQDN and DNS-based Dynamic Resolution (Support for HTTP, HTTPS, SSL, SMTP, and STMPS)Managing HTTP, HTTPS, SMTP, SMTPS, or SSL traffic when specific or all traffic lacks the HOST or SNI fieldTakes effect only when the ACL engine mode is set to Strict Mode

Traffic matching parameters

ParameterDescription
Protocol TypeSelect the transport layer protocol: TCP, UDP, ICMP, or ANY. Select ANY if the protocol is unknown.
Port TypeSelect Port to enter port ranges directly, or Address Book to use a pre-configured port address book.
PortEnter port ranges in port/port format (for example, 22/22 or 80/88), separated by commas. Up to 2,000 port ranges are supported. Multiple entries are automatically grouped into a port address book.
ApplicationSelect the application type of the traffic. Available options depend on the Domain Name Identification Mode: <br>- DNS-based Dynamic Resolution: All applications are available. <br>- FQDN-based Dynamic Resolution: Only HTTP, HTTPS, SMTP, SMTPS, or SSL. <br>- FQDN and DNS-based Dynamic Resolution: HTTP, HTTPS, SMTP, SMTPS, or SSL.

Policy behavior parameters

ParameterDescription
ActionThe action applied to matching traffic: <br>- Allow: Traffic passes through. <br>- Deny: Traffic is blocked. No notifications are sent. <br>- Monitor: Traffic is recorded and allowed. Use this action to observe traffic patterns before deciding to allow or deny.
PriorityThe priority of this policy relative to others. Default: Lowest. Valid values: Highest (the access control policy has the highest priority) or Lowest (the access control policy has the lowest priority).
Policy Validity PeriodThe time range during which this policy is active. The policy only matches traffic within this period.
DescriptionA description that helps identify the policy.
StatusWhether the policy is active when created. If turned off, the policy is saved but not enforced until you enable it in the policy list.

Configure the ACL engine mode

After you create access control policies, configure the engine mode to determine how Unknown traffic is handled.

  1. On the Prevention Configuration > Access Control > NAT Border page, click ACL Engine Management in the upper-right corner of the policy list.

  2. In the ACL Engine Management - NAT Firewall panel, find the NAT gateway whose engine mode you want to change, then click Modify in the Engine Mode column.

  3. In the Change Engine Mode dialog box, select an engine mode and click OK.

    ModeBehavior
    Loose ModeTraffic identified as Unknown is automatically allowed. Use this mode to avoid disrupting workloads during initial policy setup.
    Strict ModeTraffic identified as Unknown is matched against all configured policies. If a Deny policy applies, the traffic is blocked. Use this mode for stricter security enforcement.

Manage existing policies

After a policy is created, use the following actions in the Actions column of the policy list:

  • Modify: Edit the policy configuration.

  • Copy: Duplicate the policy as a starting point for a new one.

  • Move: Change the policy's priority. Policies with lower priority are shifted down accordingly.

  • Delete: Remove the policy. After deletion, Cloud Firewall no longer manages the traffic this policy previously covered. Proceed with caution.

Important

After you delete a policy, Cloud Firewall no longer manages traffic on which the policy is originally in effect. Proceed with caution.

Monitor and tune policies

After your services have run for a period of time, review the Hits and Last Hit At columns in the policy list to see how often each policy has matched traffic.

Click the number in the Hits column to go to the Log Audit page and view detailed traffic logs. For more information, see Log audit.

image.png

Based on the hit data, adjust your policies as needed:

  • Change a Monitor policy to Allow or Deny once you have observed the traffic pattern.

  • Remove policies that no longer match any traffic.

  • Tighten or broaden destination or port ranges based on actual usage.

What's next