Create a security group rule
You can:
- create rules one by one — create an ingress traffic rule or an egress traffic rule via the Control panel or OpenStack CLI;
- bulk add rules from a file — prepare a
.jsonfile with the descriptions of the required rules and upload it to the Control panel.
Via the Control panel and adding a file, you can create a rule with the TCP, UDP, ICMP, or Any protocol. Via 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 an ingress traffic rule
Control panel
OpenStack CLI
-
In the Control panel, from the top menu, click Products and select Cloud Servers.
-
Go to the Security Groups section.
-
Open the security group page.
-
Open the Ingress tab.
-
Click Create rule.
-
If one of the ingress traffic rule templates works for you, select it from the list. The protocol, source, source ports, traffic destination, and destination port fields will be filled in automatically.
-
If the templates do not work, specify your own 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 choose the group. You can use security groups in the same pool. If you need to accept traffic from another pool, specify the source CIDR.
7.3. Enter the port to allow traffic on (Dst. port)—a single port or a range of ports, or click All ports.
7.4. Optional: enter a comment for the rule.
-
Click Create.
Create an egress traffic rule
Control panel
OpenStack CLI
-
In the Control panel, from the top menu, click Products and select Cloud Servers.
-
Go to the Security Groups section.
-
Open the security group page.
-
Open the Egress tab.
-
Click Create rule.
-
If one of the egress traffic rule templates works for you, select it from the list. The protocol, source, source ports, traffic destination, and destination port fields will be filled in automatically.
-
If the templates do not work, specify your own rule parameters:
7.1. Select a protocol or click All protocols.
7.2. Specify the traffic destination (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 choose the group. You can use security groups in the same pool. 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.
-
Click Create.
Bulk add rules from a file
1. Prepare a file with the rule descriptions
-
In the Control panel, from the top menu, click Products and select Cloud Servers.
-
Go to the Security Groups section.
-
Download the file to edit:
- to download a file containing the rules you previously created for another security group, in the menu of the required security group, select Download JSON with rules;
- to download a file with rule templates, in the menu of any security group, select Add rules from JSON and click the link in the text.
-
Open the downloaded file in any text editor.
-
Edit the file content—delete or add the required number of rule blocks, and specify the parameters for each rule:
-
direction—traffic direction:ingressfor incoming traffic,egressfor outgoing; -
ethertype— IP type: onlyIPv4; -
port_range_max—the last port in the allowed port range: a number from 1 to 65,535. If the rule protocol isicmp, specify an ICMP type instead of the port number. To allow all ports or ICMP types, specifynull; -
port_range_min—the first port in the allowed port range: a number from 1 to 65,535. If the rule protocol isicmp, specify an ICMP type instead of the port number. To allow all ports or ICMP types, specifynull; -
protocol—protocol name:icmp—ICMP;tcp—TCP;udp—UDP;anyornull—any protocol;
-
traffic source or destination — specify one of the parameters, and for the other, specify
null:remote_group_id—security group ID, can be viewed in the Control panel: from the top menu, click Products → Cloud Servers → Security Groups → in the group card, click . You can only specify a group in the same pool; for traffic from another pool, useremote_ip_prefix. To allow traffic from all security groups, specifynull;remote_ip_prefix—IP address or subnet in CIDR format. To allow traffic from all IP addresses, specifynull.
If you specify
nullfor both parameters, all traffic matching the other rule parameters will be allowed.
-
-
Save the modified file.
2. Upload the file to the Control panel
-
In the Control panel, from the top menu, click Products and select Cloud Servers.
-
Go to the Security Groups section.
-
In the menu of a security group, select Add rules from JSON.
-
Choose how to add the rules from the file:
- add new rules to the existing ones;
- or delete the old rules and add new ones.
-
Upload the file you prepared earlier —drag and drop it into the upload field or click the upload field to select the file.
-
Click Add or Delete and add.