Adding a Security Group Rule
Scenarios
After a security group is created, you can add rules to the security group. A rule applies either to inbound traffic or outbound traffic. After ECSs are added to the security group, they are protected by the rules of that group.
- Inbound rules control incoming traffic to ECSs associated with the security group.
- Outbound rules control outgoing traffic from ECSs associated with the security group.
For details about the default security group rules, see Default Security Groups and Security Group Rules. For details about security group rule configuration examples, see Security Group Configuration Examples.
Procedure
- Log in to the management console.
- Click
in the upper left corner and select the desired region and project. - Click Service List in the upper left corner. Under Networking, select Virtual Private Cloud.
- In the navigation pane on the left, choose Access Control > Security Groups.
- On the Security Groups page, locate the target security group and click Manage Rule in the Operation column.
- On the Inbound Rules tab page, click Add Rule. In the displayed Add Inbound Rule dialog box, configure required parameters.
You can click + to add more inbound rules.
Figure 1 Add Inbound Rule
Table 1 Inbound rule parameter descriptions Parameter
Description
Example Value
Protocol & Port
Protocol: The network protocol. The protocol can be All, TCP, UDP, ICMP, or GRE.
Custom TCP
Port: The port or port range over which the traffic can reach your ECS.
Supported range: 1 to 65535
For common ports, see Common Ports Used by ECSs.
22, or 22-30
Type
The IP address type. This parameter is available after the IPv6 function is enabled.
- IPv4
- IPv6
IPv4
Source
The source of the security group rule. The source can be another security group or a single IP address. For example:
- xxx.xxx.xxx.xxx/32 (IPv4 address)
- xxx.xxx.xxx.0/24 (subnet CIDR block)
- 0.0.0.0/0 (any IP address)
- sg-abc (security group)
0.0.0.0/0
Description
(Optional) Supplementary information about the security group rule.
The description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).
N/A
- On the Outbound Rules tab page, click Add Rule. In the displayed Add Outbound Rule dialog box, configure required parameters.
You can click + to add more outbound rules.
Figure 2 Add Outbound Rule
Table 2 Outbound rule parameter descriptions Parameter
Description
Example Value
Protocol & Port
Protocol: The network protocol. The protocol can be All, TCP, UDP, ICMP, or GRE.
Custom TCP
Port: The port or port range over which the traffic can leave your ECS.
Supported range: 1 to 65535
For common ports, see Common Ports Used by ECSs.
22, or 22-30
Type
The IP address type. This parameter is available after the IPv6 function is enabled.
- IPv4
- IPv6
IPv4
Source
The source of the security group rule. The source can be another security group or a single IP address. For example:
- xxx.xxx.xxx.xxx/32 (IPv4 address)
- xxx.xxx.xxx.0/24 (subnet CIDR block)
- 0.0.0.0/0 (any IP address)
- sg-abc (security group)
0.0.0.0/0
Description
(Optional) Supplementary information about the security group rule.
The description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).
N/A
- Click OK.
Verification
After adding the security group rules, you can check whether the rules take effect. For example, you have deployed a website on ECSs. Users need to access your website over HTTP and port 80, and you have added the security group rule shown in Table 3.
Linux ECS
To verify the security group rule on a Linux ECS:
- Log in to the ECS.
- Run the following command to check whether TCP port 80 is listened:
netstat -an | grep 80
If command output shown in Figure 3 is displayed, TCP port 80 is listened.
- Enter http://ECS EIP in the address box of the browser and press Enter.
If the requested page can be accessed, then the security group rule has taken effect.
Windows ECS
To verify the security group rule on a Windows ECS:
- Log in to the ECS.
- Choose Start > Accessories > Command Prompt.
- Run the following command to check whether TCP port 80 is listened:
netstat -an | findstr 80
If command output shown in Figure 4 is displayed, TCP port 80 is listened.
- Enter http://ECS EIP in the address box of the browser and press Enter.
If the requested page can be accessed, then the security group rule has taken effect.
Last Article: Creating a Security Group


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