You can configure blacklist and whitelist rules to block, log only, or allow access requests from specific IP addresses or IP address ranges. Whitelist rules have a higher priority than blacklist rules.
If you have enabled enterprise projects, ensure that you have all operation permissions for the project where your WAF instance locates. Then, you can select the project from the Enterprise Project drop-down list and configure protection policies for the domain names in the project.
Prerequisites
A website has been added to WAF.
Constraints
- 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.
- 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 set Protective Action to Block for a blacklist or whitelist rule, you can set a known attack source to block the visitor for a certain period of time; however, the known attack source with Long-term IP address blocking or Short-term IP address blocking configured cannot be set for a blacklist or whitelist rule. WAF will block requests matching the configured Cookie or Params for a block duration you specify.
- 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.
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.
Configuring an IP Address Blacklist or Whitelist Rule
- Log in to the management console.
- Click
in the upper left corner of the management console and select a region or project. - Click
in the upper left corner and choose Web Application Firewall (Dedicated) under Security. - In the navigation pane on the left, choose Policies.
- Click the name of the target policy to go to the protection configuration page.
- In the Blacklist and Whitelist configuration area, change Status as needed and click Customize Rule.
Figure 1 Blacklist and Whitelist configuration area
- In the upper left corner above the Blacklist and Whitelist list, click Add Rule.
- In the displayed dialog box, specify the parameters by referring to Table 1.
- 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.
Figure 2 Adding a blacklist or whitelist rule
Table 1 Rule parametersParameter
|
Description
|
Example Value
|
Rule Name
|
Rule name you entered.
|
WAF
|
IP Address/Range
|
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
|
XXX.XXX.2.3
|
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 are 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 Cookie or Params for a length of time configured as part of the rule.
NOTE: Do not select the Long-term IP address blocking for a long time or Short-term IP address blocking for Blocking Type.
|
Long-term Cookie blocking
|
Rule Description
|
A brief description of the rule. This parameter is optional.
|
None
|
- Click Confirm. You can then view the added rule in the list of blacklist and 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.
Protection Effect
To verify WAF is protecting your website (www.example.com) against a rule:
- 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 1: Add a Website to WAF.
- If the website is accessible, go to Step 2.
- Blacklist the IP address of a client according to the instructions in Configuring an IP Address Blacklist or Whitelist Rule.
- 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 the event log.
Example Configuration - Allowing a Specified IP Addresses
If domain name www.example.com has been connected to WAF, you can perform the following steps to verify the rule takes effect:
- Add the following two blacklist and whitelist rules to block all IP addresses:
Figure 3 Blocking IP address range 1.0.0.0/1
Figure 4 Blocking IP address range 128.0.0.0/1
You can also add a precise protection rule to block all access requests, as shown in Figure 5.
Figure 5 Blocking all access requests
For details, see Configuring Custom Precise Protection Rules.
- Refer to Figure 6 and add a whitelist rule to allow a specified IP address, for example, XXX.XXX.2.3.
Figure 6 Allowing the access of a specified IP address
- Enable the white and blacklist protection.
- Clear the browser cache and access http://www.example.com.
If the IP address of a visitor is not the one specified in Step 2, WAF blocks the access request. Figure 7 shows an example of the block page.
Figure 7 Block page
- Go to the WAF console. In the navigation pane on the left, choose Events. View the event on the Events page.