Egress rules
Limit which destinations your sandboxes may connect to: default rules for the whole account, and rules of each sandbox.
How rules apply
A connection leaves a sandbox only if it passes three layers, each judged on its own:
- Platform rules: fixed by LumiCloud, the same for every account (see Platform limits).
- Default rules: yours, set in the console, applied to every sandbox of the account, running or created later.
- Sandbox rules: given to one sandbox when it is created (the SDK's network option) or changed while it runs.
Rules can only narrow. A sandbox's rules cannot open what your default rules close, and your default rules cannot open what the platform closes. A destination allowed by one layer is not allowed until all three allow it.
Rule lists
Each set of rules has two lists, in the form of E2B's network option.
| List | Entries |
|---|---|
| allow_out | An IP address, a CIDR range, a domain name (api.example.com) or a wildcard name (*.example.com) |
| deny_out | An IP address or a CIDR range; domain names cannot be denied |
- In the console, one entry per line.
- A destination in allow_out is allowed even if deny_out also matches it: allow wins over deny.
- A destination that matches neither list is allowed.
- Names in allow_out are matched on the name the connection asks for (the Host header on port 80, the server name on port 443) and connected by name, so a connection to an allowed name cannot be pointed at another address.
- Because a name cannot be denied, allowing only some names takes two steps: allow them, and deny 0.0.0.0/0.
Allow only some destinations
Allow the names, then deny everything else. The deny entry 0.0.0.0/0 is required whenever allow_out holds a name.
In the console, write the names under Allow and 0.0.0.0/0 under Deny:
textAllow
api.example.com
*.example.org
203.0.113.0/24
Deny
0.0.0.0/0On a sandbox, with the SDK:
pythonfrom e2b import Sandbox
sandbox = Sandbox.create(
"base",
network={
"allow_out": ["api.example.com", "*.example.org"],
"deny_out": ["0.0.0.0/0"],
},
)javascriptimport { Sandbox } from "e2b"
const sandbox = await Sandbox.create("base", {
network: {
allowOut: ["api.example.com", "*.example.org"],
denyOut: ["0.0.0.0/0"],
},
})Deny some destinations
Deny an address or range and leave allow_out empty; everything else stays open.
pythonsandbox = Sandbox.create("base", network={"deny_out": ["198.51.100.0/24"]})No internet access
A sandbox created with allow_internet_access=False has no outbound network at all, whatever the rules say.
Change rules while a sandbox runs
Changing a sandbox's network settings while it runs, or saving the default rules, takes effect at once. Connections that are open and no longer allowed are closed; loosening rules leaves open connections alone. A paused sandbox keeps its own rules and gets them back when it resumes, and the default rules are the account's current ones at that time.
Default rules in the console
- Egress rules page: two boxes, Allow and Deny, one entry per line, with the number of entries used and the plan's limit.
- Save rules applies them to all sandboxes of the account. Remove all clears both lists.
- A sandbox's detail page shows the rules in effect, layer by layer: the platform's, your default rules, the sandbox's own.
Limits of a plan
Each set of rules (your default rules, and the rules of each sandbox) holds a limited number of entries, allow and deny together: Base 10, Pro 100. The entry 0.0.0.0/0 in deny_out is not counted. A list over the limit is refused with the limit in the reason. A paused sandbox whose rules are over a lowered limit still resumes.
Platform limits
These hold on every plan, whatever the rules say, and cannot be opened:
- Outbound mail ports 25, 465, 587 and 2525 are closed.
- Private and internal networks are closed.
- The platform's own hosts are reachable on ports 80 and 443 only.
- UDP is allowed to the DNS resolver only.
An account whose plan allows only a list of destinations reaches those destinations only; your rules narrow that list and do not extend it. The console shows the tier on a sandbox's rules in effect.
Errors
- An entry that is not an address, a range, a name or a wildcard name, or a name in deny_out: refused, naming the entry.
- A name in allow_out without 0.0.0.0/0 in deny_out: refused.
- More entries than the plan allows: refused, with the limit.