> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/zh/ji-chu-zhi-shi/lan.md).

# 如何使用 Unsloth LAN Access 从网络中的任何设备提供本地 AI 模型

使用即可在家庭或办公室中任何可通过局域网访问的设备上运行本地 AI 模型 [Unsloth](https://github.com/unslothai/unsloth)。启用后，无需向云端发送任何内容，即可从手机、笔记本电脑或同一 Wi‑Fi 或有线网络上的另一台电脑访问本地模型。无需公共 URL 或互联网连接——你的 AI 始终留在你的机器和网络中。

{% columns %}
{% column %}
局域网访问是在另一台设备上使用本地模型的最快方式。流量绝不会离开你的网络，因此延迟很低。

开启局域网访问后，Unsloth 会在你机器的网络地址上响应，例如 `http://192.168.1.42:8888`。可在你的手机、笔记本电脑或同一网络中的任何设备上打开它。

它免费且可离线使用。没有任何内容会离开你的网络，你也无需接触路由器或防火墙。如需从网络外部访问，请改用 [远程访问](/docs/zh/ji-chu-zhi-shi/ru-he-zai-ren-he-di-fang-ti-gong-ben-di-llm-fu-wu-shi-yong-cloudflare-he-unsloth-shi-xian-an-quan-yu.md) 。
{% endcolumn %}

{% column %}

<figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FD2v8S0MkS1xAeEVersl2%2Fmobile_studio1.gif?alt=media&#x26;token=7cd8a534-d82f-4f05-8d5a-9b7277f7eac0" alt="" width="180"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

两种开启方式：

* **启动 Unsloth 时：** 添加 `-H 0.0.0.0` 到你的 `unsloth studio` 命令
* **Unsloth 运行时：** 前往“设置 → API →” **远程与局域网**，找到 **局域网访问** 卡片，然后按 **开始**

### ⚡ 快速开始

首先，我们需要下载 [Unsloth Desktop](https://unsloth.ai/download) 应用。

1. 为以下系统安装应用： [macOS](https://unsloth.ai/download/mac)、Windows 或 [Linux](https://unsloth.ai/download/linux)
2. 启动应用
3. 然后前往“设置 → API →” **远程与局域网**.

<div data-with-frame="true"><figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FcMQ75NHKaf3xosAL87cq%2Fremote-lan-settings2.png?alt=media" alt=""><figcaption></figcaption></figure></div>

当 Unsloth 已在运行，而你希望在同一建筑物内的另一台设备上使用它时，请使用此选项。按 **开始** 在 **局域网访问** 卡片。 `在线` 表示该地址已经响应，而不只是已被请求。

#### 自动启动

“ **自动启动** 局域网访问卡片下的开关会让 Unsloth 每次启动时都接入网络。现在停止局域网访问不会关闭此设置；该开关是与运行状态分开的偏好设置。

### CLI：局域网方式

手动安装 Unsloth 后，在终端中运行：

```bash
unsloth studio -H 0.0.0.0 -p 8888
```

Unsloth 会绑定到所有网络接口，因此原始端口可从你的网络访问。不会发布公共 Cloudflare URL， `-H 0.0.0.0` 单独使用即可让你留在局域网中。输出的第一行是其他设备使用的地址：

```
正在 http://[<你的机器网络地址>]:8888 启动 Unsloth Studio
```

该地址可能是 IPv6，和上面一样使用方括号。复制包括方括号在内的完整 URL。

#### CLI：局域网加公共链接

```bash
unsloth studio -H 0.0.0.0 --cloudflare -p 8888
```

原始端口仍可从你的网络访问 *和* 并且会发布一个公共 Cloudflare URL。横幅会就此明确警告你，因为这是隐私性最低的模式。 [远程访问页面](/docs/zh/ji-chu-zhi-shi/ru-he-zai-ren-he-di-fang-ti-gong-ben-di-llm-fu-wu-shi-yong-cloudflare-he-unsloth-shi-xian-an-quan-yu.md) 对此进行了说明。

#### UI：将已经运行的服务器接入网络

1. 打开 **设置 → API → 远程与局域网**.
2. 找到 **局域网访问** 卡片。
3. 点击 **开始**.
4. 当状态显示为 **在线**时，从同一网络中的任何设备打开显示的地址。

#### 每种启动方式实际暴露的内容

<table><thead><tr><th width="391">启动命令</th><th>可从以下位置访问</th></tr></thead><tbody><tr><td><code>unsloth studio</code></td><td>仅此机器</td></tr><tr><td><code>unsloth studio -H 0.0.0.0</code></td><td>你的网络</td></tr><tr><td><code>unsloth studio -H 0.0.0.0 --cloudflare</code></td><td>你的网络，以及一个公共 Cloudflare URL</td></tr><tr><td><code>unsloth studio --secure</code></td><td>仅一个公共 Cloudflare URL，局域网保持关闭</td></tr></tbody></table>

`--secure` 与局域网访问相对： `--secure` 会强制绑定到回环接口，因此你网络中的任何设备都无法访问原始端口。

### 🔒 安全性

将 Unsloth 接入网络意味着该网络中的每台设备都能看到它。

* **连接未加密。** 局域网流量为纯 HTTP。同一网络段上的任何人都可以读取它。在你无法控制的网络上，请使用 [远程访问](/docs/zh/ji-chu-zhi-shi/ru-he-zai-ren-he-di-fang-ti-gong-ben-di-llm-fu-wu-shi-yong-cloudflare-he-unsloth-shi-xian-an-quan-yu.md) 替代，Cloudflare 链接使用 HTTPS。
* **服务器端工具以你的用户身份运行。** 网页搜索、Python 和终端执行默认启用，因此任何持有你的 API 密钥并能访问服务器的人都可以在该机器上运行代码。请传入 `--disable-tools` 来暴露 Unsloth 时，并妥善保管 API 密钥。每次可通过网络访问的启动都会在横幅中说明这一点。
* **Unsloth 会检查端口是否泄露到路由器之外。** 在通配符绑定时，可达性探测会测试原始端口是否意外地可从互联网访问；如果可以，启动横幅会说明。这项探测会联系 `ifconfig.me` 和 `check-host.net`；设置 `UNSLOTH_STUDIO_DISABLE_PUBLIC_CHECK=1` 可跳过两者。

### ❔ 故障排除

* **`错误：Unsloth Studio 已在端口 8888 上运行（PID ...）`.** 另一个实例占用了该端口。请先运行 `unsloth studio stop` ，或在其他 `--port`.
* **该地址无法从另一台设备响应。** 两台设备必须位于同一网络。访客 Wi‑Fi、客户端隔离（“AP 隔离”）和 VPN 是常见原因。还应检查机器自身的防火墙是否允许该端口的入站连接。
* **地址发生了变化。** 局域网 IP 由路由器分配，可能会变化。请在路由器设置中为该机器分配静态 IP 或 DHCP 保留地址，以获得稳定的地址。
* **UI 中的“启动”呈灰色不可用。** 阅读卡片下方的消息，其中会说明被阻止的原因。

### 🌱 环境变量

| 变量                                    | 用途                                     |
| ------------------------------------- | -------------------------------------- |
| `UNSLOTH_STUDIO_DISABLE_PUBLIC_CHECK` | `1` 跳过对通配符绑定进行的第三方原始端口可达性探测。           |
| `UNSLOTH_STUDIO_TRUST_FORWARDED`      | `1` 遵循 `X-Forwarded-For` 位于你自己的反向代理之后。 |

### 🌐 HTTP API

四者都需要 **UI 会话，** API 密钥会被拒绝。被拒绝的操作将返回 `409` ，并将阻止原因作为 detail。

<table><thead><tr><th width="100">方法</th><th>路径</th><th>用途</th></tr></thead><tbody><tr><td><code>GET</code></td><td><code>/api/settings/lan-access</code></td><td>当前状态、地址、 <code>can_start</code> / <code>can_stop</code>, <code>block_reason</code>.</td></tr><tr><td><code>POST</code></td><td><code>/api/settings/lan-access/start</code></td><td>安排由设置管理的启动。幂等。</td></tr><tr><td><code>POST</code></td><td><code>/api/settings/lan-access/stop</code></td><td>安排由设置管理的停止。不会更改自动启动偏好。</td></tr><tr><td><code>PUT</code></td><td><code>/api/settings/lan-access/auto-start</code></td><td><code>{"enabled": true|false}</code>.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/zh/ji-chu-zhi-shi/lan.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
