Updated on 2022-01-25 GMT+08:00

Security Group Configuration Examples

Common security group configurations are presented here. The examples in this section allow all outgoing data packets by default. This section will only describe how to configure inbound rules.

You can use the default security group or create a security group in advance. For details, see sections Creating a Security Group and Adding a Security Group Rule.

Allowing External Access to a Specified Port

  • Example scenario:

    After services are deployed, you can add security group rules to allow external access to a specified port (for example, 1100).

  • Security group rule:

    Direction

    Protocol

    Port

    Source

    Inbound

    TCP

    1100

    0.0.0.0/0

Enabling ECSs in Different Security Groups to Communicate with Each Other Through an Internal Network

  • Example scenario:

    Resources on an ECS in a security group need to be copied to an ECS associated with another security group. The two ECSs are in the same VPC. We recommend that you enable private network communication between the ECSs and then copy the resources.

  • Security group configuration:

    Within a given VPC, ECSs in the same security group can communicate with one another by default. However, ECSs in different security groups cannot communicate with each other by default. To enable these ECSs to communicate with each other, you need to add certain security group rules.

    You can add an inbound rule to the security groups containing the ECSs to allow access from ECSs in the other security group. The required rule is as follows.

    Direction

    Protocol/Application

    Port

    Source

    Inbound

    Used for communication through an internal network

    Port or port range

    ID of another security group

Enabling Specified IP Addresses to Remotely Access ECSs in a Security Group

  • Example scenario:

    To prevent ECSs from being attacked, you can change the port number for remote login and configure security group rules that allow only specified IP addresses to remotely access the ECSs.

  • Security group configuration:

    To allow IP address 192.168.20.2 to remotely access Linux ECSs in a security group over the SSH protocol (port 22), you can configure the following security group rule.

    Direction

    Protocol/Application

    Port

    Source

    Inbound

    SSH (22)

    22

    IPv4 CIDR block or ID of another security group

    For example, 192.168.20.2/32

Remotely Connecting to Linux ECSs Using SSH

  • Example scenario:

    After creating Linux ECSs, you can add a security group rule to enable remote SSH access to the ECSs.

    The default security group comes with the following rule. If you use the default security group, you do not need to add this rule again.

  • Security group rule:

    Direction

    Protocol/Application

    Port

    Source

    Inbound

    SSH (22)

    22

    0.0.0.0/0

Remotely Connecting to Windows ECSs Using RDP

  • Example scenario:

    After creating Windows ECSs, you can add a security group rule to enable remote RDP access to the ECSs.

    The default security group comes with the following rule. If you use the default security group, you do not need to add this rule again.

  • Security group rule:

    Direction

    Protocol/Application

    Port

    Source

    Inbound

    RDP (3389)

    3389

    0.0.0.0/0

Enabling Communication Between ECSs

  • Example scenario:

    After creating ECSs, you need to add a security group rule so that you can run the ping command to test communication between the ECSs.

  • Security group rule:

    Direction

    Protocol/Application

    Port

    Source

    Inbound

    ICMP

    All

    0.0.0.0/0

Hosting a Website on ECSs

  • Example scenario:

    If you deploy a website on your ECSs and require that your website be accessed over HTTP or HTTPS, you can add rules to the security group used by the ECSs that function as the web servers.

  • Security group rule:

    Direction

    Protocol/Application

    Port

    Source

    Inbound

    HTTP (80)

    80

    0.0.0.0/0

    Inbound

    HTTPS (443)

    443

    0.0.0.0/0

Enabling an ECS to Function as a DNS Server

  • Example scenario:

    If you need to use an ECS as a DNS server, you must allow TCP and UDP access from port 53 to the DNS server. You can add the following rules to the security group associated with the ECS.

  • Security group rules:

    Direction

    Protocol/Application

    Port

    Source

    Inbound

    TCP

    53

    0.0.0.0/0

    Inbound

    UDP

    53

    0.0.0.0/0

Uploading or Downloading Files Using FTP

  • Example scenario:

    If you want to use File Transfer Protocol (FTP) to upload files to or download files from ECSs, you need to add a security group rule.

    You must first install the FTP server program on the ECSs and check whether ports 20 and 21 are working properly.

  • Security group rule:

    Direction

    Protocol/Application

    Port

    Source

    Inbound

    TCP

    20-21

    0.0.0.0/0