> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superserve.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Network rules

> Lock down sandbox egress to specific CIDRs or domains with allow and deny lists.

By default, a sandbox can reach any public IP on the internet. The platform always blocks egress to private, link-local, and loopback ranges regardless of your allow rules. Use `network` rules to narrow the allowlist further.

<Tip>
  Rules control what a sandbox **may** reach. To see what it **actually** reached — every connection, allowed or blocked — use the [network log](/sandbox/network-log).
</Tip>

## Allow specific destinations

`allowOut` / `allow_out` accepts a mix of CIDRs and domain patterns. Combine it with `denyOut: ["0.0.0.0/0"]` to build a strict allowlist - deny everything, then add exceptions.

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  const sandbox = await Sandbox.create({
    name: "restricted",
    network: {
      allowOut: ["api.openai.com", "*.github.com", "140.82.112.0/20"],
      denyOut: ["0.0.0.0/0"],
    },
  })
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  from superserve import Sandbox, NetworkConfig

  sandbox = Sandbox.create(
      name="restricted",
      network=NetworkConfig(
          allow_out=["api.openai.com", "*.github.com", "140.82.112.0/20"],
          deny_out=["0.0.0.0/0"],
      ),
  )
  ```
</CodeGroup>

## Rule format

| Field                    | Accepts         | Notes                                                                                                                                                                                           |
| ------------------------ | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `allowOut` / `allow_out` | CIDRs + domains | Domains support wildcards (`*.example.com`). A wildcard matches subdomains at any depth but not the bare domain — `*.example.com` does not match `example.com`; list both if you need the apex. |
| `denyOut` / `deny_out`   | CIDRs only      | Use `0.0.0.0/0` to deny the entire internet and rely on `allowOut` for exceptions.                                                                                                              |

Allow rules take precedence over deny rules when they overlap.

## Update rules on a running sandbox

Networking can be updated after creation - changes apply immediately to new connections.

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  await sandbox.update({
    network: {
      allowOut: ["api.anthropic.com", "api.openai.com"],
      denyOut: ["0.0.0.0/0"],
    },
  })
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  sandbox.update(
      network=NetworkConfig(
          allow_out=["api.anthropic.com", "api.openai.com"],
          deny_out=["0.0.0.0/0"],
      ),
  )
  ```
</CodeGroup>

<Warning>
  Blocking `*.superserve.ai` will break the SDK's ability to communicate with the sandbox.
</Warning>
