Skip to content

Security Groups

Explanation · Updated Jun 2026

Coming from another cloud?

▸AWS·Security Groups

Security Groupshigh

  • AWS stateful auto-response.
  • OpenStack stateless explicit.
  • OpenStack port/project.
  • AWS default inbound deny/outbound all.
AWS docs ↗
▸Azure·Network Security Groups (NSGs)

Network Security Groups (NSGs)high

  • NSGs can associate to both subnets and NICs with specific processing order (inbound: subnet then NIC; outbound: NIC then subnet) ().
  • Stateful with priority-based rules (100-4096); augmented rules allow multiple IPs/ports per rule (Resource Manager only).
  • Default rules allow VNet/LB/Internet out; service tags like VirtualNetwork.
  • No direct port-level only like OpenStack; subnet-level affects all instances.
Azure docs ↗
▸DigitalOcean·Cloud Firewalls

Cloud Firewallshigh

  • Application model: DigitalOcean firewalls are applied to Droplets via `droplet_ids` and/or tags, whereas OpenStack security groups are typically attached to Neutron ports (VM NICs) and can vary per port ().
  • Rule model includes both inbound and outbound rules and notes that if none are configured then no traffic is permitted in that direction; OpenStack security groups also support egress rules but many deployments default to allow-all egress—migrating users may need to explicitly model egress restrictions in DigitalOcean if they rely on different defaults ().
  • Aggregation semantics: DigitalOcean states that when multiple cloud firewalls apply to a Droplet, rules are additive (“union of the rules”) and a more permissive rule in any firewall effectively opens access; OpenStack security groups are also generally additive, but users migrating from “deny-by-default with explicit groups” patterns may be surprised by how quickly access broadens when stacking policies ().
  • Target/source object types differ: DigitalOcean allows sources/destinations to include load balancers (by UID) and uses constructs like `load_balancer_uids`, `droplet_ids`, `tags`, and CIDRs in rule JSON, whereas OpenStack security group rules typically reference CIDRs and/or remote security group IDs (not load balancer UIDs as a primitive) ().
DigitalOcean docs ↗
▸Google Cloud·Firewall Rules

Firewall Ruleshigh

  • GCP firewall rules are VPC-level with target filtering by network tags or service accounts; OpenStack security groups attach to ports.
  • GCP rules are stateful (implied return traffic); OpenStack security groups also stateful but per Neutron port.
  • GCP firewall supports priority (0-65535) with explicit deny rules; OpenStack security groups are allow-only (implicit deny).
  • GCP hierarchical firewall policies apply org/folder-wide; OpenStack has no equivalent scope.
Google Cloud docs ↗
▸Hetzner·hcloud_firewall

Firewallshigh

  • Applies only to Cloud Servers (not Load Balancers), up to 5/server, 500 rules max; free ().
  • Default: inbound blocked, outbound allowed; uses label selectors for auto-apply; statefulness not specified but likely stateless given rules ().
  • No per-port/per-network granularity like Neutron SG rules; connection limits (80k concurrent/server) ().
  • Custom Hetzner API vs Neutron security-groups API.
Hetzner docs ↗

Security groups

The Network service (OpenStack Neutron) implements security groups as stateful packet filters attached to instance ports. Each rule describes allowed traffic by direction (ingress or egress), IP protocol, optional port range, and remote address range in CIDR form (or by reference to another security group). They are the first place you express "who may SSH here" or "this tier may talk to the database on 5432."

Security groups attach rules to each port, so they track the network boundary closest to the workload without requiring a separate hardware firewall per VM.

What security groups do#

They combine into a virtual firewall around NICs. Ingress rules gate inbound connections; egress rules gate outbound. Stateful behavior means that when you allow a flow in one direction, return packets for established connections match the state table and are permitted without mirror micro-rules for ephemeral client ports.

ICMP "echo" for ping, traceroute-related types, and application protocols all use the same rule machinery; if you need ping for debugging, expose it explicitly instead of assuming defaults include it.

New instances typically land in a default security group whose baseline allows inbound from other members of that same group and outbound toward broad destinations. That default supports bootstrapping and traffic between instances in the same group; production systems add explicit ingress from reverse proxies or bastions only, and sometimes constrain egress to required endpoints for compliance.

You can attach multiple groups to one instance so web, admin, and compliance rules compose. One group can also span many instances when you treat a tier as a role.

How rules are evaluated#

Security group packet evaluationFlowchart showing how ingress and egress traffic is evaluated against security group rules on a port, with matching packets allowed and non-matching packets dropped

Yes

No

Yes (stateful)

No

Yes

No

Inbound
packet

Match
ingress rule?

Allow →
instance

Drop

Instance
response

Existing
session?

Allow →
client

Match
egress rule?

Allow →
network

Drop

Click to zoom
Security group packet evaluation: ingress and egress rules are checked against incoming and outgoing traffic on each port

Rules are allow lists: traffic must match an explicit permit. OpenStack evaluates security group rules as a set of permits (there is no separate "deny rule" row in the classic model; absence of allow means drop). Direction, protocol, ports, and remote prefixes must align for a packet to pass.

Because evaluation is stateful, short-lived responses to permitted client sessions return even if egress rules are narrower than you might expect for arbitrary UDP or TCP; still validate your egress policy against compliance needs.

Changing policy safely#

Updates apply immediately to every port using that security group, so a broad change can open or close many instances at once. Immediate propagation helps incident response and amplifies mistakes; prefer narrow ranges, change windows, and infrastructure-as-code review for shared groups.

Interaction with ports and floating IPs#

Security groups bind to ports on each NIC. If an instance has multiple NICs, each port can carry a different combination of groups; your database NIC might be far more restricted than a management NIC. Floating IP NAT resolves to the private address first; security groups then evaluate the permitted flows on that instance port.

Practices that keep environments defensible#

Apply least privilege: allow only the protocols and sources you need; default-deny is implicit where no rule matches. Segment by role (web, application, data) so a compromise in one group does not imply carte blanche elsewhere. Audit rules periodically as applications evolve. Pair filters with logging and monitoring (where the platform exposes them) to spot unexpected connection attempts.

Prefer referencing another security group as a source when tiers scale: "application servers may reach the database security group on 5432" stays correct when you add instances without editing CIDRs.

Further reading#

On this platform:

External resources:

Related content

Pages

migration

deployment

Build a private network with two virtual machines

Network

→

Deploy a bursty-GPU control plane with a queue and workers

Compute

→

Deploy a private container registry with OpenTofu

Automation

→

Deploy a Redis or Valkey cache with the redis-cache template

Automation

→

Deploy a regional edge cache with the edge-cache template

Automation

→

Deploy a self-hosted CI runner

Compute

→

Deploy a self-hosted git forge and CI with OpenTofu

Automation

→

Deploy an API gateway with the api-gateway template

Automation

→

Deploy an edge reverse proxy with the edge-reverse-proxy template

Automation

→

Deploy an edge tunnel gateway with the edge-tunnel-gateway template

Automation

→

Deploy an edge WAF with the edge-waf template

Automation

→

Deploy an inference gateway with OpenTofu

Automation

→

Deploy edge functions with the edge-functions template

Automation

→

Deploy self-hosted Supabase with Docker Compose

Compute

→

Deploy the development environment template with OpenTofu

Automation

→

Deploy the full-stack application template with OpenTofu

Automation

→

Deploy the monitoring stack template with OpenTofu

Automation

→

Deploy the MySQL/MariaDB database template with OpenTofu

Automation

→

Deploy the private network + VPN template with OpenTofu

Automation

→

Deploy the self-managed PostgreSQL template with OpenTofu

Automation

→

Deploy the Simple VM template with OpenTofu

Automation

→

Deploy the three-tier application template with OpenTofu

Automation

→

Deploy the WordPress + MySQL template with OpenTofu

Automation

→

Set up a Minecraft server

Compute

→

Templates

Troubleshooting

Was this page helpful?