archive2023

Cloudflare WARP and Zero Trust: reaching the home LAN without opening ports

How to route a home subnet through a cloudflared tunnel and reach it from a laptop and a phone with the WARP client: enrollment rules, the proxy setting, split tunnels, and how it compares to a public hostname tunnel and to WireGuard.

7 min read#ops#cloudflare#networking

I have two ways into my home network now. Grafana is published with a Cloudflare Tunnel and a public hostname, as in the tunnel post from 2021. Everything else (SSH to the Pis, the MQTT broker, the router admin page) goes through WireGuard on the home server, with one UDP port forwarded on the router.

This month I tried a third way: the same cloudflared tunnel, but routing the whole home subnet to devices that run the Cloudflare WARP client. No port forward, and it works for any TCP service, not only HTTP. I kept WireGuard running for now, more on that at the end.

How the pieces fit

  • cloudflared on a machine at home keeps outbound connections to Cloudflare. Same as before.
  • The tunnel gets a private network route: a CIDR, for example 192.168.1.0/24. This tells Cloudflare that this IP range is reachable through this tunnel.
  • The laptop and the phone run WARP, logged in to your Zero Trust organization. WARP sends traffic to Cloudflare, Cloudflare Gateway proxies it, and packets for 192.168.1.0/24 go down the tunnel to the home LAN.

So from the laptop you just type ssh pi@192.168.1.20, like at home. No hostname, no Access login page in the browser.

Everything is configured in the Zero Trust dashboard (one.dash.cloudflare.com, it was called the Teams dashboard before). The free plan is for up to 50 users, which is far more than a home needs. The first time you open it you choose a team name. Remember it, the clients need it.

1. Add the route to the tunnel

I reused the named tunnel home from the Grafana setup. It is a locally managed tunnel (config file on disk), so the route is added with the CLI:

cloudflared tunnel route ip add 192.168.1.0/24 home
cloudflared tunnel route ip show

Then the tunnel must be allowed to carry WARP traffic. In the config file:

# /etc/cloudflared/config.yml
tunnel: home
credentials-file: /etc/cloudflared/<UUID>.json

warp-routing:
  enabled: true

ingress:
  - hostname: grafana.example.com
    service: http://localhost:3000
  - service: http_status:404

Restart cloudflared. The public hostname for Grafana keeps working. Both features live in one tunnel.

If you created the tunnel in the dashboard instead (remotely managed), the route is added on the tunnel’s Private Network tab, and there is no config file to edit.

Where cloudflared runs matters. It must be able to reach the LAN addresses you route. On my side it runs on the home server, which is on 192.168.1.0/24 anyway. (In 2021 it ran on the Pi 4; last year I moved cloudflared and Grafana to the home server, which has an SSD.)

2. Let Gateway proxy the traffic

By default WARP only sends DNS to Gateway. For private network traffic, Gateway has to proxy TCP. In the dashboard, under Settings > Network, turn on Proxy and select TCP. I also turned on UDP, because I want DNS queries to a resolver on the home LAN to work.

Without this step the client connects fine and nothing on the LAN answers. That was my first hour.

3. Device enrollment rules

Who can log in a WARP client to your organization is decided by the device enrollment permissions, under Settings > WARP Client. It is an Access policy. For one person, a rule with Emails = you@example.com is enough. For the login method, the One-time PIN (a code by email) works without setting up any identity provider.

Do not use “Everyone” here. That would let anyone who knows your team name enroll a device and reach your LAN.

4. Split tunnels

This is the part that confused me. WARP’s default device profile uses Split Tunnels in Exclude mode, and the default exclude list contains the RFC 1918 ranges: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. That makes sense for a normal user, because local printers and routers should stay local. But it means traffic to 192.168.1.x never enters WARP.

So in Settings > WARP Client > Device settings, open the profile, go to Split Tunnels, and delete 192.168.0.0/16. If you stop there, all other 192.168.x.x traffic also goes to Cloudflare, including the LAN of the hotel or office you are sitting in. Better to add back the parts of 192.168.0.0/16 that are not your home subnet:

192.168.0.0/24
192.168.2.0/23
192.168.4.0/22
192.168.8.0/21
192.168.16.0/20
192.168.32.0/19
192.168.64.0/18
192.168.128.0/17

Cloudflare’s docs have a small calculator for this. I did it by hand and checked it twice.

The other choice is Include mode: only the listed ranges go through WARP, and everything else uses the normal internet. For a home user who only wants the LAN, Include mode with 192.168.1.0/24 is simpler to read. But switching the mode clears the list, and some Zero Trust features expect internet traffic to go through Gateway. I stayed with Exclude mode.

One more problem: 192.168.1.0/24 is the default on many routers. If the network you are on also uses it, your local route and the WARP route collide, and you will reach the wrong device. The same issue exists with WireGuard. The real fix is to move the home LAN to a less common range, like 10.47.12.0/24. I have not done that yet because of the many static addresses on my sensors.

5. The clients

On the laptop, install the Cloudflare WARP app, then in Preferences > Account choose to log in with Cloudflare Zero Trust and enter the team name. A browser opens, you get the PIN by email, and the device is enrolled. On the phone, the 1.1.1.1 app does the same through its account settings.

Then test with TCP, not ping:

ssh pi@192.168.1.20
curl -I http://192.168.1.10:3000/login
nc -vz 192.168.1.30 1883

ICMP may not work through the tunnel, so a failed ping does not tell you much.

When you are at home on Wi-Fi, WARP still sends the LAN traffic out and back through Cloudflare. It works, but it is a detour. I just turn WARP off at home.

How this differs from the public hostname tunnel

With a public hostname, a service gets a DNS name and anyone on the internet can reach the login page. You protect it with an Access application, and you use a browser, or cloudflared access for SSH. That is the right tool for something you want to share, or reach from a device where you cannot install anything.

With the private network route, there is no public name at all. Only enrolled devices with WARP can reach the subnet, and every protocol works: SSH, MQTT, SMB, a Postgres client. The cost is that every device needs the WARP client and the enrollment.

I keep both. Grafana stays on a public hostname behind Access, because I sometimes open it from a work machine. The rest moves to the private route.

WARP vs WireGuard, honestly

WireGuard at home WARP + tunnel
Port forward on router yes, one UDP port no
Works behind CGNAT not without a public relay yes
Third party in the path no Cloudflare sees the traffic
Setup keys and config files dashboard settings, one CLI route
Adding a device new key pair and peer entry log in with email PIN
Depends on your home internet your home internet and Cloudflare
Other VPN on the phone at the same time no no

The biggest point for me is privacy. With WireGuard, the traffic is encrypted from my laptop to my server and nobody in between can read it. With WARP, Cloudflare terminates the WARP connection and proxies the TCP stream. If the protocol inside is SSH or TLS, Cloudflare still cannot read the content. If it is plain HTTP to Grafana or plain MQTT on 1883, it can. For my sensor data I accept that. For other things I would not.

WireGuard is also simpler to reason about. It is a few files I understand, and it does not change when a vendor redesigns a dashboard. Zero Trust has many settings, and some of them (Gateway, DNS filtering, device profiles) affect all traffic on the device, not only the home LAN. With the default settings, WARP sends your DNS through Gateway too. Check that this is what you want.

On the other side, WARP wins clearly if your ISP gives you no public IPv4, or if you do not want any open port at all. Adding a new device is easier too. And it is free for a home setup.

I keep both for now. Whatever I end up using day to day, WireGuard stays as the fallback for the day Cloudflare or my account has a problem.