本文来源:https://mp.weixin.qq.com/s/JQ5cDdkort5LsFSSn6e0Jw
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。
前阵子我要把做好的项目给客户预览,顺手打开了花生壳,好家伙,默认 1Mbps 带宽,首屏转半天。更难受的是想加固定域名、开 HTTPS、多挂几个端口,样样都得额外付费升级。后来我换成了 Cloudflare Tunnel 内网穿透,免费、不限速、自带 HTTPS,一行命令就拿到公网地址。这篇文章把"为什么需要内网穿透""常用工具有哪些坑",以及 macOS 和 Windows 两个系统的安装使用,一次性讲清楚。点个收藏咱们开始。
一、先说清楚:我们为什么需要内网穿透
内网穿透要解决的核心矛盾就一句话:你电脑上的服务很好,但外网访问不到它。
内网穿透:把家里、公司内网里的服务,通过一个公网中转节点暴露到互联网上,让外网能主动访问的技术。你可以理解为给你的内网服务开一扇通往公网的"任意门"。
为什么这是个刚需?我数几个真实场景,你大概率中过一条:
-
1. 没有公网 IP。家宽和企业宽带现在普遍在 NAT 后面,运营商既不给固定公网 IP,很多连动态公网 IP 都不给(直接 CGNAT 大内网)。你想从外面连家里的机器,门都没有。 -
2. 本地开发要给人预览。前端跑在 localhost:5173、后端跑在localhost:8000,想发个链接给同事、客户或手机看看,localhost只有你自己能开。 -
3. 回调需要 HTTPS 公网域名。微信支付、公众号、企业微信、GitHub Webhook 这类回调,硬性要求一个公网可达的 HTTPS 地址,你本地 http://localhost根本接不住。 -
4. 自建服务想外网访问。NAS、家庭实验室、本地跑的 AI 服务、私有 LLM,想在外面也能临时用,又不想为这点访问专门买公网服务器、动路由器端口。
可能有人会问:不能直接在路由器上做端口转发吗?
能,但前提是你有公网 IP。没公网 IP 直接 GG;就算有,把家里端口暴露到公网,安全风险也不小,还要处理运营商封端口、动态 IP 变动、HTTPS 证书一堆事。内网穿透的本质就是把这些麻烦外包给一个公网中转节点。
说白了,内网穿透工具就是帮你"在没有公网 IP 的前提下,把本地服务安全地搬到公网"。下面看看市面上的工具,坑还不少。
二、常用内网穿透工具盘点:每个都有它的脾气
这一节不长,但能帮你少踩几个坑。常用工具我按"坑的类型"归一下类,你看看自己卡在哪条。
花生壳(贝锐旗下):国内老牌动态域名 + 内网穿透服务,有 GUI 客户端,对不熟悉命令行的人比较友好,免费档带宽和映射条数受限、增值功能付费。
花生壳免费档最明显的限制是带宽。其免费版转发带宽为 1Mbps(理论下载约 125KB/s),通常还伴随映射条数、并发连接数限制并需实名认证。一个没压缩的本地前端首屏动辄 5~10MB,按 1Mbps 算要转几十秒。至于固定域名、HTTPS、更高带宽、更多映射,则要付费升级。我个人用下来,临时给一两个人看个纯前端页面还行,长期或传大资源就有些吃力。
ngrok:海外老牌工具,命令行一行起隧道,有请求面板,生态成熟。免费档需注册账号 + authtoken,只有随机域名(每次重启变),固定域名要订阅付费;2026 年起免费档进一步收紧,有会话时长和每月流量限制。临时调试够用,长期或商用基本要付费。
frp:开源、自托管、不限速、不限域名,完全在你的掌控下。代价是你得自己有一台带公网 IP 的云服务器跑服务端 frps,Mac / Windows 跑客户端 frpc,配置文件略繁。你已经有 VPS 的话,frp 是长期方案的天花板。
natapp:国内常见的一款,注册后买个免费隧道、把本地端口配上去,跑 natapp -authtoken=你的token 就能拿到一个 xxx.natappfree.cc 的公网地址,接微信公众号回调这类场景很顺手。我之前写微信公众号验证码登录那篇时就是用它做的内网穿透,完整配置流程见《SpringBoot 实战:微信公众号验证码登录功能(全流程详解+源码)》。免费隧道同样有带宽和连接数限制,长期或大流量建议升级。
cpolar / localtunnel 等:和上面几个一类,免费档基本都限速或限量;localtunnel 走公共服务器,高峰期常不稳定。应急够用,指望它稳不太现实。
把几个常见方案放一起对比,一目了然:
|
|
|
|
|
|
|
|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
看这张表你应该明白我为什么最终落在 Cloudflare Tunnel 了:免费、不限速、自带 HTTPS、不用服务器、不用绑卡。下面正式讲它。
三、Cloudflare Tunnel 是什么,凭啥免费不限速
Cloudflare Tunnel 是 Cloudflare 官方的内网穿透方案,核心是一个叫 cloudflared 的轻量客户端。
Cloudflare Tunnel(cloudflared):Cloudflare 提供的轻量级客户端守护进程,在你本机和 Cloudflare 全球边缘网络之间建一条加密出站隧道,外网请求先到 Cloudflare,再由 Cloudflare 反向代理回你本地的服务。可以理解为"Cloudflare 帮你做好了反向代理 + HTTPS,你只要装个客户端"。
你不需要公网 IP,也不用在路由器开端口,cloudflared 是从你本机主动连出去到 Cloudflare(出站连接,防火墙一般不拦),再由 Cloudflare 把公网请求顺着这条隧道送回来。安全性和可访问性都比"在家开端口"强一截。
快速隧道:cloudflared 的一条免登录、免配置命令,启动即生成一个 trycloudflare.com 的随机子域名,把本地端口临时暴露到公网。可以理解为"不用注册账号、试穿一次就走的体验装"。
为什么能免费还不限速?官方文档说得很直白,我贴一段原文:
"We want more users to experience the speed and security improvements of Cloudflare Tunnel. We hope you test it with TryCloudflare and decide to add it to your production sites."
——Cloudflare Quick Tunnels 官方文档
翻译过来就是:Cloudflare 希望你先用免费的快速隧道体验它的速度和安全,将来正式项目时再把它用进生产环境。它把免费隧道当成产品试用入口,所以带宽不卡你(走的是 Cloudflare 全球边缘网络,我实测本机经边缘节点往返约 1.5 秒,做开发预览足够用)。
当然,免费是有代价的——代价是"没有 SLA 保证、域名随机、仅供测试开发"。官方同一篇文档里也明说:"We don't guarantee any SLA or uptime of TryCloudflare... Free tunnels are meant to be used for testing and development, not for deploying a production website." 这些限制下文会展开。
理解了原理,装起来就顺了。下面分 macOS 和 Windows 两套,都是我实测过的。
四、macOS 安装与使用(brew 一行搞定)
macOS 走 Homebrew,最省心。我这次用的版本是 cloudflared 2026.7.2
1)安装
# 适用于 macOS,需先有 Homebrewbrew install cloudflared# 验证版本cloudflared --version
如果你没装 Homebrew,去 brew.sh 按一行命令装上即可;或者按官方文档下载 Darwin 对应架构的二进制包手动放进去(搜:cloudflared macOS download)。
2)起一条快速隧道
先把本地服务跑起来(比如前端在 5173),然后另开一个终端标签页执行:
# 把本机 5173 端口暴露到公网,换成你的端口即可cloudflared tunnel --url http://localhost:5173
几秒后,输出里会出现一行关键信息:
Your quick Tunnel has been created! Visit it at (it may take some time to be reachable):https://xxx-xxx-xxx.trycloudflare.com
把这个 https://xxx.trycloudflare.com 复制出去就行,自带 HTTPS,手机、外网、同事那边直接打开。
3)停止
在那个终端窗口按 Ctrl+C,链接立刻失效,不残留、不收费。每次重新跑,域名都会随机变一个。
可能有人会问:这个 trycloudflare 域名能固定吗?
快速隧道不能,每次启动都是随机子域名。想固定,得用"命名隧道 + 自己的域名",见文末进阶部分。临时预览用快速隧道就够了。
五、Windows 安装与使用(winget 或 MSI 两种方法)
Windows 稍微多一步,但也很简单。两种安装方式任选其一。
方式一:winget(推荐,Windows 10/11 自带)
# 以命令行安装,包 ID 是 Cloudflare.cloudflaredwinget install -e --id Cloudflare.cloudflared# 验证(新开一个 PowerShell 窗口,让 PATH 生效)cloudflared --version
winget 是微软官方包管理器,Win10 1709 之后基本都自带。装完记得新开一个 PowerShell 窗口,否则 cloudflared 命令可能还没进 PATH。
方式二:MSI 安装包(图形化、适合不想敲命令的)
去 GitHub 官方发布页下载对应安装包(搜:cloudflared releases):
-
64 位 MSI:cloudflared-windows-amd64.msi
-
32 位 MSI:
cloudflared-windows-386.msi
双击安装后,cloudflared.exe 会进系统 PATH,打开新的 PowerShell/CMD 就能用。官方下载页见 Cloudflare Tunnel Downloads。
起隧道(和 macOS 完全一样)
# 暴露本机 5173 到公网cloudflared tunnel --url http://localhost:5173
同样在输出里找那行 https://xxx.trycloudflare.com,复制即可。停止一样是 Ctrl+C。
你可能会想:Windows 上能不能让它开机自启、后台一直跑?
能。MSI 装好后,以管理员身份执行
cloudflared service install,它会注册成系统服务常驻;不想用了cloudflared service uninstall卸掉。不过快速隧道随机域名每次重启会变,开机自启更适合配命名隧道用。
六、实测验证:公网地址真的能打开页面
光说不练假把式。我这篇文章的命令就是边写边在本机跑的,贴一段真实输出给你看。
装完 cloudflared 2026.7.2,起隧道指向本地 5173 的一个 Vue 项目,拿到地址 https://walking-limits-spectacular-scale.trycloudflare.com,然后分别测公网入口和本地直连:
# 通过 Cloudflare 公网地址访问curl -sS -o /dev/null -w "HTTP %{http_code} | 下载 %{size_download} bytes | 耗时 %{time_total}s\n" \ https://walking-limits-spectacular-scale.trycloudflare.com/# 对比:直接访问本机curl -sS -o /dev/null -w "HTTP %{http_code} | 下载 %{size_download} bytes\n" http://localhost:5173/
结果:公网入口返回 HTTP 200,下载 537 字节,耗时约 1.5 秒;本地直连同样 200、537 字节。两者内容一致,说明整条链路"公网 → Cloudflare 边缘节点 → 我的 Mac → localhost:5173"完全打通,返回的就是真实页面。
换 1Mbps 的花生壳,同样 537 字节当然秒回;但首屏那 5~10MB 的资源,差距就拉开了。这也是我把花生壳换掉的根本原因。
七、快速隧道的限制与注意事项(必看)
免费好用,不代表没有边界。这几条官方文档明说的限制,你心里要有数:
-
1. 无 SLA、无稳定性保证。官方原话:"We don't guarantee any SLA or uptime of TryCloudflare." 偶尔会断,断了重跑一遍命令、换个新地址即可,别拿它跑生产业务。 -
2. 并发请求硬上限 200。同一时刻在途请求超过 200 个,Cloudflare 直接返回 429。个人预览完全够,但别拿它压测或扛流量。 -
3. 不支持 SSE(Server-Sent Events)。如果你穿透的是流式接口(比如某些 AI 流式输出用 SSE),快速隧道走不通,需要用命名隧道。 -
4. 域名每次随机。 trycloudflare.com前面那串每次启动都变,没法当固定地址发出去长期用。 -
5. 只在终端开着时有效。关终端、Ctrl+C、电脑休眠,链接就断。要长期挂,用后台服务或命名隧道。 -
6. 对外是 HTTPS,到你本地那段是 HTTP。你穿的是 http://localhost:端口,不用配证书;HTTPS 由 Cloudflare 在边缘终止,省心。 -
7. 无需注册、无需绑卡。快速隧道连账号都不要,这是它最爽的一点。命名隧道才需要免费注册 Cloudflare 账号(官网标注 "no credit card required",但 Zero Trust 控制台个别情况可能要求留个支付方式做反滥用,免费档不扣费)。
一句话总结:快速隧道 = 开发预览、临时分享、回调测试的完美工具,不是生产工具。
八、想要固定域名?进阶看命名隧道
如果哪天你要长期挂一个固定地址(比如给团队稳定的预览环境、接 Webhook 回调),就该从快速隧道升级到命名隧道了。
命名隧道需要:免费注册 Cloudflare 账号 → 一个托管在 Cloudflare 的域名 → cloudflared login 授权 → cloudflared tunnel create 建隧道 → 写 config.yml 指定域名与本地端口映射 → cloudflared service install 装成系统服务(launchd / Windows 服务)开机自启。
配好之后就是"开机自动起、固定域名、永久在线",不用再敲命令。完整步骤以官方文档为准:Connect through Cloudflare Tunnel。我个人建议:先把快速隧道用熟,确定长期需要再上命名隧道,别一上来就折腾配置文件。
九、报错排查:我替你踩过的三个坑
这一节是我真踩过的坑,贴出来帮你省时间。
坑一:页面打开报 "Blocked request. This host is not allowed"
穿透成功,但浏览器一访问就被开发服务器拦,提示要把域名加到 allowedHosts。原因是较新版本的 Vite 等现代开发服务器会校验请求的 Host 头,防止 DNS 重绑定攻击,而隧道转发过来的 Host 是 xxx.trycloudflare.com,不是本机,于是被拦。
解法:在 vite.config 的 server 里放开 Host 校验。
// vite.config.js / .tsexport default defineConfig({ server: { host: true, // 监听 0.0.0.0,允许外部访问 allowedHosts: true, // 允许 trycloudflare 这类 Host 头 },})
坑二:本地能开,但 http://内网IP:端口 和隧道都连不上
八成是服务只绑了 127.0.0.1 或 IPv6 回环 ::1,没监听所有网卡。表现是 lsof 看到 TCP [::1]:5173 (LISTEN) 而不是 *:5173。解法同上,设 host: true 让它监听 0.0.0.0。改完记得重启 dev server,这种配置不热更新。
坑三:页面能开,但 /api 接口报错
穿透的是前端端口(如 5173),页面里的接口请求经开发服务器的代理转到本机后端(如 127.0.0.1:8000)。后端没起,页面开得开、接口却 404/502。这不是隧道的锅,把后端在本机跑起来就好。
可能有人会问:那我需要把后端端口也单独穿透一条吗?
不用。只要前端开发服务器配了
/api代理到后端,你只穿透前端一个端口,接口请求由前端服务在服务端转发到本地后端,对外只需要一条隧道。多穿一条反而多一个域名、多一份维护。
十、合规与说明
合规提醒:内网穿透适用于开发预览、临时分享、回调测试等短期场景;若在中国大陆对外正式、长期提供网站或信息服务,仍需依法办理 ICP 备案等手续,本文不鼓励用它规避监管。
说明:以上即 Cloudflare Tunnel 内网穿透的完整上手指南,结合个人 macOS 实测独立撰写;花生壳、ngrok、natapp 等工具的套餐、带宽与定价会随时间调整,文中数据为撰写时的公开信息,请以各厂商官网为准,观点与表述均为作者本人。
延伸阅读:想看内网穿透在真实业务里的用法,可看我之前这篇《SpringBoot 实战:微信公众号验证码登录功能(全流程详解+源码)》——里面用 Natapp 做内网穿透接微信回调。
如果这篇 Cloudflare Tunnel 内网穿透教程对你有帮助,欢迎点赞收藏;有踩坑或疑问,评论区见。

往期推荐
Source: https://mp.weixin.qq.com/s/JQ5cDdkort5LsFSSn6e0Jw If you have copyright concerns, please email: 13951431913#139.com or leave a comment on the right.
I recently wanted to preview a completed project with a client, so I opened Oray (花生壳) — and holy moly, the default bandwidth is only 1Mbps, with the first screen taking forever to load. Even worse, adding a fixed domain, enabling HTTPS, or exposing multiple ports all require paid upgrades. So I switched to Cloudflare Tunnel for my intranet penetration needs: it's free, unrestricted, comes with built-in HTTPS, and gives you a public address with a single command. This article covers everything in one go: why you need intranet penetration, what pitfalls the common tools have, and how to install and use it on both macOS and Windows. Bookmark this one and let's get started.
I. First, let's clarify: Why do we need intranet penetration?
The core contradiction that intranet penetration solves can be summed up in one sentence: the service on your computer is great, but no one on the public internet can reach it.
Intranet penetration is a technique that exposes services inside your home or corporate internal network to the internet through a public relay node, allowing external networks to actively access them. You can think of it as opening an "Anywhere Door" from your internal services to the public internet.
Why is this a must-have? Let me list a few real-world scenarios where you've likely hit a wall:
1. No public IP. Both residential and enterprise broadband now sit behind NAT. ISPs rarely assign fixed public IPs, and many don't even provide dynamic public IPs (they throw you straight into CGNAT). If you want to connect to your home machine from the outside, there's simply no door.
2. Need to preview local development work. Your frontend runs on localhost:5173, your backend on localhost:8000 — you want to send a link to a colleague, client, or your phone to check it out, but localhost only works on your own machine.
3. Callbacks require an HTTPS public domain. WeChat Pay, WeChat Official Accounts, WeCom, GitHub Webhooks — these callbacks all strictly require a publicly reachable HTTPS address. Your local http://localhost simply can't handle it.
4. Want to access self-hosted services from the internet. Your NAS, home lab, locally running AI services, or private LLM — you want to use them remotely occasionally without buying a public server or fiddling with router port forwarding.
Some might ask: Can't I just set up port forwarding on my router?
You can, but only if you have a public IP. Without one, it's game over. Even if you do, exposing your home ports to the internet carries significant security risks, plus you'd have to deal with ISPs blocking ports, dynamic IP changes, and HTTPS certificate headaches. Intranet penetration essentially outsources all these troubles to a public relay node.
In short, intranet penetration tools help you "securely expose your local services to the internet without a public IP." Let's look at the tools on the market — there are quite a few pitfalls.
II. Common Intranet Penetration Tools Review: Each Has Its Own Temperament
This section is short, but it can save you from several headaches. I've categorized the common tools by "type of pitfall" so you can see which bucket you fall into.
Oray (花生壳, by Beirui): A well-known domestic dynamic DNS + intranet penetration service. It has a GUI client, which is friendly to those uncomfortable with the command line. The free tier is limited in bandwidth and number of mappings, and value-added features require payment.
The most obvious limitation of Oray's free tier is bandwidth. The free version forwards traffic at 1Mbps (theoretical download speed of about 125KB/s), and typically also limits the number of mappings and concurrent connections, with real-name verification required. An uncompressed local frontend's first screen easily takes up 5–10MB, which at 1Mbps would take dozens of seconds to load. Fixed domains, HTTPS, higher bandwidth, and more mappings all require paid upgrades. My personal experience: fine for temporarily showing a pure frontend page to one or two people, but struggles with long-term use or large resources.
ngrok: A well-known overseas tool. Start a tunnel with one command line, has a request inspection panel, and a mature ecosystem. The free tier requires account registration plus an authtoken, and only provides random subdomains (changing on each restart); fixed domains require a paid subscription. Starting from 2026, the free tier has tightened further with session duration and monthly traffic limits. Fine for temporary debugging, but paid plans are essentially required for long-term or commercial use.
frp: Open-source, self-hosted, unlimited speed, unlimited domains — entirely under your control. The catch is you need your own cloud server with a public IP to run the frps server, and frpc clients on your Mac/Windows, with slightly complex configuration files. If you already have a VPS, frp is the ceiling for a long-term solution.
natapp: A commonly used domestic tool. After registration, purchase a free tunnel and configure your local port. Running `natapp -authtoken=your_token` will give you a public address like `xxx.natappfree.cc`, which is very convenient for scenarios such as handling WeChat public account callback URLs. I used it for intranet penetration when writing my article on WeChat public account verification code login. For the complete configuration process, see *SpringBoot in Practice: WeChat Public Account Verification Code Login Feature (Complete Guide + Source Code)*. Free tunnels also have bandwidth and connection limits; upgrading is recommended for long-term or high-traffic use.
cpolar / localtunnel, etc.: Similar to the above — free tiers are generally speed-limited or quota-limited. localtunnel routes through public servers and is often unstable during peak hours. Fine for emergencies, but don't rely on it for stability.
Here's a comparison of the common options at a glance:
Tool
Best Use Case
Speed Limit
Cost
HTTPS
Requires Server
Oray (花生壳)
Beginners, GUI users
Free tier: 1Mbps
Value-added features paid
Paid
No
ngrok
Temporary debugging, overseas
Free tier has connection limits
Fixed domain costs extra
Built-in
No
frp
Long-term self-hosted, with VPS
Only depends on your server bandwidth
Completely free
Self-configured
Needs VPS
Cloudflare Tunnel
Personal development, demos, callbacks
No speed limit
Free
Built-in
No
With this table, you should understand why I ultimately landed on Cloudflare Tunnel: free, no speed limit, built-in HTTPS, no server needed, no credit card required. Let's get into it.
III. What Is Cloudflare Tunnel, and Why Is It Free and Unmetered?
Cloudflare Tunnel is Cloudflare's official intranet penetration solution, centered around a lightweight client called cloudflared.
Cloudflare Tunnel (cloudflared): A lightweight client daemon provided by Cloudflare that establishes an encrypted outbound tunnel between your local machine and Cloudflare's global edge network. External requests first hit Cloudflare, which then reverse-proxies them back to your local service. Think of it as "Cloudflare handles the reverse proxy and HTTPS for you — you just install the client."
You don't need a public IP, and you don't need to open ports on your router. cloudflared initiates an outbound connection from your machine to Cloudflare (outbound connections are generally not blocked by firewalls), and Cloudflare then routes public requests back through that tunnel. This is significantly more secure and accessible than "opening ports at home."
Quick Tunnel: A no-login, no-configuration command in cloudflared that generates a random trycloudflare.com subdomain on startup, temporarily exposing your local port to the internet. Think of it as a "no-account-required trial" experience.
Why is it free and unmetered? The official documentation is straightforward — here's an excerpt:
"We want more users to experience the speed and security improvements of Cloudflare Tunnel. We hope you test it with TryCloudflare and decide to add it to your production sites."
——Cloudflare Quick Tunnels Official Documentation
In other words: Cloudflare wants you to try the free Quick Tunnel first to experience its speed and security, and later integrate it into your production environments. They treat free tunnels as a product trial entry point, so they don't throttle your bandwidth (in my tests, round-trip via the edge node was about 1.5 seconds from my local machine, which is plenty for development previews).
Of course, free comes with trade-offs — the trade-off is "no SLA guarantee, random domain, testing/development only." The same official doc explicitly states: "We don't guarantee any SLA or uptime of TryCloudflare... Free tunnels are meant to be used for testing and development, not for deploying a production website." These limitations are discussed below.
Once you understand the principle, installation is straightforward. Below are two tested setups for macOS and Windows.
IV. macOS Installation and Usage (one brew command)
On macOS, Homebrew makes this the easiest path. My tested version is cloudflared 2026.7.2.
1) Installation
If you haven't installed Homebrew, go to brew.sh and run the one-liner, or download the Darwin binary matching your architecture directly from the official docs (search: cloudflared macOS download).
2) Start a Quick Tunnel
Get your local service running first (e.g., your frontend on port 5173), then open a new terminal tab and run:
After a few seconds, you'll see a key line in the output:
Copy that https://xxx.trycloudflare.com link and share it. It comes with built-in HTTPS — open it on your phone, from outside the network, or share it with colleagues.
3) Stop
Press Ctrl+C in that terminal window and the link becomes invalid immediately. Nothing lingers, nothing costs money. Every time you restart, the domain will be randomly regenerated.
Someone might ask: Can the trycloudflare domain be made fixed?
No. Quick tunnels always generate a random subdomain on each startup. To get a fixed domain, you need a "named tunnel with your own domain" — see the advanced section at the end. For temporary previews, quick tunnels are perfectly sufficient.
V. Windows Installation and Usage (winget or MSI — pick one)
Windows requires one extra step, but it's still simple. Pick either installation method.
Method 1: winget (recommended, built into Windows 10/11)
winget is Microsoft's official package manager, included by default on Windows 10 1709 and later. After installing, make sure to open a new PowerShell window — otherwise the cloudflared command may not yet be in your PATH.
Method 2: MSI Installer (graphical, for those who prefer not to type commands)
Download the appropriate installer from the official GitHub releases page (search: cloudflared releases):
64-bit MSI: cloudflared-windows-amd64.msi
32-bit MSI: cloudflared-windows-386.msi
After double-clicking to install, cloudflared.exe will be added to your system PATH. Open a new PowerShell/CMD and you're ready to go. Official download page: Cloudflare Tunnel Downloads.
Starting a tunnel (identical to macOS)
Look for that same `https://xxx.trycloudflare.com` line in the output, copy it, and you're done. Stopping is Ctrl+C as well.
You might be wondering: Can I make it auto-start on boot and run in the background on Windows?
Yes. After the MSI install, run `cloudflared service install` as administrator — it registers as a system service and stays resident. Run `cloudflared service uninstall` to remove it. However, since quick tunnel domains change on each restart, auto-start is better suited for named tunnels.
VI. Live Test: The Public Address Really Works
Talk is cheap — let me show you real output. I ran these exact commands while writing this article.
After installing cloudflared 2026.7.2, I started a tunnel pointing to a local Vue project on port 5173 and got the address https://walking-limits-spectacular-scale.trycloudflare.com, then tested both the public entry and local direct access:
Result: The public entry returned HTTP 200, downloaded 537 bytes, in about 1.5 seconds. Local direct access also returned 200 with 537 bytes. The content was identical, confirming the full chain "public internet → Cloudflare edge node → my Mac → localhost:5173" is working correctly — you're seeing a real page.
With Oray's 1Mbps, the same 537-byte response loads instantly — but when the first screen hits 5–10MB of resources, the difference becomes obvious. That's the fundamental reason I switched away from Oray.
VII. Quick Tunnel Limitations and Important Notes (Must Read)
Free and useful doesn't mean boundaryless. These official limitations are clearly stated — keep them in mind:
1. No SLA, no uptime guarantee. Official wording: "We don't guarantee any SLA or uptime of TryCloudflare." It may disconnect occasionally; just rerun the command and get a new address. Do not use it for production workloads.
2. Hard concurrency limit of 200 simultaneous requests. Cloudflare returns 429 when the in-flight request count exceeds 200. Fine for personal previews, but don't use it for stress testing or high-traffic scenarios.
3. SSE (Server-Sent Events) not supported. If you're tunneling a streaming API (e.g., AI streaming output via SSE), quick tunnels won't work — you need a named tunnel.
4. Random domain every time. The subdomain before .trycloudflare.com changes on each startup, so you can't share it as a permanent address.
5. Only active while the terminal is open. Close the terminal, press Ctrl+C, or put the computer to sleep, and the link goes down. For persistent access, use a background service or a named tunnel.
6. HTTPS to the public, HTTP to your local endpoint. You're tunneling http://localhost:port — no certificate needed. Cloudflare terminates HTTPS at the edge, which is hassle-free.
7. No registration, no credit card required. Quick tunnels don't even need an account — that's the best part. Named tunnels require a free Cloudflare account (the website says "no credit card required," but the Zero Trust console may occasionally ask for a payment method as an anti-abuse measure; the free tier won't charge you).
One-sentence summary: Quick Tunnel = the perfect tool for dev previews, temporary sharing, and callback testing. It is not a production tool.
VIII. Want a Fixed Domain? Go Advanced with Named Tunnels
If you eventually need to run a fixed address long-term (e.g., a stable preview environment for your team, or a webhook callback endpoint), it's time to upgrade from a quick tunnel to a named tunnel.
Named tunnels require: a free Cloudflare account → a domain managed in Cloudflare → authorize with `cloudflared login` → create the tunnel with `cloudflared tunnel create` → write a config.yml specifying the domain-to-local-port mapping → install as a system service with `cloudflared service install` (launchd / Windows service) for auto-start.
Once configured, it's "auto-starts on boot, fixed domain, permanently online" — no more typing commands. Follow the official docs for complete steps: Connect through Cloudflare Tunnel. My advice: master the quick tunnel first, and only move to named tunnels when you're sure you need them long-term. Don't dive into config files right away.
IX. Troubleshooting: Three Pitfalls I've Already Stepped In For You
These are real pitfalls I've encountered — here to save you time.
Pitfall 1: Page opens with "Blocked request. This host is not allowed"
The tunnel works, but the browser gets blocked by your dev server asking you to add the domain to allowedHosts. Newer versions of Vite and other modern dev servers validate the request Host header to prevent DNS rebinding attacks. The host forwarded through the tunnel is xxx.trycloudflare.com, not localhost, so it gets blocked.
Fix: Relax the Host validation in your vite.config under the server section.
Pitfall 2: Works locally, but neither http://internal-IP:port nor the tunnel connects
Most likely, the service is only bound to 127.0.0.1 or the IPv6 loopback ::1, not listening on all interfaces. You'll see TCP [::1]:5173 (LISTEN) in lsof instead of *:5173. The fix is the same: set host: true so it listens on 0.0.0.0. Remember to restart the dev server after changing this — such configs don't hot-reload.
Pitfall 3: Page loads, but /api endpoints return errors
You're tunneling the frontend port (e.g., 5173). Requests to API endpoints in the page are proxied through the dev server to your local backend (e.g., 127.0.0.1:8000). If the backend isn't running, the page loads fine but APIs return 404/502. This isn't the tunnel's fault — just start your backend locally.
Someone might ask: Do I need to tunnel the backend port separately too?
No. As long as your frontend dev server proxies /api to the backend, tunneling just the frontend port is enough. API requests are forwarded server-side by the frontend to your local backend. Only one tunnel is needed externally. Adding another tunnel would only mean another domain and more maintenance overhead.
X. Compliance and Disclaimer
Compliance reminder: Intranet penetration is suitable for short-term scenarios like dev previews, temporary sharing, and callback testing. If you plan to officially and permanently provide websites or information services to the public in mainland China, you must still comply with ICP filing and other regulatory requirements. This article does not encourage using these tools to circumvent regulation.
Disclaimer: This is a complete hands-on guide for Cloudflare Tunnel intranet penetration, written independently based on my personal macOS testing. Package details, bandwidth, and pricing for tools like Oray, ngrok, and natapp are subject to change over time. The data in this article reflects publicly available information at the time of writing. Please refer to each vendor's official website for current details. Opinions and expressions are solely those of the author.
Extended Reading: If you're interested in seeing how intranet penetration is used in real business scenarios, check out my previous article *SpringBoot in Practice: WeChat Public Account Verification Code Login Feature (Complete Guide + Source Code)*—it demonstrates using Natapp for intranet penetration to handle WeChat callbacks.
If this Cloudflare Tunnel intranet penetration tutorial was helpful, feel free to like and bookmark. If you hit any snags or have questions, see you in the comments.
Previously Recommended
Elegant Operation Log Recording
JaCoCo Code Coverage
Loop Engineering
GPT-5.6 Arrives with Three Models

