Moving from a VPN to Tailscale
Intro
When I need to reach a server, whether that's SSH to read logs, DBeaver to query PostgreSQL, or an internal dashboard, the usual approach (and mine, for a long time) is a VPN. Everyone connects to the VPN first, then reaches the servers inside the private network.
The problem I hit most often was that once the VPN was up, all my internet traffic went through it too. Opening a website, watching YouTube or running docker pull all detoured out through the gateway first. Some days the slowdown was obvious, so I kept disconnecting the VPN when I was done with the server and reconnecting the next time I needed it. Then there's the cost: a machine to run the VPN server, a cloud VPN Gateway, or a monthly VPN provider subscription, all paid around the clock even if I only connect a few times a day.
These days I use Tailscale instead. My Windows dev machines and my Linux servers all sit on the same network. There's no VPN server to look after, no port to open for the VPN, and no database port open to the internet.
Tailscale is still a VPN, but it's a mesh VPN (overlay network) encrypted with WireGuard. What it takes away is the tedious part of a traditional VPN: the VPN server, the routing, the public IP and the NAT traversal.
How life got better after switching
- No more connecting and disconnecting. Tailscale stays on all the time. When I need a server I just
sshor open DBeaver. - The internet doesn't slow down. Tailscale only sends traffic for machines in the tailnet (the
100.x.x.xrange) through the tunnel. Everything else goes straight out from my machine as usual (split tunneling). If I really want all traffic to leave through one machine, I turn on an exit node for that occasion. - Servers feel closer. Traffic goes straight to the server instead of detouring through a gateway.
- Lower cost. No machine to run a VPN server, no cloud VPN Gateway, no VPN provider. For personal use or a small team, the Tailscale Personal plan is free.
- Better security. Data is encrypted end to end, machine to machine, and I can decide who reaches which machine on which port (details in the Security section below).
If you only read this section, here are the four takeaways:
- No VPN Gateway. Machines connect to each other directly whenever the network allows it.
- Only tailnet traffic goes through the tunnel. Your normal internet doesn't slow down.
- Split the network into two layers. Customer-facing services stay public; SSH, databases and internal dashboards live on the tailnet.
- Close ports to the internet, not on every interface. The database still has to listen on an interface Tailscale can reach.
Traditional VPN vs Tailscale
Traditional VPN: everything goes through one door
A traditional VPN is hub-and-spoke. A VPN Gateway is the single way into the private network: everyone connects to that door first, and is then routed on to the server they want.
What comes with that:
- You need one machine with a public IP and an open port for the VPN (UDP 1194 or 51820, for example).
- You manage everyone's certificates or keys yourself, and revoke them yourself when someone leaves.
- All traffic detours through the gateway, even when the destination is closer than the gateway. With a full tunnel (a common setting), all internet traffic detours too, so the gateway's bandwidth becomes everyone's bottleneck.
- It costs money all the time: the machine, a cloud VPN Gateway, or licences and a VPN provider.
- The gateway is a single point of failure. If it goes down, nobody reaches the servers.
- Once connected, you can usually see the whole subnet. Limiting who reaches which machine on which port needs a separate layer of firewall rules.
Tailscale: machines connect to each other
Tailscale separates the control plane from the data plane.
- The control plane (Tailscale's coordination server) only hands out public keys and handles login and policy. It never carries your traffic.
- The data plane is a real mesh. Machines talk to each other directly over WireGuard. Only when a direct connection isn't possible (an awkward NAT, for example) does traffic go through a relay (DERP), and it is still end-to-end encrypted.
Side by side:
| Topic | Traditional VPN | Tailscale |
|---|---|---|
| VPN server | Set up and maintain it yourself | None |
| Public IP / port for the VPN | Required, with an open port | Not needed (NAT traversal from outbound connections) |
| Traffic path | Detours through the gateway | Direct, machine to machine (relay only as a fallback) |
| Internet traffic | Often detours through the gateway (full tunnel) and slows down | Goes straight out from your machine, unless you choose an exit node |
| Encryption | Encrypted to the gateway, decrypted there | End to end, machine to machine |
| Cost | Machine / VPN Gateway / provider | Personal plan is free |
| Login / revoking access | Manage certs and keys yourself | Your existing identity provider (Google, Microsoft, GitHub, etc.) |
| Access control | Connecting usually exposes the whole subnet | Per user, device and port through policy |
| Machine names | Remember IPs or run your own DNS | MagicDNS names machines automatically |
Do you have to change your existing network?
Mostly not at all, because Tailscale is an overlay on top of the network you already have.
| Configuration | Needed? |
|---|---|
| Static public IP | No |
| Port forwarding on the router | Usually no |
| A VPN Gateway | No |
| Changing the LAN subnet / default gateway | No |
| Opening the database port to the internet | No |
| Installing the Tailscale client on every machine that talks | Yes |
| Writing an access policy | Strongly recommended |
A quick setup
Say the server runs Ubuntu and the dev machine runs Windows.
- Install Tailscale on both and sign in with the same account (on Linux:
curl -fsSL https://tailscale.com/install.sh | sh, thensudo tailscale up). - Both machines join the same tailnet, get an IP in
100.64.0.0/10, and get their own DNS name through MagicDNS. - Run
tailscale statusto see every machine in the tailnet, and whether each pair is connecteddirector through arelay.
If the database server gets IP 100.80.10.20 and the name db-server, a normal .NET connection string just works:
// PostgreSQL
Host=db-server;Port=5432;Database=mydb;Username=app;
// SQL Server
Server=db-server,1433;Database=mydb;
DBeaver, SSMS, pgAdmin or a .NET app connect as if the server were on the LAN. No networking code changes.
The thing to check is that the database listens on an interface Tailscale can reach. If PostgreSQL only listens on 127.0.0.1, other machines in the tailnet can't connect. Add the Tailscale IP to listen_addresses (and pg_hba.conf), or use an SSH tunnel over the tailnet.
Beyond the database, I use tailscale serve to expose internal dashboards (log/observability pages, for example) to tailnet machines only. The app itself still listens on 127.0.0.1; Tailscale accepts requests from the tailnet and forwards them. No extra reverse proxy or basic auth needed.
Splitting ports: what's public and what's tailnet-only
With a tailnet in place, port decisions get much simpler. Here's an example VPS running web, database and monitoring:
| Service | Port | Public Internet | Tailnet |
|---|---|---|---|
| HTTP | 80 | Allow | Allow |
| HTTPS | 443 | Allow | Allow |
| SSH | 22 | Deny | Allow |
| PostgreSQL | 5432 | Deny | Allow |
| SQL Server | 1433 | Deny | Allow |
| Redis | 6379 | Deny | Allow |
| Grafana | 3000 | Deny | Allow |
The rule: the public side only reaches what customers need; everything back-office goes through the tailnet.
One thing to know: Tailscale adds its own iptables rules that accept tailnet traffic before UFW sees it. So don't rely on UFW alone for the tailnet side. Use the tailnet policy to control who reaches what, and have each service bind only to the interfaces it needs.
Is it more secure than a traditional VPN?
There are two parts: data in transit, and access control.
Data in transit: end-to-end encryption (E2EE)
Between your machine and the server sit several middlemen: the router at home or the café Wi-Fi, your ISP, and the data center network. If data isn't encrypted, anyone in the middle can read it.
A traditional VPN encrypts too, but only as far as the gateway. At the gateway the data is decrypted and travels on inside the private network to the server. If the gateway is compromised, or someone is already inside that private network, they can see the data.
Tailscale encrypts with WireGuard directly from the source machine to the destination machine.
- Each machine generates its own private key, and the private key never leaves the machine. The control plane only knows public keys.
- Routers, ISPs and networks along the way only see encrypted packets, not their contents.
- Even when traffic goes through a DERP relay, the relay only forwards encrypted packets and cannot decrypt them.
So even on public Wi-Fi, SSH or database connections over the tailnet can't be read in transit. (You should still keep database TLS on; see the limitations section.)
Access control: ACLs / grants
The other advantage is that you can control access down to identity, device and port in the tailnet policy file (using grants, or the older acls). An example for a dev team:
| Identity | Destination | Port | Access |
|---|---|---|---|
| Developer | Dev Database | 5432 | Allow |
| Developer | Production Database | 5432 | Deny |
| DBA | Production Database | 5432 | Allow |
| Backend API | Production Database | 5432 | Allow |
| Frontend Server | Production Database | 5432 | Deny |
This is Zero Trust Network Access (ZTNA): being on the network doesn't mean you can reach every machine.
A grant that lets the developer group reach only the dev database:
{
"tagOwners": {
"tag:dev-db": ["group:admin"]
},
"grants": [
{
"src": ["group:developer"],
"dst": ["tag:dev-db"],
"ip": ["tcp:5432"]
}
]
}
Two things to know:
- A new tailnet's default policy is allow all. Every machine can see every other one. That's fine when you're the only user, but once other people or production machines join, remove the allow-all rule and grant only what's needed (least privilege).
- Grants only add permissions. There's no deny rule to override them. If an allow-all rule is still there, adding narrow rules changes nothing. The "Deny" rows in the table above mean "no rule grants access", not an explicit deny rule.
Limitations to know
- You still depend on Tailscale's control plane for login, adding machines and distributing policy. (If you'd rather not, Headscale lets you self-host the control plane.)
- Over a DERP relay, latency is higher than a direct connection. Check with
tailscale statusortailscale ping. - It doesn't replace database authentication or TLS. You still need users, passwords and database permissions as usual.
- It doesn't replace your whole firewall. Public ports still need the host or cloud firewall.
- Managed databases that can't run Tailscale (database-as-a-service, for example) need a subnet router as the way in.
Summary
- Tailscale is a mesh VPN on WireGuard: no VPN Gateway, no public IP for the VPN, and no changes to your existing network.
- Leave it on all the time. Only tailnet traffic goes through the tunnel, so your normal internet doesn't slow down, and there's no VPN server or provider to pay for.
- Data is encrypted end to end, machine to machine; routers, ISPs and relays along the way can't read it.
- Split the network into two layers: Public for the frontend, public API, reverse proxy and HTTPS; Tailnet for databases, Redis, SSH/RDP, Grafana and the observability stack.
- Move the policy from allow all to least privilege, and remember that grants only add permissions; there's no deny.
- Close database ports to the internet, not on every interface, so they stay reachable over the tailnet.
Ref
Found this useful? You can support the blog with a coffee.
Buy me a coffee