Skip to main content

Create a rule in a security group

Last update:

You can:

Through the Control Panel and Add File, you can create a rule with TCP, UDP, ICMP, or Any (all protocols).Through the OpenStack CLI, you can create a rule with any protocol.

You can also copy rules from one security group to another, to do this, copy the security group.

Create a rule for incoming traffic

  1. In the dashboard, on the top menu, click Products and select Cloud Servers.

  2. Go to the Security Groups section.

  3. Open the security group page.

  4. Open the Incoming Traffic tab.

  5. Click Create Rule.

  6. If one of the rule templates for incoming traffic is suitable for you, select a template from the list. The Protocol, Source, Source Ports, Traffic Destination, and Destination Port fields are filled in automatically.

  7. If the templates don't fit, specify your rule parameters:

    7.1. Select a protocol or click All Protocols.

    7.2 Specify the traffic source (Source):

    • for traffic from an IP address or subnet — select CIDR and enter the IP address or subnet, or click All Sources;
    • for traffic from a security group — select Security Group and select the group. Security groups in the same pool are available. If you need to accept traffic from another pool, specify the source CIDR.

    7.3 Enter the port on which traffic is allowed to be received (Dst. port) — a single port or a range of ports, or click All Ports.

    7.4 Optional: enter a comment for the rule.

  8. Click Create.

Create a rule for outgoing traffic

  1. In the Dashboard, on the top menu, click Products and select Cloud Servers.

  2. Go to the Security Groups section.

  3. Open the security group page.

  4. Open the Outgoing Traffic tab.

  5. Click Create Rule.

  6. If one of the rule templates for outgoing traffic is suitable for you, select a template from the list. The Protocol, Source, Source Ports, Traffic Destination, and Destination Port fields are filled in automatically.

  7. If the templates don't fit, specify your rule parameters:

    7.1. Select a protocol or click All Protocols.

    7.2 Specify the destination of the traffic (Destination):

    • for traffic from an IP address or subnet — select CIDR and enter the IP address or subnet or click All Sources;
    • for traffic from a security group — select Security Group and select the group. Security groups in the same pool are available. If you need to send traffic to another pool, specify the source CIDR.

    7.3 Enter the source port (Src. port) — a single port or a range of ports or click All Ports.

    7.4 Optional: enter a comment for the rule.

  8. Click Create.

Add rules from a file en masse

  1. Prepare a file describing the rules.
  2. Upload the file to the control panel.

1. Prepare a file describing the rules

  1. In the dashboard, on the top menu, click Products and select Cloud Servers.

  2. Go to the Security Groups section.

  3. Open the security group page.

  4. From the menu of the security group, select Add Rules from JSON.

  5. Click on the link in the text to download the file template.

  6. Open the file in any text editor.

  7. Edit the content of the file — delete or add the required number of blocks with rules, specify parameters for each rule:

    • direction — traffic direction: ingress for incoming traffic, egress for outgoing traffic;

    • ethertype — IP type: IPv4 or IPv6;

    • port_range_max — last port in the allowed port range: a number from 1 to 65,535.If the protocol of the rule is icmp instead of the port number, specify the ICMP type.To allow all ports or ICMP types, specify null;

    • port_range_min — the first port in the allowed port range: a number from 1 to 65,535.If the protocol of the rule is icmp instead of the port number, specify the ICMP type.To allow all ports or ICMP types, specify null;

    • protocol — protocol name:

      • icmp — ICMP;
      • tcp — TCP;
      • udp — UDP;
      • any or null — any protocol;
    • traffic source or destination — specify one of the parameters, specify null for the other:

      • remote_group_id — Security group ID, can be viewed in control panel: in the top menu, click ProductsCloud ServersSecurity Groups → in the group card, click .You can only specify a group in the same pool, for traffic from another pool use remote_ip_prefix.To allow traffic from all security groups, specify null;
      • remote_ip_prefix — IP address or subnet in CIDR format.To allow traffic from all IP addresses, specify null.

      If you specify null for both parameters, all traffic matching the other rule parameters will be allowed.

  8. Save the modified file.

2. Upload the file to the control panel

  1. In the dashboard, on the top menu, click Products and select Cloud Servers.

  2. Go to the Security Groups section.

  3. Open the security group page.

  4. From the Security Group menu, select Add Rules from JSON.

  5. Choose how to add rules from the file to existing rules in the group:

    • add new rules to the old ones;
    • or delete old rules and add new ones.
  6. Upload the file you prepared earlier — drag and drop it into the upload box or click on the upload box and select the file.

  7. Click Add or Delete and add.