把 Cloudflare Tunnel 的繁琐流程封装成极简 CLI
cftunnel quick <端口>,零配置生成 *.trycloudflare.com 临时公网地址,无需账户和域名
init → create → add → up,4 条命令搞定自有域名穿透,DNS CNAME 自动创建和清理
macOS (Intel / Apple Silicon)、Linux (amd64 / arm64)、Windows 10+ (amd64 / arm64)
基于 Cloudflare 全球网络加密传输,无需公网 IP,完全免费使用
--auth user:pass 一键启用密码保护,内置鉴权代理中间件,无需外部依赖,支持 WebSocket 透传
cftunnel install 一键注册开机自启 — macOS launchd / Linux systemd / Windows Service
程序同级目录放一个 portable 空文件,配置/日志/二进制全部就地存储,U 盘携带
内置多镜像源轮询,自动选择最快通道,国内用户也能秒装 cloudflared
cftunnel update 一键升级到最新版,自动检测 GitHub Release
cftunnel destroy 自动删隧道 + 删 DNS 记录 + 删本地配置,不留残余
cftunnel 是 cloudflared 的智能管理层,不是代理本身
同样的 Cloudflare Tunnel,更简单的操作方式
| 操作 | 原生 cloudflared | cftunnel |
|---|---|---|
| 免域名穿透 | cloudflared tunnel --url 手动操作 | cftunnel quick <端口> |
| 创建隧道 | 登录浏览器 + 手动配置 | cftunnel create my-tunnel |
| DNS 记录 | 手动去 Dashboard 创建 CNAME | 自动创建和清理 |
| 多路由管理 | 手动编辑 YAML 配置 | add / remove / list |
| 开机自启 | 手动写 systemd / launchd | cftunnel install |
| 清理资源 | 手动删隧道 + 删 DNS + 删配置 | cftunnel destroy |
| 自更新 | 无 | cftunnel update |
| 便携模式 | 无 | portable 文件启用 |
| 密码保护 | 需配合 Cloudflare Access | --auth user:pass 内置鉴权 |
| 下载加速 | 仅 GitHub 原始地址 | 多镜像源自动轮询 |
| Windows 检测 | 无 | 自动检测 Win10+ 版本 |
所有命令一览,复制即用
常见问题与解决方案
failed to dial to edge with quic: timeout
代理/防火墙拦截了 UDP。cftunnel v0.6.1+ 已默认使用 HTTP/2(TCP)。运行 cftunnel uninstall && cftunnel install 重装服务即可。
cloudflared 解析到 198.18.0.x
Clash 等代理的 TUN 模式劫持了 DNS。将 cloudflared 进程加入 TUN 绕行列表,或将 *.argotunnel.com 加入 fake-ip-filter。
DNS CNAME 指向旧 Tunnel ID
运行 cftunnel remove <名称> 再 cftunnel add 重建路由,自动修正 DNS 记录。
cloudflared 未连接到 Edge
运行 cftunnel logs -f 查看实时日志,根据具体错误参考上述对应方案排查。
单二进制文件,零运行时依赖
$ curl -fsSL https://raw.githubusercontent.com/qingchencloud/cftunnel/main/install.sh | bash
支持 macOS Intel / Apple Silicon、Linux amd64 / arm64
PS> irm https://raw.githubusercontent.com/qingchencloud/cftunnel/main/install.ps1 | iex
支持 Windows 10+ (amd64 / arm64),自动添加到 PATH
$ git clone https://github.com/qingchencloud/cftunnel.git $ cd cftunnel $ make build
需要 Go 1.21+
也可以从 GitHub Releases 手动下载
两种模式,按需选择
$ cftunnel quick 3000 ✔ 隧道已启动: https://xxx-yyy-zzz.trycloudflare.com # Ctrl+C 退出,域名自动失效
$ cftunnel init $ cftunnel create my-tunnel $ cftunnel add app 3000 --domain app.example.com $ cftunnel up # app.example.com → localhost:3000