Help Center/ Virtual Private Cloud/ User Guide/ IP Address Group/ IP Address Group Configuration Examples/ Using IP Address Groups to Reduce the Number of Security Group Rules
Updated on 2024-07-30 GMT+08:00

Using IP Address Groups to Reduce the Number of Security Group Rules

Scenarios

An IP address group is a collection of one or more IP addresses. You can use IP address groups when configuring security group rules. If you change the IP addresses in an IP address group, the security group rules are changed accordingly. You do not need to modify the security group rules one by one.

Finance and securities enterprises have high security requirements when planning cloud networks. Access to instances is often controlled based on IP addresses. To simplify security group rule configuration and control access based on IP addresses, you can use IP address groups to manage IP address ranges and IP addresses with the same security requirements. For more information about IP address groups, see IP Address Group Overview.

Suppose your enterprise has an online office system deployed on the cloud. To provide services for different departments, you associate office servers with different security groups based on security levels. These servers are accessed from a large number of IP addresses that may change from time to time.
  • If IP address groups are not used, you need to configure multiple rules to control access from different sources. Once the IP addresses change, you need to adjust the rules in each security group one by one. The management workload increases with the number of security groups and rules.
  • If IP address groups are used, you can add the IP addresses with the same security requirements to an IP address group and add rules with source set to this IP address group. When an IP address changes, you only need to change it in the IP address group. Then, the security group rules using the IP address group change accordingly. You do not need to modify the security group rules one by one. This simplifies security group management and improves efficiency.

Solution Architecture

In this practice, the instances are associated with three security groups based on different security requirements. In addition, these instances need to be accessed by specific IP addresses over SSH port 22. To simplify management, you can use IP address groups.
  1. Create an IP address group and add IP addresses that need to access the instances.
  2. Add inbound rules to allow traffic from the IP address group to the instances in the three security groups.
    Table 1 Inbound rules

    Direction

    Action

    Type

    Protocol & Port

    Source

    Inbound

    Allow

    IPv4

    TCP:22

    IP address group

  3. Change the IP addresses in the IP address group if any IP addresses change. Then, the rules using the IP address group change accordingly.

Constraints

Security group rules using IP address groups do not take effect for the following instances:

  • General computing (S1, C1, and C2 ECSs)
  • Memory-optimized (M1 ECSs)
  • High-performance computing (H1 ECSs)
  • Disk-intensive (D1 ECSs)
  • GPU-accelerated (G1 and G2 ECSs)
  • Large-memory (E1, E2, and ET2 ECSs)

Resource Planning

In this practice, the IP address group and security groups must be in the same region. For details, see Table 2. The following resource details are only examples. You can modify them as required.

Table 2 Resource planning

Resource

Quantity

Description

IP address group

1

Create an IP address group and add IP addresses that need to access the instances.
  • Name: ipGroup-A
  • Max. IP Addresses: Set it as required. In this practice, 20 is used.
  • IP Address Version: Set it as required. In this practice, IPv4 is used.
  • IP Addresses:
    • 11.xx.xx.64/32
    • 116.xx.xx.252/30
    • 113.xx.xx.0/25
    • 183.xx.xx.208/28

Security group

3

Add inbound rules to allow traffic from ipGroup-A to the instances in the three security groups, as shown in Table 3.

Table 3 Inbound rules

Direction

Action

Type

Protocol & Port

Source

Inbound

Allow

IPv4

TCP:22

ipGroup-A

Procedure

  1. Create IP address group ipGroup-A and add IP addresses that need to access the instances.

    For details, see Creating an IP Address Group.

  2. Add inbound rules to allow traffic from ipGroup-A to the instances in the three security groups.

    For details, see Adding a Security Group Rule.

    After the rules are added, traffic from 11.xx.xx.64/32, 116.xx.xx.252/30, 113.xx.xx.0/25, and 183.xx.xx.208/28 are allowed to the Linux ECSs over SSH port 22.

  3. Change IP addresses in the IP address group.

    After security group rules are added, you can add IP addresses to ipGroup-A. For example, you can add 117.xx.xx.0/25 to ipGroup-A, and the security groups rule is applied automatically, allowing traffic from 117.xx.xx.0/25 over SSH port 22.

    For details, see Managing IP Addresses in an IP Address Group.