Skip to Content
Open Beta — managed Kubernetes, DNS & more are live.
🛡️

Security groups

Updated 2026-11-20
On this page

Security groups

Security groups are virtual firewalls for your instances. Each rule allows specific inbound or outbound traffic, so you decide exactly which ports and sources are permitted.

A security group is a set of allow rules that attach to an instance's network ports. There are no deny rules: traffic that no rule allows is simply dropped. That makes a group easy to reason about, you read it as the complete list of what is permitted.

Rules are stateful. If you allow an inbound connection, the reply traffic is allowed back automatically, so you rarely need matching outbound rules for the same flow. You can attach several groups to one instance and reuse a group across many instances, which keeps a common policy in one place.

Only open the ports you actually need, and restrict the source to trusted address ranges rather than the whole internet (0.0.0.0/0).
Opening SSH (22) or RDP (3389) to 0.0.0.0/0 exposes the port to constant scanning. Restrict the source to your own address range wherever possible.

Key concepts

Security group — A named set of allow rules attached to instance ports.

Rule — One allow entry: a direction, protocol, port range and source or destination.

Direction — ingress for inbound traffic to the instance, egress for outbound.

Remote IP prefix — The CIDR a rule allows traffic from (ingress) or to (egress), e.g. 203.0.113.0/24.

Ethertype — Whether the rule applies to IPv4 or IPv6.

Before you start

  • An instance (or a plan to create one) whose traffic you want to control.
  • The list of ports your service actually listens on.

Step by step

  1. Open Security groups

    Go to Networking and open Security groups.

    Screenshot — The Security groups list
    The Security groups list
  2. Create a group

    Create a group with a clear name such as web-servers so its purpose is obvious.

    Screenshot — The Create security group form
    The Create security group form
  3. Add rules
    • Add an ingress rule for each port you must expose, for example 443 for HTTPS.
    • Set the protocol (TCP, UDP or ICMP), the port range, and the ethertype.
    • Restrict the remote IP prefix to a trusted range where possible.
    Screenshot — The add-rule form with direction, protocol, port and source fields
    The add-rule form with direction, protocol, port and source fields
  4. Attach to instances

    Attach the group to your instances. An instance keeps the rules of every group attached to it.

Examples

Create a group and allow HTTPS
patrii security-group create --name web-servers
patrii security-group list    # note the group ID
patrii security-group rule add <group-id> \
  --direction ingress --protocol tcp --port 443 \
  --cidr 0.0.0.0/0
Allow SSH only from a trusted range
patrii security-group rule add <group-id> \
  --direction ingress --protocol tcp --port 22 \
  --cidr 203.0.113.0/24
The same group with Terraform
resource "patrii_security_group" "web" {
  name        = "web-servers"
  description = "HTTPS from anywhere, SSH from the office"
}

resource "patrii_security_group_rule" "https" {
  security_group_id = patrii_security_group.web.id
  direction         = "ingress"
  protocol          = "tcp"
  port_range_min    = 443
  port_range_max    = 443
  remote_ip_prefix  = "0.0.0.0/0"
}

resource "patrii_security_group_rule" "ssh" {
  security_group_id = patrii_security_group.web.id
  direction         = "ingress"
  protocol          = "tcp"
  port_range_min    = 22
  port_range_max    = 22
  remote_ip_prefix  = "203.0.113.0/24"
}

Limits & specifications

Fields on a security-group rule:

FieldValues / meaning
directioningress (inbound) or egress (outbound).
ethertypeIPv4 or IPv6.
protocoltcp, udp, icmp, or left empty for all protocols.
port rangeA single port or a range, e.g. 443 or 8000-8080.
remote IP prefixThe allowed source/destination CIDR, e.g. 203.0.113.0/24.

Best practices

  • Start from deny-by-default: add only the rules you need and nothing more.
  • Scope sources to specific CIDRs; avoid 0.0.0.0/0 for management ports like SSH and RDP.
  • Group by role (web, app, data) and reuse the group instead of recreating rules per instance.
  • Review groups periodically and remove rules for services you no longer run.

FAQ

Do I need an outbound rule for the reply to an allowed request?
No. Rules are stateful, so the return traffic for an allowed connection is permitted automatically.
What happens if two attached groups disagree?
Security groups only add allow rules; there are no deny rules. The instance is allowed the union of all rules across every attached group.
My instance is unreachable even though the port is listening.
Confirm an ingress rule allows that port and protocol, that the source range covers where you connect from, and that the group is actually attached to the instance.

Learn more

Everything you can do here in the console is also available through the Patrii Cloud API for automation and scripting.

Was this article helpful?
Thank you for your feedback. Still stuck? Contact us