Modes
| Mode | Behavior |
|---|---|
allow_all | All outbound traffic is permitted (default) |
deny_all | All outbound traffic is dropped unless explicitly allowed via allow_cidrs |
169.254.169.254 is always reachable regardless of the policy. The in-VM agent daemon uses it to fetch its auth token at boot.
Policy fields
allow_all or deny_all.CIDRs to allow outbound traffic to. Only evaluated when
mode is deny_all. Example: ["1.1.1.1/32", "8.8.8.8/32"].CIDRs to explicitly deny. Evaluated before
allow_cidrs, so use this to carve out subnets from a broad allow rule. Example: ["10.0.0.0/8"].Restrict
allow_cidrs rules to these destination TCP ports. If omitted, the allowed CIDRs are reachable on any port. Requires allow_cidrs to be set. Example: [443, 8080].Validation
The API validates egress policies on create and returns400 for:
- Unknown mode (must be
allow_allordeny_all) allow_allcombined withallow_cidrs,deny_cidrs, orallow_portsallow_portsset withoutallow_cidrsdeny_cidrscontaining the metadata service range (169.254.0.0/16)- Malformed CIDR notation
- Port numbers outside 1–65535
Per-sandbox egress
Pass anegress object when creating a sandbox to override the template default.
- CLI
- API
sandbox create and sandbox run):| Flag | Description |
|---|---|
--egress-mode | allow_all or deny_all. When omitted and other egress flags are set, defaults to deny_all. |
--egress-allow-cidr | Allow outbound to this CIDR (repeatable). Implies deny_all. |
--egress-deny-cidr | Deny outbound to this CIDR (repeatable). |
--egress-allow-port | Restrict --egress-allow-cidr to this TCP port (repeatable). |
Template-level egress defaults
Set a default egress policy on a template so every sandbox created from it inherits the same restrictions.- CLI
- API
egress object. Passing no egress field inherits the template default.
Rebuilding a template (
zwrm templates rebuild) does not change the stored egress policy. The policy is attached to the template record, not the image.How it works
Egress rules are implemented as iptables rules in theZWRM chain on the host. When a sandbox is created with a deny_all policy, the manager installs:
- Allow rules — one
ACCEPTperallow_cidrsentry (optionally port-scoped), inserted near the top of the chain - Deny rule — a final
DROPfor all traffic from the sandbox IP, appended at the bottom
169.254.169.254/32) always has an unconditional ACCEPT that sits above per-sandbox rules.
Rules are cleaned up automatically when the sandbox is destroyed or suspended.