Skip to main content
A security group is a named set of stateful allow rules. There are no deny rules and no ordering: a packet is allowed if any rule on any group attached to the interface allows it, and dropped otherwise.
Rules do nothing until the group is attached to an interface. A group full of carefully written rules that no interface belongs to has no effect anywhere.

The default posture

What an interface with no group does, and the one rule a new group starts with.

Writing rules

Required fields, the source that is not optional, and why there is no update.

Attaching

Membership is a set you replace, not a list you append to.

Platform rules

Traffic that is always allowed, and the one port that is always blocked.

The default posture

Two different defaults matter here, and confusing them is the usual source of “my rules do nothing”.
Default deny, both directions. Every packet is dropped except the platform’s own always-on allows. Attaching no security group is not the permissive option — it is the closed one.
That default egress rule is IPv4 only. A dual-stack interface has no ::/0 egress until you add an ipv6 egress rule yourself, so a v6-enabled instance that works over IPv4 can fail silently over IPv6 with a group that looks wide open.

Rules

Go to Networking → Security Groups — Create Security Group makes one, with a Name and an optional Description — then open it and choose Add inbound rule or Add outbound rule. Which button you pressed is the rule’s direction; there is no direction field in the dialog, and the block where you name the other end is headed Source or Destination to match.Pick a Service preset — HTTPS (443), SSH (22), PostgreSQL (5432) and so on — or leave it on Custom and set IP Version, Protocol and Port Range yourself. Port Range is one field taking either a single port or a range, where the API takes port_min and port_max separately. Then choose CIDR or Security Group for the source, and confirm with Add Rule.The group’s Inbound and Outbound tabs list what it holds, each row with a Delete rule action.
Rules omit the parent security_group_id. In read responses, source_security_group is a resource reference with id, crn, and an optional name; create requests accept it as a string selector.
ingress | egress
required
For an egress rule, remote_cidr and source_security_group name the destination. The field names do not change with the direction.
tcp | udp | icmp | all
required
ipv4 | ipv6
Defaults to ipv4. A rule matches one family only; write two rules for both.
integer
Required for tcp and udp, and rejected without them. Ignored — and cleared — for icmp and all. The range must satisfy 0 ≤ port_min ≤ port_max ≤ 65535. For a single port, set both to it.
string | ResourceRef
required
Exactly one of the two is required. They are mutually exclusive, and omitting both is rejected — there is no “any source” shorthand; write 0.0.0.0/0 or ::/0 explicitly. remote_cidr must match the rule’s ethertype.
Rules are create-and-delete only; there is no update. To change one, delete it and create the replacement.

Naming another group as the source

In Add inbound rule, switch the Source block from CIDR to Security Group, then Pick a source security group.
This means “any workload in that group”, matched by the addresses of its current members. Adding an instance to the app tier makes the database reachable from it with no rule change, and removing one closes it again. It saves you from maintaining CIDR lists that drift out of date every time a tier scales.

Stateful

An allowed connection’s return traffic is allowed automatically. You do not write a mirrored rule in the opposite direction — an ingress rule for TCP 443 already lets the responses out.

Attaching groups to an interface

Membership belongs to the interface, not to the group. There is nothing on a security group’s own page that attaches it to anything.
Open the interface under Networking → Interfaces. Its Security groups tab lists the full attached resources. Choose Attach security group to add one, or the row’s Detach security group action to remove one. Other attachments stay unchanged.
GET returns security_groups with the same resource fields as the top-level security-group list, plus meta. POST accepts one security_group string selector and returns {security_group}. DELETE takes the group’s UUID and returns 204. Removing the last group leaves the interface dropping all traffic. Every id has to be a group your account owns. When several groups apply to one interface, their allow rules are unioned — an interface is at least as open as its most permissive group. You cannot subtract with a security group; to narrow an interface, remove the group that allows the traffic. Deleting a group is refused while any interface still belongs to it. Empty the membership on each interface first. name is immutable; description and tags can be patched.

What the platform enforces regardless

A small band of rules sits above yours. You cannot override or remove them through this API.

Always allowed

DHCP, IPv6 neighbor discovery, and the link-local metadata endpoint at 169.254.169.254. Every instance needs these to lease its address and to reach instance metadata at boot, so they survive a default-deny posture — otherwise a correctly-locked-down instance could never finish booting.

Always blocked: outbound TCP 25 to the internet

Direct-to-MX SMTP from a compromised or rented instance is the fastest way for an address range to land on a spam blocklist, and the cost of that lands on everyone sharing the range. The envelope carries your address, so the block is on port 25 specifically.
The submission ports 465, 587 and 2525 are not blocked. Mail handed to an authenticated provider leaves from that provider’s addresses carrying that provider’s reputation, so blocking those buys nothing and breaks a great deal of software that only speaks SMTP.The port 25 drop also excludes private destinations, so your own mail server inside the VPC stays reachable from another instance.

Next

Interfaces

What a NIC is and how it gets its security groups.

Routing

Security groups decide the last hop. Routing decides whether the packet ever arrives.