Configuring an IP Address Blacklist or Whitelist Rule
This topic describes how to configure blacklist or whitelist rules to block, allow, or log only access requests of specific IP addresses or address ranges.
If you have enabled enterprise projects, you can select your enterprise project from the Enterprise Project drop-down list and add protection policies for the domain names in the project.
Prerequisites
A website has been added to WAF.
Specification Limitations
- For details about the quota for IP address blacklist and whitelist rules, see Edition Differences.
- If the quota for IP address whitelist and blacklist rules of your cloud WAF instance cannot meet your requirements, you can purchase rule expansion packages under the current WAF instance edition or upgrade your WAF instance edition to increase such quota.
A rule expansion package allows you to configure up to 10 IP address blacklist and whitelist rules. For details about how to upgrade WAF specifications, see Upgrading the WAF Edition and Specifications.
Constraints
- This function is unavailable in the detection edition.
- WAF does not support batch import of blacklists or whitelists. To configure multiple IP address or IP address range rules, add blacklist and whitelist rules one by one to allow or block specified IP addresses or IP address ranges.
- It takes several minutes for a new rule to take effect. After the rule takes effect, protection events triggered by the rule will be displayed on the Events page.
- The address 0.0.0.0/0 cannot be added to a WAF IP address blacklist or whitelist, and if a whitelist conflicts with a blacklist, the whitelist rule takes priority. If you want to allow only a specific IP address within a range of blocked addresses, add a blacklist rule to block the range and then add a whitelist rule to allow the individual address you wish to allow.
If you want to allow only specified IP addresses to access the protected website, see How Do I Allow Only Specified IP Addresses to Access the Protected Website?
- If you set Protective Action to Block for a blacklist or whitelist rule, you can configure a known attack source rule. WAF will block requests matching the configured IP address, Cookie, or Params for a length of time configured as part of the rule. For more details, see Configuring a Known Attack Source Rule
Impact on the System
If an IP address is added to a blacklist or whitelist, WAF blocks or allows requests from that IP address without checking whether the requests are malicious.
Procedure
- Log in to the management console.
- Go to the protection policy configuration page by following the steps shown in Figure 1.
- In the Blacklist and Whitelist configuration area, change Status if needed and click Customize Rule. Figure 2 shows an example.
- In the upper left corner of the Blacklist and Whitelist page, click Add Rule.
- In the displayed dialog box, specify the parameters by referring to Table 1. Figure 3 shows an example.
- If you select Log only for Protective Action for an IP address, WAF only identifies and logs requests from the IP address.
- Other IP addresses are evaluated based on other configured WAF protection rules.
Table 1 Rule parameters Parameter
Description
Example Value
IP Address/Range
IPv4 and IPv6 IP addresses or IP address ranges are supported.
- IP address: IP address to be added to the blacklist or whitelist
- IP address range: IP address and subnet mask defining a network segment
NOTICE:IPv6 protection is available in the professional (former enterprise) and platinum (former premium) editions only. Currently, IPv4/IPv6 dual stack and NAT64 are supported only in East China and North China regions.
- IPv4:
- 192.168.2.3
- 10.1.1.0/24
- IPv6: 1050:0:0:0:5:600:300c:326b
Protective Action
- Block: Select Block if you want to blacklist an IP address or IP address range.
- Allow: Select Allow if you want to whitelist an IP address or IP address range.
- Log only: Select Log only if you want to observe an IP address or IP address range. Then, WAF determines whether the IP address or IP address range can be blacklisted or whitelisted based on the events data.
Block
Known Attack Source
If you select Block for Protective Action, you can select a blocking type of a known attack source rule. WAF will block requests matching the configured IP address, Cookie, or Params for a length of time configured as part of the rule.
Long-term IP address blocking
Rule Description
A brief description of the rule. This parameter is optional.
None
- Click OK. You can then view the added rule in the list of blacklist and whitelist rules. Figure 4 Blacklist or whitelist rules
- To disable a rule, click Disable in the Operation column of the rule. The default Rule Status is Enabled.
- To modify a rule, click Modify in the row containing the rule.
- To delete a rule, click Delete in the row containing the rule.
Example Configuration - Allowing a Specified IP Addresses
To allow three IP addresses but block others:
Protection Effect
If you have added domain name www.example.com to this rule, to verify WAF is protecting the corresponding website:
- Clear the browser cache and enter the domain name in the address bar to check whether the website is accessible.
- If the website is inaccessible, connect the website domain name to WAF by following the instructions in Step 3: Routing Website Traffic to WAF.
- If the website is accessible, go to Step 2.
- Blacklist the IP address of a client according to the instructions in Procedure.
- Clear the browser cache and access http://www.example.com. Normally, WAF blocks such requests and returns the block page.
- Return to the WAF console. In the navigation pane, click Events. On the displayed page, view or download events data.
Last Article: Adding a Reference Table
Next Article: Configuring a Known Attack Source Rule




Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.