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

# 网络规则配置

CLI 的 `network` 命令更新运行中沙箱的**出站（outbound）规则**，让您可以控制沙箱允许或拒绝访问哪些外部目标。规则通过沙箱 ID 应用到沙箱，并在运行中的沙箱上生效。

<Note>
  **注意：** 如果未指定 `allowOut`，则允许所有出站流量。省略 `--allow-out` 和 `--deny-out` 会清除所有出站规则。
  `allow-out` 和 `deny-out` 仅支持 CIDR 的配置方式，不支持域名。
</Note>

***

## 前置条件

在运行命令之前设置环境变量中的 API 密钥：

```bash theme={null}
export PPIO_API_KEY=<your API key>
```

***

## 用法

```bash theme={null}
ppio sandbox network <sandboxID> [--allow-out <destination>] [--deny-out <destination>]
```

| 选项 / 参数       | 值           | 说明                         |
| ------------- | ----------- | -------------------------- |
| `<sandboxID>` | string      | 要更新的运行中沙箱的 ID（必填）          |
| `--allow-out` | destination | 允许的出站目标。可重复 —— 多次传递以允许多个目标 |
| `--deny-out`  | destination | 拒绝的出站目标。可重复 —— 多次传递以拒绝多个目标 |

`destination` 是 IP 地址或 CIDR 范围，例如 `1.1.1.1` 或 `8.8.8.0/24`。

***

## 示例

```bash theme={null}
# 仅允许出站到这两个目标
ppio sandbox network <sandboxID> \
  --allow-out 1.1.1.1 \
  --allow-out 8.8.8.0/24
```

```bash theme={null}
ppio sandbox network <sandboxID> \
  --deny-out 1.1.1.1 \
  --deny-out 8.8.8.0/24
```

```bash theme={null}
# 省略两个选项以删除所有出站规则
ppio sandbox network <sandboxID>
```

成功时 CLI 打印：

```text theme={null}
Sandbox <sandboxID> network has been updated
```

<Warning>
  **注意：** 如果沙箱 ID 不存在，命令会报告 `Sandbox <sandboxID> wasn't found` 并以非零状态退出。
</Warning>
