Network policies control outbound network access from a box.
Use them when you want to:
- block all outbound traffic
- allow only specific public domains
- restrict egress to specific CIDR ranges
By default, boxes use:
Modes#
| Mode | Description |
|---|---|
allow-all | Default. No outbound restrictions. |
deny-all | Block all outbound network access. |
custom | Allow or deny specific domains and CIDR ranges. |
The SDK type is:
Create a box with a policy#
Pass networkPolicy when creating a box:
You can also combine domain and CIDR rules:
networkPolicy is also supported in Box.fromSnapshot() and EphemeralBox.
Read the current policy#
Use the networkPolicy getter:
Update a running box#
Update the policy after creation:
Switch back to unrestricted outbound access:
Changes take effect immediately. You do not need to recreate the box.
Matching rules#
allowedDomainssupports exact matches such asapi.github.com- wildcard domains must use
*.suffixform, for example*.githubusercontent.com allowedCidrsanddeniedCidrsuse standard CIDR notation- in
custommode,deniedCidrstakes precedence over allowed CIDRs - private IP ranges are always blocked even if you try to allow them explicitly
Example patterns#
Allow only GitHub and npm:
Block all outbound traffic:
Allow a specific public CIDR:
Block a specific CIDR range: