Smaller Tailscale Repository For OpenWrt


Note:

These are smaller Tailscale packages for OpenWrt, specifically designed to reduce storage usage while maintaining essential functionality.

      optimized:

  • Combined tailscale and tailscaled into a single binary.
  • Built with the --extra-small flag to significantly reduce binary size.
  • UPX compression applied to binaries (except for mips64 architecture) to further reduce storage usage.

Repository Setup

Import the public key used to verify package signatures:

Run this command on your OpenWrt device:

wget -O /tmp/key-build.pub https://gunanovo.github.io/openwrt-tailscale/key-build.pub && opkg-key add /tmp/key-build.pub

Add the package feed to your OpenWrt configuration:

Edit /etc/opkg/customfeeds.conf:

echo "src/gz openwrt-tailscale https://gunanovo.github.io/openwrt-tailscale" >> /etc/opkg/customfeeds.conf

Or manually add this line:

src/gz openwrt-tailscale https://gunanovo.github.io/openwrt-tailscale

Installation Methods

Choose your preferred method to install Tailscale on OpenWrt:

Web UI:

  1. Navigate to System → Software ;
  2. Click Update lists to refresh packages ;
  3. Search for "tailscale" ;
  4. Install the main package and any desired utilities ;

Command Line:

opkg update
opkg install tailscale

Note: The "failed log upload" message during installation is expected and can be safely ignored.

Post-Installation Steps

After installation, you need to configure Tailscale to connect your device to the Tailscale network.

Run the following command to start Tailscale and configure it:

tailscale up \
    --accept-dns=false \
    --advertise-routes=10.0.0.0/24 \
    --advertise-exit-node

If you're using OpenWrt == 22.03 you will also need to specify --netfilter-mode=off. For versions 23+ do NOT include netfilter-mode.

Tips:

  • Consider adding --hostname=your-router-name for easier identification.

Note:

If you encounter any of the following situations:

  • Your device has limited RAM, and during usage, Tailscale consumes an excessive amount of memory;
  • Or Tailscale is killed and restarted by the OOM Killer;
  • Or you’re not sure why Tailscale keeps restarting unexpectedly;

Then you may try trading higher CPU usage for lower memory usage. Here's how:

  1. Edit the /etc/init.d/tailscale file:
  2. vi /etc/init.d/tailscale
  3. Locate the following line:
  4. procd_set_param env TS_DEBUG_FIREWALL_MODE="$fw_mode"
  5. Append GOGC=10 to the end of that line so it becomes:
  6. procd_set_param env TS_DEBUG_FIREWALL_MODE="$fw_mode GOGC=10"

    This will make Tailscale more aggressive in memory garbage collection.

Note:

这是为 OpenWrt 精简定制的 Tailscale 软件包,旨在在保持核心功能的同时,尽可能降低存储占用。

      优化内容:

  • tailscaletailscaled 合并为一个单一的可执行文件。
  • 使用 --extra-small 编译标志以显著减小二进制文件体积。
  • 使用 UPX 对二进制文件进行压缩(mips64 架构除外),进一步降低存储占用。

软件源设置

导入用于验证软件包签名的公钥:

在你的 OpenWrt 设备上执行以下命令:

wget -O /tmp/key-build.pub https://gunanovo.github.io/openwrt-tailscale/key-build.pub && opkg-key add /tmp/key-build.pub

将软件源添加到你的 OpenWrt 配置中:

编辑 /etc/opkg/customfeeds.conf 文件:

echo "src/gz openwrt-tailscale https://gunanovo.github.io/openwrt-tailscale" >> /etc/opkg/customfeeds.conf

或者手动添加以下内容:

src/gz openwrt-tailscale https://gunanovo.github.io/openwrt-tailscale

安装方式

请选择你喜欢的方式安装 Tailscale:

Web 界面方式:

  1. 打开 系统 → 软件包(System → Software);
  2. 点击 更新列表(Update lists) 以刷新软件包;
  3. 搜索 "tailscale" ;
  4. 安装主软件包及其他你需要的工具组件 ;

命令行方式:

opkg update
opkg install tailscale

Note: 安装过程中出现 "failed log upload" 报错属于预期现象,可放心忽略。

安装后步骤

安装完成后,需要配置 Tailscale 以将设备接入 Tailscale 网络。

执行以下命令:

tailscale up \
    --accept-dns=false \
    --advertise-routes=10.0.0.0/24 \
    --advertise-exit-node

如果你的OpenWrt版本为22.03,你还需要添加 --netfilter-mode=off 参数, 对于 OpenWrt 23+ 则不应该包含该参数

Tips:

  • 建议添加 --hostname=your-router-name 参数,以便在 Tailscale 网络中更容易识别该设备。

NOTE:

如果你遇到以下情况:

  • 设备运行内存有限,在使用过程中出现tailscale占用极高运行内存;
  • 或直接致使tailscale被OOM KILLER杀死并重启;
  • 或你不清楚什么原因导致tailscale异常重启;

则,你可以尝试以更高的CPU占用换取较低的内存占用,操作如下:

  1. 修改 /etc/init.d/tailscale 文件
  2. vi /etc/init.d/tailscale
  3. 找到以下一行:
  4. procd_set_param env TS_DEBUG_FIREWALL_MODE="$fw_mode"
  5. 在该行后方加上参数 GOGC=10,使其变为:
  6. procd_set_param env TS_DEBUG_FIREWALL_MODE="$fw_mode GOGC=10"

    该参数将使 Tailscale 更积极地回收内存。