- Published on
Tailscale and Cloudflare Tunnel: my home PC with zero open ports

- Authors

- Name
- Nadim Tuhin
- @nadimtuhin
On this page
My home PC runs AI agents with access to my repos, and my router has zero open ports. I can still reach it from a cafe or a hotel, and reach its browser tools from a borrowed laptop.
This is how. It's one piece of my AI coding agent setup, covering how I get from my MacBook Pro, or any browser, to the Windows PC at home where my agents run.
The problem
The PC sits behind a home router. My internet provider can change the public IP whenever it likes, and I don't want any port on that router open to the internet. A box that runs AI agents with access to my repos is the last thing I want a port scanner to find.
But I still need two very different kinds of access:
- From my own devices, full access: ssh, Herdr terminals, and 9Router.
- From any browser, a few web tools: a browser editor and a view of a running browser, behind a login.
One tool doesn't fit both well. So I use two.

Tailscale: the private path for my devices
Tailscale builds a private network between my own devices on top of WireGuard. The PC and the MacBook each get a stable private address, holding direct peer-to-peer latency around ~12ms, and they find each other through any NAT, from home, from a cafe, from a hotel.
Only devices signed into my account are on that network. There's nothing public to attack.

This is the path for everything interactive:
Host homelab
HostName <the PC's Tailscale address>
User nadim
IdentitiesOnly yes
LocalForward 20131 localhost:20128
ControlMaster auto
ControlPersist 1h
A few lines doing a lot of work:
ssh homelabworks the same from anywhere, because the Tailscale address never changes.herdr --remote homelabrides the same ssh connection to the Herdr server, so my terminals on the PC open on the MacBook.LocalForwardbrings the PC's 9Router to a port on my MacBook, so tools on the laptop can use the same gateway as the agents, without exposing it anywhere.ControlMasterreuses one connection for every ssh, scp and Herdr session, so new panes open instantly.

Key-only auth, no passwords, no root login.
Cloudflare Tunnel: the public path for browser tools
Some things I want from a phone or a borrowed laptop, where installing Tailscale isn't an option. For those, Cloudflare Tunnel runs on the PC as cloudflared.
It makes an outbound connection to Cloudflare. Cloudflare then serves a few subdomains through that connection. Nothing comes in through my router. The router doesn't even know.
In front of each subdomain sits Cloudflare Access. Before any request reaches the PC, Cloudflare asks me to sign in. If it isn't me, the request never leaves Cloudflare.
What goes through this path:
- code-server, VS Code in a browser, with the same repos the agents use.
- noVNC, a view of a real browser running on the PC, for the times an agent is driving one and I want to watch.
What doesn't: ssh, Herdr and 9Router. Those stay on the private path.
Why both, not one
I could run everything through Cloudflare, or everything through Tailscale. Each one is good at one of these jobs and awkward at the other.
| Tailscale | Cloudflare Tunnel + Access | |
|---|---|---|
| Who can reach it | Only my signed-in devices | Anyone who passes the login |
| Needs a client | Yes | No, just a browser |
| Best for | ssh, terminals, private APIs | Web apps from any device |
| Exposed to the internet | Nothing | A login page on Cloudflare |

The rule I settled on: if it's interactive and powerful, it goes over Tailscale. If it's a web page I might open from a phone, it goes through Cloudflare with Access in front.
Things that bit me
- WSL2 networking. Ubuntu inside WSL2 lives behind its own virtual NAT. Tailscale and
cloudflaredrunning inside Ubuntu sidestep most of that. Anything on the Windows side that needs to reach a WSL2 service needs a port forward. - WSL2 shutting down. Windows stops the Ubuntu VM when nothing is attached, and every tunnel inside it goes with it. A keepalive on the Windows side keeps it up.
- Tailscale stopped on the laptop. When ssh to the PC times out, the first thing to check isn't the PC. It's whether Tailscale is running on the MacBook.
tailscale statusanswers that in a second.

- Don't restart the tunnel you're connected through. Restarting
sshdorcloudflaredover the connection that depends on it is a good way to lock yourself out until you get home.
What I'd tell someone copying this
- Open zero ports at home. Both tools work without any.
- Split private access from browser access. They have different threat models, so they get different paths.
- Put a login in front of anything public. A tunnel without Access is just a public URL to your house.
- Give the remote box a name in your ssh config. Every other tool, Herdr included, gets simpler once
homelabjust works.
Frequently asked questions
- How do I access my home PC without opening router ports?
- Use Tailscale for your own devices and Cloudflare Tunnel for browser tools. Tailscale gives a stable private address for ssh, and cloudflared makes an outbound connection to Cloudflare, so nothing comes in through the router.
- Should I use Tailscale or Cloudflare Tunnel?
- Use both for different jobs. Tailscale suits interactive, powerful access like ssh and terminals from devices you control. Cloudflare Tunnel with Access suits web apps you open from any browser, with a login in front.
- Is a Cloudflare Tunnel safe without Access?
- No. A tunnel without Cloudflare Access is just a public URL to your house. Put a login in front of every public subdomain so unauthenticated requests never leave Cloudflare.
- Why does ssh to my home PC time out over Tailscale?
- Check whether Tailscale is running on the laptop first, using tailscale status. Then check WSL2, which Windows shuts down when nothing is attached, and then sshd.
Related posts
- My AI coding agent setup: a MacBook controls, a home Windows PC runs
Control coding agents from a MacBook Pro while they run on a Windows PC at home: Herdr over Tailscale, Cloudflare Tunnel for browsers, 9Router for every model.
- 9Router: one local endpoint in front of every AI coding account I have
9Router puts 6 Antigravity, 2 Codex Pro, Claude Max and other accounts behind one localhost endpoint. Fallback, round robin and fusion combos hide rate limits.
- Pathao Tickets: replacing Zendesk with a patched open source helpdesk
Pathao support ran on Zendesk. We patched an open source helpdesk for ticketing, live chat and automations at roughly a third of the Zendesk bill.