v0.7 · 双模式穿透 · 开源免费 · MIT

全协议内网穿透工具

Cloudflare 免费穿透 + 自建中继全协议穿透,一个工具搞定

Cloud 模式
Relay 模式
zsh
$ cftunnel quick 3000
✔ 隧道已启动: https://xxx-yyy-zzz.trycloudflare.com
$ cftunnel relay add mc --local 25565 --proto tcp
✔ 规则已添加: tcp://localhost:25565 → 远程:25565
6
平台支持
1
条命令穿透
0
费用
协议覆盖
Features

双引擎,全场景覆盖

Cloud 模式零成本穿透 HTTP/WS,Relay 模式自建中继支持 TCP/UDP 全协议

Cloud 模式

基于 Cloudflare Tunnel,免费穿透 HTTP/HTTPS/WebSocket,自动 TLS,全球 CDN 加速

Relay 模式

基于 frp 自建中继,支持 TCP/UDP 全协议穿透,适合游戏服务器、SSH、数据库等场景

一条命令穿透

cftunnel quick 3000 即刻穿透,零配置上手

6 平台支持

macOS / Linux / Windows,ARM64 + AMD64 全覆盖

自有域名模式

绑定自己的域名,自动配置 DNS 和 TLS 证书

系统服务

一键注册 launchd / systemd / Windows Service,开机自启

自动安装 cloudflared

自动检测平台下载对应二进制,无需手动安装

自更新

cftunnel selfupdate 一键升级到最新版本

实时日志

纯 Go 实现跨平台 tail,实时查看隧道日志

开源免费

MIT 协议,代码完全开源,社区驱动

访问保护

--auth 一键启用密码保护,内置鉴权代理中间件

桌面客户端

图形界面管理隧道,适合不熟悉命令行的用户

Architecture

双模式架构

两种穿透路径,覆盖不同场景需求

Cloud 模式

localhost:端口
本地流量
cftunnel
启动管理
cloudflared
QUIC 隧道
Cloudflare Edge
全球 CDN
公网用户访问

Relay 模式

localhost:端口
本地流量
cftunnel (frpc)
TCP/UDP 隧道
你的服务器 (frps)
公网端口映射
远程访问
Compare

模式对比

根据你的场景选择合适的穿透模式

功能Cloud 模式Relay 模式
支持协议HTTP / HTTPS / WebSocketTCP / UDP / 全协议
需要Cloudflare 账号(免费)一台公网服务器
域名免费随机域名 / 自有域名服务器 IP 直连
加密自动 TLS + Cloudflare CDNfrp 内置加密
费用完全免费服务器成本
典型场景Web 开发、API 调试、Webhook游戏服务器、SSH、数据库、RDP
启动命令cftunnel quick 3000cftunnel quick 25565 --relay
Commands

命令速查

两种模式的常用命令一览

Cloud 模式
Relay 模式
cftunnel init
初始化配置(API Token + Account ID)
cftunnel quick 3000
一键穿透本地 3000 端口(免域名)
cftunnel create mytunnel
创建命名隧道
cftunnel add myapp 8080 --domain app.example.com
添加域名路由
cftunnel remove myapp
删除域名路由
cftunnel up
启动隧道
cftunnel down
停止隧道
cftunnel logs
查看实时日志
cftunnel install
注册系统服务(开机自启)
cftunnel destroy
删除隧道 + DNS + 配置
cftunnel relay init
初始化中继配置(服务器地址 + Token)
cftunnel relay add web --local 8080 --proto tcp
添加 TCP 穿透规则
cftunnel relay add mc --local 25565 --proto tcp
穿透 Minecraft 服务器
cftunnel relay add voice --local 9987 --proto udp
穿透 UDP 端口(如语音服务)
cftunnel relay remove web
删除穿透规则
cftunnel relay up
启动中继连接
cftunnel relay down
停止中继连接
cftunnel relay list
列出所有穿透规则
cftunnel relay install
注册中继系统服务
cftunnel relay server setup
SSH 远程安装 frps 服务端
cftunnel relay logs
查看中继日志
Troubleshoot

常见问题排查

遇到问题?这里有最常见的解决方案

QUIC 连接超时

部分网络环境屏蔽 UDP/443。解决:设置 --protocol http2 回退到 HTTP/2,或检查防火墙规则。

fake-ip 冲突

Clash 等代理工具的 fake-ip 模式可能劫持 Cloudflare 域名解析。解决:将 trycloudflare.com 加入直连规则。

错误 1033

Cloudflare Argo Tunnel 错误,通常是隧道配置不匹配。解决:cftunnel down 后重新 cftunnel up,或删除重建隧道。

错误 530

DNS 解析指向了错误的隧道。解决:检查 DNS CNAME 记录是否指向正确的 tunnel UUID,使用 cftunnel remove 清理后重新添加。

Install

快速安装

选择你的平台,一行命令搞定

macOS / Linux
Windows
源码编译
# 自动尝试国内镜像源加速,无需手动配置
curl -fsSL https://raw.githubusercontent.com/qingchencloud/cftunnel/main/install.sh | bash

# 国内网络慢?也可以手动使用镜像源下载:
# curl -fsSL https://ghfast.top/https://github.com/qingchencloud/cftunnel/releases/latest/download/cftunnel_linux_amd64.tar.gz -o cftunnel.tar.gz
# tar xzf cftunnel.tar.gz && sudo install -m 755 cftunnel /usr/local/bin/
irm https://raw.githubusercontent.com/qingchencloud/cftunnel/main/install.ps1 | iex
git clone https://github.com/qingchencloud/cftunnel.git
cd cftunnel
go build -o cftunnel .
Quick Start

三种模式,按需选择

从零开始,3 分钟完成内网穿透

1

免域名模式

无需 Cloudflare 账号,获得随机域名,适合临时分享和调试

cftunnel quick 3000
2

自有域名模式

绑定自己的域名,需要 Cloudflare 账号和 API Token

cftunnel init
cftunnel create mytunnel
cftunnel add myapp 8080 --domain app.example.com
cftunnel up
3

中继模式

自建中继服务器,支持 TCP/UDP 全协议穿透

cftunnel relay init
cftunnel relay add mc --local 25565 --proto tcp
cftunnel relay up
Server

中继服务端部署

在你的公网服务器上部署 frps,作为中继节点

SSH 远程安装
一键脚本
Docker Compose
# 在本地一条命令搞定服务端安装 + 客户端配置
cftunnel relay server setup --host 你的服务器IP --user root

# 支持密钥认证
cftunnel relay server setup --host 1.2.3.4 --key ~/.ssh/id_ed25519

# 支持密码认证(交互输入,不落历史记录)
cftunnel relay server setup --host 1.2.3.4 --password

# 全交互模式
cftunnel relay server setup
curl -fsSL https://raw.githubusercontent.com/qingchencloud/cftunnel/main/install-relay.sh | bash
# 1. 下载配置文件
mkdir -p cftunnel-relay && cd cftunnel-relay
curl -fsSLO https://raw.githubusercontent.com/qingchencloud/cftunnel/main/docker/relay-server/docker-compose.yml
curl -fsSLO https://raw.githubusercontent.com/qingchencloud/cftunnel/main/docker/relay-server/frps.toml.example
cp frps.toml.example frps.toml

# 2. 编辑 frps.toml,设置你的 auth.token
# bindPort = 7000
# auth.token = "你的密钥"

# 3. 启动
docker compose up -d
Desktop

桌面客户端

图形界面管理隧道,更直观的操作体验

cftunnel Desktop

基于 Tauri 构建,轻量原生,支持 Cloud 模式和 Relay 模式的可视化管理