Skip to main content

Managing Security Groups

Managing firewall groups (security groups) and access rules in Arvancloud Cloud Server.

Overview​

The security-group commands provide tools for managing firewall groups and their rules. Firewall groups control the inbound and outbound network traffic of your servers.

Alias: sg

Commands​

1. Listing Security Groups​

Shows the list of all firewall groups, with filtering options.

arvan iaas security-group list

Alias: ls

Flags:

  • --region, -r: filter by region code (such as ir-central1)
  • --az, -a: filter by data center (such as ir-central1-a)

Example:

$ arvan iaas security-group list --region=ir-central1

Output:

ID NAME DESCRIPTION RULES AZ
sg-1a2b3c4d-5678-90ab-cdef-123456789 default Default security group 8 ir-central1-a
sg-2b3c4d5e-6789-01bc-def0-234567890 web-servers Web server security group 5 ir-central1-a

2. Showing Security Group Details​

Shows detailed information about a specific firewall group.

arvan iaas security-group show <security-group-id>

Alias: sh

Arguments:

  • security-group-id (required): the firewall group ID

Example:

$ arvan iaas security-group show sg-1a2b3c4d-5678-90ab-cdef-123456789

Output:

SECURITY GROUP DETAILS
----------------------
ID: sg-1a2b3c4d-5678-90ab-cdef-123456789
Name: web-servers
Description: Web server security group
AZ: ir-central1-a
Created: 2025-01-10T10:00:00Z


SUMMARY
-------
Total Rules: 5
Ingress Rules: 3
Egress Rules: 2

3. Creating a Security Group​

Creates a new firewall group in the specified data center.

arvan iaas security-group add <security-group-name>

Arguments:

  • security-group-name (required): the firewall group name

Flags:

  • --description, -d: a description for the firewall group
  • --az, -a: the data center to create the firewall group in (required)

Example:

$ arvan iaas security-group add app-servers --description "Application server security group" --az ir-central1-a

Output:

Security group created successfully!

ID: sg-4d5e6f7g-8901-23de-f012-456789012345
Name: app-servers
Description: Application server security group
AZ: ir-central1-a

4. Deleting a Security Group​

Deletes a firewall group from the account.

arvan iaas security-group delete <security-group-id>

Alias: del

Arguments:

  • security-group-id (required): the ID of the firewall group to delete

Example:

$ arvan iaas security-group delete sg-1a2b3c4d-5678-90ab-cdef-123456789

Output:

Security group 'sg-1a2b3c4d-5678-90ab-cdef-123456789' has been deleted.

5. Adding a Firewall Rule​

Adds a new rule to a firewall group.

arvan iaas security-group add-rule <security-group-id>

Alias: ar

Arguments:

  • security-group-id (required): the firewall group ID

Flags:

  • --direction, -d: the traffic direction: ingress (inbound) or egress (outbound) (default: ingress)
  • --ether-type, -e: the network protocol type: IPv4 or IPv6 (default: IPv4)
  • --protocol, -p: the protocol: tcp, udp, icmp, or empty for all protocols
  • --port-min: the lowest port number (0 for any port)
  • --port-max: the highest port number (0 for any port)
  • --remote-ip, -r: the destination/source IP address in CIDR format (example: 0.0.0.0/0)
  • --desc: a description for this rule

Example:

$ arvan iaas security-group add-rule sg-1a2b3c4d --direction=ingress --protocol=tcp --port-min=8080 --port-max=8080 --remote-ip=0.0.0.0/0 --desc="Application port"

Output:

SECURITY GROUP RULE ADDED
-------------------------
Security Group: sg-1a2b3c4d-5678-90ab-cdef-123456789
Rule ID: rule-6f7g8h9i-0123-45de-f012-678901234567
Direction: ingress
Protocol: tcp
Port Range: 8080-8080
Remote IP: 0.0.0.0/0
Description: Application port

Rule added successfully!

6. Deleting a Firewall Rule​

Deletes a rule from an existing firewall group.

arvan iaas security-group delete-rule <security-group-id> <rule-id>

Alias: dr

Arguments:

  • security-group-id (required): the firewall group ID
  • rule-id (required): the ID of the rule to delete

Example:

$ arvan iaas security-group delete-rule sg-1a2b3c4d rule-1a2b3c4d-5678-90ab-cdef-1234567

Output:

Rule 'rule-1a2b3c4d-5678-90ab-cdef-1234567' has been deleted from security group 'sg-1a2b3c4d'.

7. Attaching a Security Group to a Port​

Attaches a firewall group to a network port to apply its rules on that port.

arvan iaas security-group attach <security-group-id> <port-id>

Alias: att

Arguments:

  • security-group-id (required): the firewall group ID
  • port-id (required): the ID of the network port to attach to

Flags:

  • --force, -f: skip confirmation

Example:

$ arvan iaas security-group attach bc2140c6-ed92-41b1-a6d8-550b74441216 86468ef7-01ab-4dff-a7ef-f7077d9c919b

Output:

SECURITY GROUP ATTACHED:
Security Group ID: bc2140c6-ed92-41b1-a6d8-550b74441216
Port ID: 86468ef7-01ab-4dff-a7ef-f7077d9c919b
Status: Instance 192.168.1.9 port connected to the firewall

8. Detaching a Security Group from a Port​

Detaches a firewall group from a network port and removes the firewall rules from that port.

arvan iaas security-group detach <security-group-id> <port-id>

Alias: det

Arguments:

  • security-group-id (required): the firewall group ID
  • port-id (required): the ID of the network port to detach from

Flags:

  • --force, -f: skip confirmation

Example:

$ arvan iaas security-group detach bc2140c6-ed92-41b1-a6d8-550b74441216 86468ef7-01ab-4dff-a7ef-f7077d9c919b

Output:

SECURITY GROUP DETACHED:
Security Group ID: bc2140c6-ed92-41b1-a6d8-550b74441216
Port ID: 86468ef7-01ab-4dff-a7ef-f7077d9c919b
Status: Instance 192.168.1.9 port disconnected from the firewall

Common Scenarios​

Allowing HTTP and HTTPS Traffic​

arvan iaas security-group add-rule <sg-id> --direction=ingress --protocol=tcp --port-min=80 --port-max=80 --remote-ip=0.0.0.0/0 --desc="HTTP"
arvan iaas security-group add-rule <sg-id> --direction=ingress --protocol=tcp --port-min=443 --port-max=443 --remote-ip=0.0.0.0/0 --desc="HTTPS"

Allowing SSH from a Specific IP Range​

arvan iaas security-group add-rule <sg-id> --direction=ingress --protocol=tcp --port-min=22 --port-max=22 --remote-ip=192.168.1.0/24 --desc="SSH from office"

Allowing All Outbound Traffic​

arvan iaas security-group add-rule <sg-id> --direction=egress --protocol=tcp --port-min=0 --port-max=65535 --remote-ip=0.0.0.0/0 --desc="All TCP outbound"
arvan iaas security-group add-rule <sg-id> --direction=egress --protocol=udp --port-min=0 --port-max=65535 --remote-ip=0.0.0.0/0 --desc="All UDP outbound"

Allowing Database Access from Application Servers​

arvan iaas security-group add-rule <sg-id> --direction=ingress --protocol=tcp --port-min=5432 --port-max=5432 --remote-ip=10.0.1.0/24 --desc="PostgreSQL from app servers"

Command Reference​

CommandAliasDescriptionArguments
security-group listlsList all firewall groupsNone
security-group showshShow the details of a firewall group<security-group-id>
security-group add-Create a new firewall group<security-group-name>
security-group deletedelDelete a firewall group<security-group-id>
security-group add-rulearAdd a rule to a firewall group<security-group-id>
security-group delete-ruledrDelete a rule from a firewall group<security-group-id> and <rule-id>
security-group attachattAttach a firewall group to a port<security-group-id> and <port-id>
security-group detachdetDetach a firewall group from a port<security-group-id> and <port-id>