A security group consists of inbound and outbound rules to control the traffic that is allowed to flow into or out of instances (such as ECSs) in the security group. Security group rules are commonly used to allow or deny network traffic from specific sources or over specific protocols, block certain ports, and define specific access permissions for instances.
Before adding a security group rule, note the following:
Direction | Priority | Action | Type | Protocol & Port | Source/Destination |
|---|---|---|---|---|---|
Inbound | 1 | Allow | IPv4 | All | Source: current security group (Sg-A) |
Inbound | 1 | Allow | IPv6 | All | Source: current security group (Sg-A) |
You can use VPC peering connections to connect different VPCs.
Before configuring security group rules, you need to plan access policies for instances in the security group.
Security Group Examples shows more security group rule configuration examples.
After allowing traffic over a port in a security group rule, you need to ensure that the port used by the instance is also opened.
For example, if you have deployed a website on an ECS and want users to access your website through HTTP (80), you need to add an inbound rule to the ECS security group to allow access over the port. Table 5 shows the rule.
Direction | Priority | Action | Type | Protocol & Port | Source |
|---|---|---|---|---|---|
Inbound | 1 | Allow | IPv4 | TCP: 80 | IP address: 0.0.0.0/0 |
After adding the security group rule, perform the following operations to check whether the ECS port is opened and whether the rule is applied:
Run the following command to check whether TCP port 80 is being listened on:
netstat -an | grep 80
If the following figure is displayed, TCP port 80 is enabled.
Figure 1 Command output for the Linux ECS

netstat -an | findstr 80
If the following figure is displayed, TCP port 80 is enabled.
Figure 2 Command output for the Windows ECS

If the requested page can be accessed, the security group rule has taken effect.