Skip to main content
This feature is in public preview.
A firewall is a set of rules controlling inbound traffic to an instance. Firewalls are scoped to a workspace.

Default firewall

Every workspace has a built-in default firewall with 2 ingress rules.
  • Allow SSH (TCP port 22) from anywhere
  • Allow ICMP (ping) from anywhere
SF Compute manages the default firewall. You cannot modify or delete it. Password authentication is disabled on all SF Compute base images, so open SSH is safe by default. Only key holders can connect.

How firewalls apply

Firewall rules control traffic between instances and the public internet. Instances in the same subnet communicate freely on all ports. Instances in different subnets are isolated and cannot communicate. Firewalls only apply to instances with a public IP (created with --public-ipv4) and cannot be attached to an instance without one. The API requires the firewall field whenever enable_public_ipv4 is true and rejects the request with 422 when it is omitted. The CLI fills it in for you. If you run sf instances create --public-ipv4 interactively without --firewall, it prompts you to pick a firewall. Otherwise, it uses the workspace’s default firewall.

Creating a firewall

Create a firewall from a TOML file that defines the rules.

Rule format

Each rule specifies a direction, protocol, port (or port range), and source CIDR (Classless Inter-Domain Routing). The API accepts only ingress rules and rejects egress, which is reserved for future use. Firewalls do not filter outbound traffic. The protocol is tcp, udp, or icmp; ICMP rules take no port.
This creates a firewall that allows SSH and port 8080 from anywhere. Source CIDRs must be publicly routable. The API rejects private, reserved, and other non-public ranges (for example 10.0.0.0/8, 192.168.0.0/16). The wildcard 0.0.0.0/0 (allow from anywhere) is the only exception.

Restricting access

Restrict SSH to a specific network.

Port ranges

Allow a range of ports.

Create via the API

To create a firewall via the API, send a POST request to /preview/v2/firewalls.

Attaching a firewall to an instance

Specify the firewall when creating an instance.

Replacing the firewall on an instance

Replace the attached firewall on an existing instance. The instance must have been created with --public-ipv4. The new rules take effect without a reboot.
You can replace the firewall but not detach it.

Listing firewalls

List the firewalls in the active workspace.

Getting firewall details

Fetch a firewall by name.
Add --toml to output the rule set as TOML, which round-trips with sf firewalls set.

Updating a firewall

Replace a firewall’s rule set from a TOML file. The replacement is atomic.

Update via the API

PUT /preview/v2/firewalls/{id} replaces the full rule set.

Deleting a firewall

Delete a firewall by name.
Deleting a firewall fails if any instances still reference it.

Limits

Firewalls enforce the following limits.
  • 100 rules per firewall
  • 100 firewalls per workspace, including the built-in default

API reference

See the Firewalls API for programmatic access.