rainpwn

Research note

A Cloudflare Tunnel inside my Zyxel firewall

I added Cloudflare Tunnel to the custom firmware on my USG FLEX 100H, with its own page in the VPN menu, and opened a feature request on the Zyxel Community to ask whether uOS should have it natively.

Simplicity is prerequisite for reliability.
Edsger W. Dijkstra

For a long time now I have been building a custom firmware for my own Zyxel USG FLEX 100H. It is a research build and I don't distribute it. This post is about one feature I added to it: Cloudflare Tunnel.

The feature I missed

Publishing a service from behind a firewall usually means a port forward on the WAN. With Cloudflare Tunnel a small connector opens outbound connections to the Cloudflare edge, and requests for a public hostname come back through them. Nothing listens on the WAN, it works behind CGNAT and with a dynamic IP, and Cloudflare Access can require a login before a request reaches the LAN.

uOS already talks to Cloudflare for DDNS and ships Tailscale, but it has no Tunnel.

What it looks like

The new entry sits in the VPN menu, next to IPsec, SSL VPN and Tailscale:

The USG FLEX 100H web interface with the VPN menu open, listing IPSec VPN, SSL VPN, Tailscale and the new Cloudflare Tunnel entry

The page holds an enable switch, the tunnel token and the connector status. You create a tunnel in the Cloudflare dashboard, paste its token here and press Apply.

The VPN, Cloudflare Tunnel page: Enable switched on, the tunnel token stored and masked, and Connector Status showing Connected

A few seconds later Cloudflare reports the tunnel Healthy. The replica is the firewall itself, a linux_arm64 host with four connections to the edge in Rome and Milan.

The Cloudflare Tunnels list with the tunnel flex100h-test in state Healthy, one replica, connector version 2026.10.0

The tunnel overview in Cloudflare: one active replica whose host name is the firewall, architecture linux_arm64, edge locations fco01, mxp02 and mxp05

The CLI needed no extra code, because it is generated from the same data model:

The firewall CLI: show state vrf main cftunneld reports enabled true and connected true, and show config vrf main cftunnel shows the feature enabled

How it fits

The feature uses only what uOS already has:

  1. a YANG model with two settings, enabled and token, plus a state container with enabled and connected;
  2. a configuration service that decrypts the token, writes it to a root-only file and restarts the connector;
  3. the official cloudflared connector as a sandboxed service running as nobody, about 22 MB of RAM;
  4. a GUI page built like the other VPN pages.

The token is stored encrypted the same way as the Cloudflare DDNS API token, so the configuration never holds it in clear text.

Testing it from the outside

In the Cloudflare dashboard I published a test hostname pointing at the connector's own readiness endpoint, limited to the path /ready. The route reached the firewall within seconds, with no change on the box:

The Cloudflare dialog to add a published application: subdomain flex100h-test, path ^/ready$ and service URL http://localhost:20241

From the Internet:

bash
rainpwn@0xdeadspace:~$ curl https://flex100h-test.<redacted>/ready
HTTP 200  {"status":200,"readyConnections":4,...}
rainpwn@0xdeadspace:~$ curl https://flex100h-test.<redacted>/metrics
HTTP 404

Should uOS have it?

This shouldn't need a custom firmware, since uOS already has every piece it relies on. If you run a FLEX H, would you use it, and for what? The feature request is open on the Zyxel Community: Feature request: native Cloudflare Tunnel (cloudflared) on USG FLEX H.