To ensure the security and stability of Redis databases, the system blocks all IP addresses that attempt to access ApsaraDB for Redis instances by default. Before you use an ApsaraDB for Redis instance, you must add IP addresses or CIDR blocks that are used to access the ApsaraDB for Redis instance to the whitelists of the instance. We recommend that you periodically manage whitelists to secure access to and data in the ApsaraDB for Redis instances.

Prerequisites

  • The ApsaraDB for Redis instance is updated to the latest minor version. For more information about how to update the minor version, see Upgrade the minor version.
  • If you want to associate security groups of Elastic Compute Service (ECS) instances to configure whitelists for an ApsaraDB for Redis instance, the engine version of the ApsaraDB for Redis instance must be Redis 4.0 or later.

Methods to configure a whitelist

Method Description
Method 1: Configure a whitelist Manually add the IP address of a client to a whitelist of your ApsaraDB for Redis instance to allow the client to access the instance.
Method 2: Associate ECS security groups to configure whitelists A security group is a virtual firewall that is used to control the inbound and outbound traffic of ECS instances in the security group. To authorize multiple ECS instances to access an ApsaraDB for Redis instance, you can associate the ApsaraDB for Redis instance with the security group that contains these ECS instances. This method is more convenient than manually adding the IP addresses of the ECS instances to a whitelist.
Note You can configure one or more whitelists and associate ECS security groups with an ApsaraDB for Redis instance as whitelists at the same time. All IP addresses in the whitelists and ECS instances in the security groups are allowed to access the ApsaraDB for Redis instance.

Method 1: Configure a whitelist

  1. Log on to the ApsaraDB for Redis console.
  2. In the top navigation bar of the page, select the region where the instance is deployed.
  3. On the Instances page, click the ID of the instance.
  4. In the left-side navigation pane, click Whitelist Settings.
  5. Find the specific whitelist and click Modify.
    Note You can also click Add Whitelist to create another whitelist. The name of the whitelist must be 2 to 32 characters in length and can contain lowercase letters, digits, and underscores (_). It must start with a lowercase letter and end with a lowercase letter or digit.
  6. In the dialog box that appears, perform one of the following operations:
    • Manually modify the whitelist

      Enter IP addresses or CIDR blocks.

      Figure 1. Manually modify the whitelist
      Manually modify the whitelist
      Note
      • Separate multiple IP addresses with commas (,). A maximum of 1,000 unique IP addresses can be added. Supported formats are specific IP addresses such as 10.23.12.24 and CIDR blocks such as 10.23.12.24/24. /24 indicates the length of the IP address prefix. An IP address prefix can be 1 to 32 bits in length.
      • If you set the prefix length to 0, for example, 0.0.0.0/0 or 127.0.0.1/0, all IP addresses are allowed to access the instance. This poses a high security risk. Proceed with caution.
    • Add private IP addresses of ECS instances to the whitelist
      1. Click Load ECS Internal Network IP.
      2. Select IP addresses based on your business requirements.
        Figure 2. Add private IP addresses of ECS instances
        Add private IP addresses of ECS instances
        Note To find the ECS instance that is assigned a specific IP address, you can move the pointer over the IP address. Then, the system displays the ID and name of the ECS instance to which the IP address is assigned.
    • Clear a whitelist

      To remove all IP addresses from a whitelist but retain the whitelist, click Delete.

  7. Click OK.

Method 2: Associate ECS security groups to configure whitelists

You can associate security groups to configure whitelists for your ApsaraDB for Redis instance. Then, the ECS instances in the security groups can access the ApsaraDB for Redis instance over an internal network or the Internet. If you want to access the ApsaraDB for Redis instance over the Internet, make sure that the ApsaraDB for Redis instance has a public endpoint. For more information, see Use a public endpoint to connect to an ApsaraDB for Redis instance.

Note Before you associate a security group with an ApsaraDB for Redis instance, make sure that the network types of the ApsaraDB for Redis instance and the ECS instances in the security group are the same. If the network types of the ApsaraDB for Redis instance and ECS instances are VPC, make sure that they are deployed in the same VPC.
Region Region ID (used in the ApsaraDB for Redis API) Region Region ID (used in the ApsaraDB for Redis API)
China (Hangzhou) cn-hangzhou China (Shanghai) cn-shanghai
China (Qingdao) cn-qingdao China (Beijing) cn-beijing
China (Zhangjiakou) cn-zhangjiakou China (Hohhot) cn-huhehaote
China (Shenzhen) cn-shenzhen China (Chengdu) cn-chengdu
China (Hong Kong) cn-hongkong Singapore (Singapore) ap-southeast-1
Australia (Sydney) ap-southeast-2 Malaysia (Kuala Lumpur) ap-southeast-3
Indonesia (Jakarta) ap-southeast-5 Japan (Tokyo) ap-northeast-1
Germany (Frankfurt) eu-central-1 UK (London) eu-west-1
US (Virginia) us-east-1 India (Mumbai) ap-south-1
UAE (Dubai) me-east-1

  1. Log on to the ApsaraDB for Redis console.
  2. In the top navigation bar of the page, select the region where the instance is deployed.
  3. On the Instances page, click the ID of the instance.
  4. In the left-side navigation pane, click Whitelist Settings.
  5. Click Add Security Group.
  6. In the dialog box that appears, select the security groups that you want to associate.
    Figure 3. Associate security groups
    Associate security groups
    Note
    • You can identify a security group by moving the pointer over the ID of the security group. Then, the system displays the name and description of the security group. If you move the pointer over the VPC icon, you can view the ID of the VPC.
    • You can associate up to 10 security groups with each ApsaraDB for Redis instance.
  7. Click OK.
  8. Optional:To remove all security groups, click Delete.

Common solutions

Related API operations

Operation Description
DescribeSecurityIps Queries the whitelists of an ApsaraDB for Redis instance.
ModifySecurityIps Configures whitelists for an ApsaraDB for Redis instance.
DescribeSecurityGroupConfiguration Queries the security groups that are associated with an ApsaraDB for Redis instance.
ModifySecurityGroupConfiguration Modifies the security groups that are associated with an ApsaraDB for Redis instance.

FAQ

  • Q: Why are whitelists automatically created for ApsaraDB for Redis instances? Can I delete these whitelists?

    A: When you create an ApsaraDB for Redis instance, a default whitelist is automatically created. After you perform specific operations on the instance, more whitelists are automatically created. For more information, see the following table.

    Whitelist name Source
    default The default whitelist, which cannot be deleted.
    ali_dms_group This whitelist is automatically created by Data Management (DMS) when you log on to an ApsaraDB for Redis instance by using DMS. For more information, see Use DMS. Do not delete or modify this whitelist. Otherwise, you may fail to log on to the ApsaraDB for Redis instance by using DMS.
    hdm_security_ips This whitelist is automatically created by Database Autonomy Service (DAS) when you use CloudDBA features, such as Use the cache analytics feature to find big keys. Do not delete or modify this whitelist. Otherwise, the CloudDBA features may become unavailable.
  • Q: A whitelist contains IP address 127.0.0.1 in addition to client IP addresses. In this case, can the clients with the specified IP addresses connect to the ApsaraDB for Redis instance?

    A: The clients can connect to the ApsaraDB for Redis instance. If only 127.0.0.1 exists in the whitelist, all IP addresses are blocked from connecting to the ApsaraDB for Redis instance.

  • Q: Why does the (error) ERR illegal address message appear after I use redis-cli to connect to an ApsaraDB for Redis instance?

    A: The IP address of the client where you run redis-cli is not added to a whitelist of the ApsaraDB for Redis instance. You must check the whitelists of the ApsaraDB for Redis instance.

  • Q: If the IP address of my client is not added to a whitelist of an ApsaraDB for Redis instance, can I check port connectivity by running the telnet command?
    A: Yes. The following message is returned after you run the telnet command:
    Escape character is '^]'.
    Connection closed by foreign host.