Configuring Security Group Rules
A security group is a collection of access control rules for ECSs and RDS DB instances that have the same security protection requirements and are mutually trusted in a VPC.
This section describes how to create a security group to enable specific IP addresses and ports to access RDS.
When you attempt to connect to an RDS DB instance through an EIP, you need to configure an inbound rule for the security group associated with the DB instance.
The default security group rule allows all outgoing data packets. ECSs and RDS DB instances can access each other if they are deployed in the same security group. After a security group is created, you can configure security group rules to control access from and to the DB instances in the security group.
- By default, you can create a maximum of 100 security groups in your cloud account.
- By default, you can add up to 50 security group rules to a security group.
- One RDS DB instance can be associated only with one security group.
- Too many security group rules will increase the first packet latency. You are advised to create no more than 50 rules for each security group.
- To enable access to an RDS DB instance from resources outside the security group, you need to configure an inbound rule for the security group associated with the RDS DB instance.
To ensure security of data and DB instances, you are advised to use the principle of least privilege for database access. Change the database port (default value: 3306), and set the IP address to the remote server's address or any IP address in the remote server's smallest subnet to control the access scope of the remote server.
If you use 0.0.0.0/0, RDS DB instances in the security group can be accessed from any IP address.
For details about the requirements of security group rules, see the Adding a Security Group Rule section in the Virtual Private Cloud User Guide.
- Log in to the management console.
- Click in the upper left corner and select a region and a project.
- Click in the upper left corner of the page and choose Database > Relational Database Service. The RDS console is displayed.
- On the Instance Management page, click the target DB instance name.
- Go to the security group page.
- In the Connection Information area on the Basic Information page, click the security group name.Figure 1 Connection information
- Alternatively, choose Connection Management in the navigation pane on the left. In the Security Group Rules area, click the security group name next to the Security Group field.Figure 2 Security group rules
- In the Connection Information area on the Basic Information page, click the security group name.
- On the Inbound Rules tab, click Add Rule. In the displayed dialog box, set required parameters to add an inbound rule.
Alternatively, choose Connection Management in the navigation pane on the left. In the Security Group Rules area, click Allow All IP or Add Inbound Rule.
You can click + to add more inbound rules.
Allow All IP allows all IP addresses to access RDS DB instances in the security group, which poses high security risks. Exercise caution when performing this operation.Figure 3 Adding an inbound rule
Table 1 Inbound rule parameter description
Protocol & Port
Protocol: specifies the network protocol. Currently, the value can be All, TCP, UDP, ICMP, GRE, or others.
Port: specifies the port or port range over which the traffic can reach your ECS.
When connecting to the DB instance through a public network, enter the port of the target DB instance.
Specifies the source of the security group rule. The value can be an IP address or a security group. For example:
- xxx.xxx.xxx.xxx/32 (IPv4 address)
- xxx.xxx.xxx.0/24 (subnet)
- 0.0.0.0/0 (any IP address)
Provides supplementary information about the security group rule. This parameter is optional.
The description can contain a maximum of 255 characters and cannot contain angle brackets (<) or (>).