By default, the Cloud Firewall internet firewall allows all traffic until you configure access control policies. To prevent unauthorized access, you can create outbound and inbound policies for your Internet-facing assets.
Prerequisites
The Internet Firewall is enabled, and protection for your Internet-facing assets is enabled. For more information, see Enable the Internet firewall. For information about the scope of Internet-facing assets that Cloud Firewall can protect, see Protection scope.
Ensure you have a sufficient policy quota. You can view your quota usage on the page. For information about how policy quotas are calculated, see Overview of access control policies.
If your available quota is insufficient, click Increase Quota to purchase a Quota for Additional Policy. For more information, see Purchase Cloud Firewall.
In the Usage area, view the Used/Edition Quota (for example, 14/10000) and Additional Quota (for example, 0/0) values to determine if your remaining quota is sufficient.
To add multiple objects as a source or destination, create an address book first. For more information, see Address books.
Configure access control policies for the Internet firewall
Cloud Firewall provides the following methods to configure access control policies:
Create a custom access control policy: You can create a custom policy that meets your business requirements.
Apply a recommended intelligent policy: Cloud Firewall learns your traffic patterns over the last 30 days, identifies potential risks, and recommends access control policies, which you can then review and apply.
Apply a recommended common policy: You can apply a built-in recommended common policy.
For exposed public IPs, create policies to allow traffic on open, active ports, and deny all access to other ports. This reduces the attack surface of your assets on the internet.
To allow trusted sources (such as IP addresses and domain names) and deny all other sources, first create a high-priority allow policy for the trusted sources, and then create a low-priority deny policy that matches all sources.
Recommended policies do not take effect until you apply them.
Configuring an outbound policy to allow traffic to specific regions does not increase the risk of inbound attacks, such as DDoS. Outbound policies only control traffic initiated from internal assets and do not open any inbound ports. We recommend that you follow the principle of least privilege and allow traffic to only the necessary destination regions and ports.
Custom policy
You can create custom outbound and inbound policies for the internet firewall.
Log on to the Cloud Firewall console.
In the left-side navigation pane, choose .
On the Outbound or Inbound tab, select the IP version and then click Create Policy. IPv4 is selected by default.
In the Create Outbound Policy or Create Inbound Policy panel, click Create Policy.
Configure the policy details based on the following tables, and then click OK.
NoteNote the following when you configure IP addresses:
Address format requirements: Use commas (,) or line feeds to separate multiple IP address segments. Semicolons or spaces are not supported. A single IP address must include a subnet mask, for example, 192.168.1.1/32.
IPv6 policy matching rules: When you create an IPv6 policy, the source and destination addresses must both be in IPv6 format.
0.0.0.0/0 coverage: In an inbound policy, a destination address of 0.0.0.0/0 matches all IPv4 public assets but does not include IPv6 assets. To cover IPv6 assets, you must create a separate IPv6 policy.
Configuration for proxy scenarios: When you use proxy services such as WAF (with CNAME access), Anti-DDoS, or ESA, Cloud Firewall detects the source IP address of inbound traffic as the proxy's back-to-origin IP address, not the real client IP address. When you configure the source address for an inbound policy, reference the system's built-in Cloud Service IP Address Book to ensure that back-to-origin traffic is allowed.
Intelligent policy
You can apply recommended intelligent policies for outbound and inbound traffic.
Applying a policy carries risks. Review the policy details carefully before you apply it.
Ignored recommendations cannot be restored. Proceed with caution.
In the left-side navigation pane, choose .
In the upper-right corner of the policy list, click Agent Policy Generation to go to the SecOps Agent page.
View the recommended intelligent policies. In the section for the policy that you want to apply, click Apply Policy.
Common policy
Applying a policy carries risks. Review the policy details carefully before you apply it.
Ignored recommendations cannot be restored. Proceed with caution. If you ignore all common policy recommendations, the Recommended Common Policy tab is hidden.
In the left-side navigation pane, choose .
On the Outbound or Inbound tab, click Create Policy, and then click the Recommended Common Policy tab.
View the recommended common policies. In the section for the policy that you want to apply, click Quick Apply.
ACL engine mode
The ACL engine for the internet firewall supports Loose Mode and Strict Mode:
Loose Mode (Default): In Loose Mode, traffic from unidentified applications or to unidentified domain names is allowed to prioritize service availability.
Strict Mode: In Strict Mode, traffic from unidentified applications or to unidentified domain names is matched against your policies. If a matching deny policy exists, this unidentified traffic is denied.
You can configure the ACL engine mode in one of the following three ways: as a default for new assets, for a single asset, or for multiple assets in batches. On the page, click ACL Engine Management in the upper-right corner of the access control policy list. Then, configure the settings in the Access Control Engine Management - Internet Border panel.
Default mode for new assets
Change mode per asset
Change mode in batches
View policy hit statistics
After your business has been running for a period, you can view the hit count of access control policies in the Hits/Last Hit At column in the access control policy list.
Click the hit count to go to the Traffic Logs page to view traffic logs. For information about how to view traffic logs, see Traffic Logs.

Related operations
From the policy list, you can edit, delete (individually or in batches), download, copy, or move custom policies. Moving a policy changes its priority.
The priority of an access control policy can be set from 1 to N, where N is the number of existing policies. A smaller number indicates a higher priority. When you change a policy's priority, the priorities of lower-ranked policies are adjusted automatically.
When a policy is deleted, its associated traffic is no longer managed by Cloud Firewall's access control. Delete policies with caution.
FAQ
What are the best practices for configuring inbound policies?
Most network attacks originate from the public network. Configure security policies that meet your business needs. We recommend using a whitelist. Set a low-priority, catch-all policy to drop all traffic. Then, add specific allow policies with higher priority.
Configuration recommendations:
Rule order: Always place whitelist rules before the catch-all rule. Before you deploy, add allow rules for your production services above the drop policy.
Grayscale validation: Initially, set the action of the catch-all policy to Monitor. Analyze the traffic using Log Audit and adjust the policy to allow only trusted traffic. After a full trial run, change the action to Drop.
Environment isolation: You can enable the catch-all policy for your entire staging environment. For your production environment, if you cannot create a complete whitelist right away, limit the source address of the catch-all policy to your test IP segment. This prevents disruption to your production services.
Why is the policy to drop foreign IPs not working?
If your policy to drop international IP addresses is not working, check the following scenarios:
Scenario 1: Your service uses a WAF CNAME
When traffic passes through Web Application Firewall (WAF) to your origin server, Cloud Firewall detects the source IP of the WAF origin fetch node instead of the original client IP. This makes location-based blocking policies ineffective.
Recommendation: Configure geo-blocking rules in the WAF console. This blocks requests from outside your specified regions at the traffic entry point.Scenario 2: The public IP address of the test client is not what you expect
If you test from a corporate network, VPN, or proxy server, Cloud Firewall detects the public IP of the gateway or proxy. It does not detect the real IP of your test device. This can cause the detected location to differ from your policy settings.
Recommendation: You can test by directly accessing the target public IP from an independent public network, such as a mobile data network or home broadband.Scenario 3: The policy parameters are incorrect
Verify that the following key configuration items are set correctly:
Source Type: For an inbound policy, the Source Type must be set to Location. Then, specify "International" or select specific countries or regions.
Action: The policy Action must be set to Drop.
Priority: Ensure that this block policy has a higher priority than any allow policies for the same destination. This prevents a high-priority whitelist rule from overriding it.
Can a policy with a drop action reduce Cloud Firewall traffic fees?
A policy with a Drop action does not reduce your Cloud Firewall traffic fees. This policy blocks traffic from reaching your backend services and reduces the load on your origin server. However, because the traffic has already been inspected by Cloud Firewall, it is still included in your billable traffic.
When a private ECS instance accesses the public network through an Internet NAT Gateway, should I configure an Internet firewall or a NAT firewall?
Configure a NAT firewall when a private ECS instance accesses the public network through an Internet NAT Gateway.
If you only use the NAT Gateway for outbound access and do not expose any public IPs or other public assets, the Internet firewall does not apply to the NAT traffic. Outbound traffic is not managed by Internet firewall policies, so you do not receive targeted security protection.
When WAF uses the cloud native mode, does Cloud Firewall detect the real client IP for inbound traffic?
Yes, it does. When you connect your assets using the WAF cloud native mode, Cloud Firewall detects the real client IP as the source IP for inbound traffic. This mode uses a transparent proxy or an SDK integration. It does not forward traffic from a WAF origin fetch IP. Therefore, it can directly obtain and pass the original client IP.