跳到主要内容

Tailscale

Unraid 现在通过与 Tailscale 的技术合作,提供了深度集成,使您的服务器能够实现无缝、安全的网络连接。Tailscale 不是传统的 VPN,而是一种基于 WireGuard 的现代点对点覆盖网络。它可以将设备、服务器和单个 Docker 容器连接到您的安全私人网络 (Tailnet),无论其物理位置或网络环境如何。Unraid 的合作确保了 Tailscale 插件的完整维护和紧密集成,为 Unraid 7 及更新版本提供原生证书支持和高级功能。

  • 简单设置: 无需端口转发或防火墙困扰。
  • 强大的安全性: 使用 WireGuard 加密核心技术。
  • 灵活共享: 仅授予对特定设备或容器的访问权限,而不是整个网络。
  • 一流支持: 官方维护的插件,持续增强。

开始使用 Tailscale

首先,注册一个免费的 Tailscale 帐户 并在至少一个设备(Windows, macOS, Linux, iOS, Android 等)上安装客户端。免费帐户最多支持三位用户和 100 台设备。

在添加 Unraid 之前,请考虑:

备注

HTTPS证书中的机器名称是公开的。使用您愿意分享的名称。

将 Tailscale 添加到 Unraid

以下步骤适用于 Unraid 7 及更高版本:

  1. 按上述描述检查您的 Tailscale 帐户设置。
  2. 在 Unraid 中,搜索 Community Apps 标签中的官方 Tailscale 插件并安装。
  3. 打开设置→Tailscale并单击重新验证。使用您的Tailscale账户登录。
  4. 点击 连接 以将您的 Unraid 服务器添加到您的 Tailnet
  5. 访问 Settings → Management Access 查看您的 Tailscale 用于 WebGUI 的 URL。
  6. In Settings → Tailscale, find your server's Tailnet name and IP. Use these to access SMB/NFS shares, Docker containers, and more from any device on your Tailnet. +7. (Optional) Enable Include Tailscale peers in /etc/hosts (see Enhanced hostname resolution) to automatically add Tailscale devices to your server's hostname resolution, making it easier to access other devices on your Tailnet.

子网路由(可选)

要通过其主 LAN IP 访问您的 Unraid 服务器(或访问具有自有 IP 的 Docker 容器):

  1. Go to Settings → Tailscale, click Reauthenticate, and sign in with your Tailscale account.
  2. In the Tailscale settings, locate the Advertise Routes section and add:
    • Your Unraid server's IP (e.g., 192.168.0.12/32), or
    • Your whole network's subnet (e.g., 192.168.0.0/24).
  3. 点击 应用 以保存更改。
  4. Log in to your Tailscale admin console and navigate to the Machines page.
  5. Locate your Unraid server and approve the pending route for the advertised subnet.
  6. 一旦获得批准,您的 Tailnet 设备就可以通过其常规 IP 地址访问您的 Unraid 服务器和/或 LAN 设备。
备注

For advanced details, see the Tailscale subnet routing documentation.

Enhanced hostname resolution

The Tailscale plugin includes an option to automatically add Tailscale peers to your server's /etc/hosts file. This feature simplifies device access by enabling hostname-based connections to other devices on your Tailnet.

Benefits include:

  • Accessing other Tailscale devices using friendly hostnames instead of IP addresses.
  • Automatic updates when devices join or leave your Tailnet.
  • Improved compatibility with applications that rely on hostname resolution.

To enable this feature:

  1. Go to Settings → Tailscale in the WebGUI.
  2. Enable the Include Tailscale peers in /etc/hosts option.
  3. 点击 应用 以保存更改。

Once enabled, you can access other devices on your Tailnet using their Tailscale hostnames from your Unraid server, making it easier to configure services, access shared resources, and manage your network.


将 Tailscale 添加到 Docker 容器

Unraid使连接Docker容器到您的Tailnet变得简单,给每个容器分配一个唯一的设备身份以实现安全、灵活的远程访问。通过这种集成,您可以分享对单个容器的访问权限,而无需暴露整个服务器,并可利用高级功能,如出口节点、Serve、Funnel等,按容器独立配置。设置完全自动化,因此所有技术水平的用户都可以受益于增强的安全性和简化的网络连接。

如何运作 Tailscale-Docker 集成 - 点击展开/折叠

当您启用 Docker 容器的 使用 Tailscale 并应用更改时,Unraid 会自动执行以下步骤以实现无缝集成:

  1. 入口点提取: Unraid 识别容器的原始入口点和命令,保留其预期的启动行为。
  2. 集成脚本注入: tailscale_container_hook 脚本会被挂载到容器内,并更新入口点以首先运行此脚本。
  3. 环境设置: 将原始入口点、命令和所有必需的 Tailscale 变量传递给 Docker 运行命令。
  4. Tailscale 初始化: 启动时,挂载脚本会安装任何依赖项,下载并在容器内启动 Tailscale 客户端。
  5. 正常启动: 然后脚本会启动容器的原始入口点和命令,因此您的应用程序可以照常运行 - 并自动层叠上 Tailscale 网络。

一旦启用,容器就会显示为您 Tailnet 上的一个独立设备,准备好用于安全访问和高级 Tailscale 功能,无需手动网络配置或端口转发。

Container 兼容性

Tailscale集成不适用于所有容器。如果启用了Tailscale,某些容器可能根本无法运行,特别是以下情况的容器:

  • 首先,在任何将访问您 Docker 容器的计算机上安装 Tailscale
  • 尽管 Unraid Tailscale 插件不是 Docker 集成的必要条件,但强烈建议在您的 Unraid 服务器上安装并登录以获得最佳体验。
  • 与 Tailscale 网络修改相冲突的应用程序

请首先在非关键容器上测试 Tailscale 集成,并准备在容器无法正常工作时禁用它。

:::note[Prerequisites]

  • 首先,在任何将访问您 Docker 容器的计算机上安装 Tailscale
  • 尽管 Unraid Tailscale 插件不是 Docker 集成的必要条件,但强烈建议在您的 Unraid 服务器上安装并登录以获得最佳体验。

:::

Tailscale 添加到 Docker 容器:

  1. Serve:允许您使用友好的 HTTPS URL 从您的 Tailnet 安全访问容器的网页或 Web 服务。不需要端口转发,且只能通过 Tailnet 设备进行连接。
  2. 在 Unraid 中,转到 Docker 选项卡并 编辑所需的容器
  3. 启用 使用 Tailscale 开关。
  4. 为容器输入一个 Tailscale 主机名(必须在您的 Tailnet 上唯一)。
警告

HTTPS 证书将为此主机名生成,并发布在公共证书册中。选择您愿意公开分享的名称。有关详细信息,请参阅 Tailscale HTTPS 文档

  1. 决定此容器是否应成为出口节点(对于 VPN 容器非常有用)。
  2. Choose whether the container should use an exit node for its outgoing traffic. If the Tailscale plugin is installed, you’ll see a list of available exit nodes; otherwise, enter the IP manually.
  3. 如果使用出口节点,指定容器是否还应访问您的 LAN。
  4. Tailscale 用户空间网络 字段通常自动设置。除非有特定需求,否则请保持禁用状态。
  5. 决定是否启用 Tailscale SSH(通过 Tailscale 认证的安全外壳访问)。
Serve 与漏斗
  • 编辑容器并标识映射路径以存储 Tailscale 状态数据(例如,/container-path/)。
  • 启用 Tailscale 显示高级设置 并设置 Tailscale 状态目录/container-path/.tailscale_state
  1. 启用 Serve 可将容器的 Web 界面反向代理到您的 Tailnet,或启用 Funnel 以使其在公共互联网中可访问。Unraid 将根据容器的 WebUI 设置自动检测要使用的端口。如有需要,还提供高级选项。
警告

Tailscale 经常更新以提供新功能和安全改进。为使您的 Unraid 系统保持安全和兼容,请确保 Unraid Tailscale 插件和使用 Tailscale 的任何 Docker 容器都是最新的。

  1. Apply your changes and check the Enhanced Log or Log Viewer for Tailscale messages. Click the To authenticate, visit... link to approve the container on your Tailnet.

:::caution[Troubleshooting]

持久状态错误 - 如果您看到 "错误:未检测到 .tailscale_state 的持久 Docker 目录":

  • 编辑容器并标识映射路径以存储 Tailscale 状态数据(例如,/container-path/)。
  • 启用 Tailscale 显示高级设置 并设置 Tailscale 状态目录/container-path/.tailscale_state
  • 重启容器。
  • Docker XML 作者可以通过在容器的 XML 文件中添加 <TailscaleStateDir>/container-path/.tailscale_state</TailscaleStateDir> 来简化这一过程。

:::


更新 Tailscale

Tailscale 经常更新以提供新功能和安全改进。为使您的 Unraid 系统保持安全和兼容,请确保 Unraid Tailscale 插件和使用 Tailscale 的任何 Docker 容器都是最新的。

Updating the Tailscale Plugin

When a new version is available, update the plugin through the Unraid Apps tab just like any other plugin. The plugin is actively maintained and regularly updated with the latest Tailscale features. You can always review the latest Tailscale changes in the Tailscale changelog and the plugin release notes.

Updating Tailscale in Docker Containers

To update Tailscale in Docker containers:

  1. 在 Docker 页面,悬停在某个容器的 Tailscale 图标上。如果有可用更新,您将看到通知。
  2. 通过以下方式更新容器:
    • Switching to Advanced View (upper-right corner), then clicking Force update.
    • 编辑容器,进行微小更改(如切换一个设置),并点击 应用

用户空间网络

* “WireGuard”和“WireGuard”徽标是Jason A. Donenfeld的注册商标。

  • 启用: 容器在受限环境中操作。它无法启动与其他 Tailnet 设备的连接或使用 Tailscale DNS,但仍可通过 Tailscale WebUI 和原始 WebUI URL 访问。

  • 禁用: 容器具有完整的 Tailnet 访问权限,并可以使用 Tailscale DNS。它可以与其他 Tailnet 设备通信,但原始 WebUI URL 可能无法使用。

Feature 要求
  • 设置为 出口节点 的容器始终开启用户空间网络。
  • 使用出口节点的容器始终关闭用户空间网络。

网络类型兼容性

Tailscale 集成和用户空间网络的行为取决于容器的网络类型。使用下表了解兼容性和访问选项:

网络类型用户空间网络默认可以改变吗?WebUI 访问(Tailscale)WebUI 访问(原始)笔记
host禁用不可以不可以可以宿主模式下未提供 Tailscale 集成
bridge禁用可以可以启用: 可以 禁用: 不可以如果启用,则启用两个 URL;如果禁用,只启用 Tailscale WebUI
eth0/br0/bond0禁用可以可以可以无论设置如何,都可以访问两个 URL
container/wg0已禁用(未经测试)可以未知未知使用时请谨慎;尚未完全测试
Keep 记住
  • Tailscale 的 WebUI 地址仅可由安装了 Tailscale 并加入您 Tailnet 的设备访问,或者在显式共享启用时访问。
  • 对于大多数用户,默认设置提供安全且可靠的访问。针对特殊的网络需求提供高级选项。

* "WireGuard"和 "WireGuard"徽标是Jason A. Donenfeld的注册商标.