Cocoduck VPN Linux 与软路由配置手册:sing-box 核心与透明代理

面向场景:服务器运维、开发工程师以及需要在家庭软路由中实现全屋无缝透明代理的高阶用户。本文将指导如何在 Linux 环境中高效部署 sing-box 核心并接入 Cocoduck VPN 官方专线网络。

一、 为什么选择 sing-box 作为 Linux 代理基石

在 Linux 服务器(如 Ubuntu、Debian)以及 OpenWrt 软路由系统中,sing-box 具备以下技术特点:

二、 sing-box 部署步骤

1. 二进制核心安装

在终端中下载官方编译好的独立二进制执行文件(以 64 位 x86 架构为例):

# 下载官方 Release 包
curl -Lo sing-box.tar.gz https://github.com/SagerNet/sing-box/releases/download/v1.9.0/sing-box-1.9.0-linux-amd64.tar.gz
tar -xzf sing-box.tar.gz
sudo mv sing-box-*/sing-box /usr/local/bin/
sudo chmod +x /usr/local/bin/sing-box
sing-box version

2. 获取 Cocoduck 订阅配置

登录 Cocoduck VPN 官方用户中心,获取配置 JSON,放置于 /etc/sing-box/config.json。

3. 配置 systemd 守护进程与开机自启

创建系统服务文件 /etc/systemd/system/sing-box.service:

[Unit]
Description=sing-box service
After=network.target nss-lookup.target

[Service]
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
ExecStart=/usr/local/bin/sing-box run -c /etc/sing-box/config.json
Restart=on-failure
RestartSec=10s
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

启动并查看服务状态:

sudo systemctl daemon-reload
sudo systemctl enable --now sing-box
sudo systemctl status sing-box

三、 Linux 终端命令行代理快速生效

在终端中声明环境变量即可加速终端网络:

# 临时开启当前终端代理
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
export all_proxy="socks5://127.0.0.1:7890"

# 验证加速效果
curl -I https://www.google.com

在服务器与软路由上体验专线加速

低至 ¥77/年 即可拥有高吞吐、低开销的专线节点,完美契合 sing-box 极客环境。

前往官网获取 Cocoduck VPN 官方套餐 →

四、 本文常见问题 (FAQ)

在 Linux 终端中为什么 curl 仍然连不上国外服务?

Linux 终端默认不继承全局代理。需要在当前 Shell 会话中手动设置环境变量:export http_proxy="http://127.0.0.1:7890" 和 export https_proxy="http://127.0.0.1:7890",或将其写入 ~/.bashrc 中实现持久化生效。

为什么在软路由上推荐 sing-box 连接 Cocoduck 专线?

sing-box 是完全用 Go 语言编写的通用网络代理平台,代码轻量、内存占用极低(通常仅 20-40MB),且原生支持 Cocoduck VPN 全站所采用的 VLESS 协议,非常适合内存有限的软路由或 VPS 运行。