What is Tailscale? How its mesh VPN works
Tailscale is a VPN built on WireGuard that links your devices straight to each other. Here is how it works, what its servers see, and when traffic is relayed.
This guide explains what Tailscale is and how it works. It is not a setup guide. To use Tailscale like a VPN app, with all your internet traffic going out through another machine, see Use your VPS as a Tailscale exit node.
Put Tailscale to work: What Can You Do With Tailscale? 8 Real Uses
What is Tailscale?
Tailscale is a VPN that connects your machines straight to each other instead of routing all traffic through one gateway you run. Every node runs WireGuard, so packets travel encrypted from one server to another and nothing in the path can read them. A hosted coordination server handles the introductions. It stores and distributes public keys and tells each node where the others are. It also pushes down the access rules you wrote.
That split is the entire design. The data plane is peer to peer and encrypted between nodes. The control plane is a service Tailscale runs for you. Every interesting question about Tailscale, including the uncomfortable ones about trust, follows from those two facts. If you have already built a WireGuard VPN by hand on a VPS, Tailscale is that same tunnel with key distribution and firewall traversal done for you.
Is Tailscale a VPN or a mesh network?
Both words are accurate, and they describe different layers. The tunnels are WireGuard, which makes it a VPN. The topology is a mesh, because each node builds a tunnel directly to each node it talks to instead of sending every packet through one central server. The coordination server sits in the control path, not in the data path, so if it becomes unreachable your existing tunnels keep carrying traffic. What stops during an outage is new nodes joining and changes to keys or policy landing. It is not a privacy VPN by default, though: websites still see your own public address until you send traffic through an exit node, and what Tailscale hides from websites and your ISP goes through each setup.
How does Tailscale work?
Your private network of nodes is called a tailnet. Four things happen when a machine joins one.
- The
tailscaleddaemon starts, generates a WireGuard key pair, and keeps its state in/var/lib/tailscale/tailscaled.state. The private key stays on that machine. Tailscale's own wording is blunt: "the private key never, ever leaves its node." - The node logs in to the coordination server and uploads its public key, plus the addresses where it believes it can be reached. Tailscale describes that server as "a shared drop box for public keys."
- The coordination server sends back a network map: the public key, the tailnet address, the machine name and the candidate endpoints of every node this one is allowed to reach.
- Each pair of nodes then tries to build a direct WireGuard tunnel between themselves. When that fails, they push the packets through a relay instead.
Each node gets a stable address out of 100.64.0.0/10, the carrier-grade NAT range that runs from 100.64.0.0 to 100.127.255.255. Tailscale uses that range because it is reserved for provider infrastructure, so it rarely collides with the private addresses your servers already use. On Linux the tunnel appears as an interface named tailscale0.
The WireGuard implementation lives inside tailscaled in userspace, not in the kernel module. That is why Tailscale starts on container virtualisation where sudo modprobe wireguard fails with Operation not supported. It also means the throughput ceiling on a given box is lower than kernel WireGuard, which is one of the trade-offs Tailscale against plain WireGuard goes into.
Two commands tell you where you stand.
tailscale ip -4
tailscale statustailscale status prints one line per node, and the last column is the one that matters.
100.101.102.103 web-1 you@ linux -
100.101.102.104 db-1 you@ linux active; direct 198.51.100.24:41641
100.101.102.105 ci-runner you@ linux active; relay "fra"direct followed by an address and port means the two machines found a path to each other and traffic is peer to peer. relay "fra" means it is passing through a Tailscale relay in Frankfurt. A - means there is no active session with that node right now, which is normal.
What is Tailscale used for?
In practice, Tailscale gives you private access to your own machines wherever they run. The common jobs are these.
- SSH and admin access to a VPS with public port 22 closed, covered further down.
- Reaching a NAS or a Pi at home with no port forwarded on your router.
- Linking servers at different providers, or behind firewalls you cannot edit, as if they shared a private network, which connecting two VPSs over a private network sets up step by step.
- Opening a web app or dashboard to devices in your tailnet only, with
tailscale serve. - Reaching a whole private network that has no Tailscale installed on it, through a subnet router.
- Sending your internet traffic out through another machine, the way a VPN app does, with an exit node.
What you can do with Tailscale goes through each of these in practice.
What the coordination server can and cannot see
The coordination server holds public keys and metadata. It knows your machine names, which user or tag owns each node, each node's tailnet address, the public addresses your nodes are reachable at, when each was last online, and the policy file you wrote. That is a complete map of your fleet.
It holds no private key, so it cannot decrypt traffic between two nodes. Encryption is end to end between the WireGuard peers, and the coordination server is not a peer.
What it can do is hand out keys. Any coordination server, hosted or self-run, is trusted to tell your nodes which public keys belong in the tailnet. That is the hinge of the threat model further down, and the reason Headscale, an open-source coordination server you host yourself exists.
How two servers behind different firewalls talk directly
NAT (network address translation) is what lets many machines share one public address. Your VPS usually has a public address of its own, but the other machines you want in the tailnet often do not: a home server, a build runner on an office network, a box behind a provider firewall you cannot edit.
Tailscale finds a path using techniques built on the STUN (session traversal utilities for NAT) and ICE standards. Each node sends a small UDP packet to a STUN server and learns the public address and port its router assigned to that socket. Both nodes report those candidates to the coordination server, which passes them to the other side. Then both nodes start sending packets to each other at the same time. Each router sees an outbound packet first, so it creates a mapping and accepts the reply arriving from that same address. Neither side needed an inbound firewall rule. That is also why a NAS or a Pi at home can stay reachable with no port forwarded on your router, and using Tailscale instead of port forwarding walks through that setup, including what it cannot do.
The ports are specific. Direct WireGuard tunnels use UDP with a source port that defaults to 41641. STUN runs over UDP 3478 to Tailscale's relay servers. The control connection prefers plain HTTP on TCP 80, wrapped in Tailscale's own encrypted transport, and falls back to HTTPS on TCP 443 when port 80 does not answer. Data relayed through Tailscale's DERP servers uses HTTPS on TCP 443, while a peer relay you run inside your own tailnet carries it over UDP. Most of the time you open nothing inbound, though on a network with a difficult NAT, allowing UDP 41641 inbound makes a direct connection more likely. If you need to turn that list into actual rules on a locked-down VPS, which Tailscale ports to open on your firewall gives the ufw and firewalld commands and explains why the port is 41641 rather than the 51820 you may know from plain WireGuard setups.
tailscale netcheckRead two lines of that report. UDP: true means this machine can send UDP to the internet, and UDP: false means it cannot, so every connection from this node will be relayed. MappingVariesByDestIP: true means the router assigns a different public port per destination, so the address prediction above cannot work and those nodes usually stay relayed.
When Tailscale uses a DERP relay instead
DERP (designated encrypted relay for packets) is Tailscale's network of relay servers, reachable over TCP 443. Every connection starts out relayed through one, and Tailscale then tries to upgrade it to a direct tunnel. If the upgrade never succeeds, the traffic stays on the relay. It still works, but each packet takes a detour through a third machine, and that adds latency.
The packets stay encrypted. Tailscale states it plainly: "there is never a way for a DERP server to decrypt your traffic. It just blindly forwards already-encrypted traffic from one node to another." A relay sees ciphertext, and it sees which node is talking to which.
You can watch the upgrade happen.
tailscale ping db-1The first replies come back via DERP(fra), then a later line reports something like via 198.51.100.24:41641. That change is the move to a direct tunnel. If it never changes, run tailscale netcheck on both ends. If what you noticed is slow transfers rather than a broken connection, why a relayed Tailscale connection is so much slower than a direct one measures the gap and shows how to get a VPS onto a direct path.
In tailscale status, a connection through DERP shows as relay. A tailnet can also have peer relays, which are your own devices forwarding traffic over UDP. Tailscale tries those before it falls back to DERP, and a connection through one shows as peer-relay.
Joining a VPS to your tailnet
On Ubuntu and Debian, two commands do it.
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale upsudo tailscale up prints a URL. Open it, authenticate, and the node appears in your admin console. Then check that the daemon comes back after a reboot, because that is the step people skip.
sudo systemctl is-enabled tailscaled
tailscale statusis-enabled should print enabled, and tailscale status should list the new node with its 100.x address.
A server built from a script cannot click a URL. Generate an auth key in the admin console instead and pass it, with a tag that records what kind of machine this is.
sudo tailscale up --auth-key=tskey-auth-REPLACE-ME --advertise-tags=tag:serverThe tag must be declared under tagOwners in your policy file first, or the command is refused. A tagged node belongs to the tag rather than to the person who ran the command, so it keeps working after that person's account is gone, and key expiry is off for it by default. Tagged nodes also have an allowance of their own: Tailscale's pricing page lists 50 tagged resources included and $1/month for each one after that. What the free tier actually covers sets out the rest of the limits.
Key expiry is the setting that catches fleets out. Node keys expire after 180 days by default (as of November 2026), and when a key expires "connections to/from the given endpoint will stop working" until the device reauthenticates. For any untagged server that runs unattended, open its row in the admin console and choose Disable Key Expiry. If a key has already expired, an admin can choose Temporarily extend key, which gives you 30 minutes to log in again or disable expiry.
MagicDNS, enabled by default for tailnets created on or after 20 October 2022, gives each node a name such as db-1.yak-bebop.ts.net, resolved by a stub resolver at 100.100.100.100. Use names rather than addresses, because a rebuilt node gets a new address. Remove the old machine from the admin console before the rebuilt one joins: while a machine with the same name is still registered, the new one gets a name like db-1-1.
Reaching a service bound to localhost
Joining the tailnet does not make a loopback service reachable, and most people get stuck here. Check what the service is listening on.
ss -tlnp | grep 3000If that prints 127.0.0.1:3000, the socket accepts only packets whose destination is 127.0.0.1. A request from another node arrives with that node's 100.x address as its source and this server's 100.x address as its destination. Nothing is listening on that destination, so the kernel answers with a TCP reset and the client reports Connection refused. The tunnel is fine. The listener is the problem.
There are two fixes. The first is to bind the service to the server's tailnet address instead of loopback: pass --bind 100.101.102.104 or the equivalent option in your config. For a container, publish the port as -p 100.101.102.104:3000:3000. Docker's documentation adds one caveat: if IP forwarding is enabled on the host, a port published to one host address can still be reached through the host's other interfaces by routing to that address. The second fix is to leave the service on loopback and put Tailscale in front of it.
tailscale serve 3000That proxies requests to http://127.0.0.1:3000 and serves them inside your tailnet on a ts.net name over HTTPS, once HTTPS certificates are enabled for the tailnet. Other devices in your tailnet can reach it and the internet cannot. The public version of the same idea is Funnel, and Tailscale serve against funnel covers which one you want.
Two related jobs have their own pages. Reaching a whole private network that has no Tailscale installed on it needs a subnet router on a VPS, and sending a node's outbound internet traffic through another node needs an exit node.
Closing the ports you no longer need
Once every administrator reaches the box over the tailnet, public port 22 has no job left, and a closed port cannot be brute forced. Order matters. Add the tailnet access, prove you can log in through it from a second session, and only then remove the public rule.
sudo ufw allow in on tailscale0
sudo ufw status verboseThen delete the public SSH rule and reconnect using the MagicDNS name. Be aware that ufw allow in on tailscale0 trusts everything that arrives on the tunnel, so your Tailscale policy file becomes the access control instead of ufw. Write the policy with that in mind.
Containers need one more step. A published Docker port installs its own NAT rules and bypasses ufw, so a ufw deny does not close it. Docker published ports bypassing ufw explains the mechanism. Publishing to the tailnet address, as above, binds the port to that address rather than to every address on the host, with the routing caveat described there. If the app runs under Docker Compose, a Tailscale sidecar in the Compose stack removes the published port altogether, so the container is reachable only over the tailnet.
What Tailscale protects, and what it does not
Worth stating plainly, because the marketing version blurs the line.
Protected: traffic between two nodes is encrypted end to end with WireGuard, and no relay in the middle can read it. Private keys never leave the machine that generated them. Nodes need no inbound public port to reach each other. Installing Tailscale does not close anything already listening on a public interface, though: SSH on 22 or a database on 5432 stays open to internet scans until you delete its public firewall rule or rebind the service to the tailnet address, as described above. Access between nodes is decided by a policy file rather than by whoever knows an address.
Not protected: the coordination server sees your device graph. That metadata is sensitive on its own, because machine names, owners, addresses and online times describe your infrastructure. It also distributes keys, which is the sharper risk. Tailscale says it directly: "If Tailscale were malicious, and stealthily inserted new nodes into your network, then Tailscale could send or receive traffic to your existing nodes in plaintext." Your single sign-on provider sits in the same trust path, because whoever can mint an identity there can add a node. And a compromised node is a peer inside the tailnet, so what it reaches next is whatever your policy allows. Whether that adds up to an acceptable risk depends on who you are defending against, and the full trust model walks through each of those cases, including what a stolen identity account can actually do.
There are two answers to the key distribution risk. The first is tailnet lock, which requires existing trusted nodes to cryptographically sign a new node before your other nodes accept it. A control plane that adds a node without a valid signature is ignored. The admin console generates the exact tailscale lock init line for your signing nodes, and every node can confirm what it sees.
tailscale lock statusAll nodes should report the same set of trusted signing keys. The second answer is to run the control plane yourself. A self-hosted Headscale coordination server speaks the same protocol to the same clients, which moves the device graph and the key distribution onto hardware you own. You then own that server's uptime as well. If you are still comparing self-hosted control planes rather than settling on this one, NetBird is a separate mesh VPN whose server you run end to end on a single VPS.
One default to fix on the first day. A new tailnet ships permissive: "the default access control policy lets all devices communicate with all other devices." As soon as you add an acls section, the model flips to deny by default and only your rules pass.
{
"tagOwners": {
"tag:server": ["autogroup:admin"]
},
"acls": [
{"action": "accept", "src": ["autogroup:member"], "dst": ["tag:server:22"]}
]
}That policy lets tailnet members reach SSH on tagged servers and nothing else. Add a rule per service rather than leaving the wildcard in place, because the wildcard means one stolen laptop key reaches your database. If you are still choosing a mesh VPN, how you write rules like these is one of the places the options genuinely differ, and NetBird against Tailscale compares the two policy models alongside who runs the control plane.
When something does not work
tailscale statusalways saysrelay. The two nodes never built a direct path. Runtailscale netcheckon both ends and read the two lines described above. Why a relayed Tailscale connection is so much slower than a direct one shows how to get a VPS onto a direct path.- A node that worked for months disappeared. Check the admin console for an expired node key first, the 180 day default described above. If the key is not expired, check the policy file for a rule that blocks the connection.
- Peers are listed but connections time out. If
tailscale pinggets replies, the tunnel works and the policy is the likely cause. A denied packet is dropped rather than answered, which is why you see a timeout instead ofConnection refused. - MagicDNS names do not resolve. A node started with
--accept-dns=falsedoes not take your tailnet's DNS settings. Runsudo tailscale set --accept-dns=trueto hand DNS back to Tailscale. - The install fails on apt or on the repository. The common Tailscale install errors on Ubuntu covers the fixes.
FAQ
What is a tailnet?
A tailnet is your private Tailscale network, the set of nodes that have joined it. Each node gets a stable address out of 100.64.0.0/10 and, with MagicDNS, a name such as db-1.yak-bebop.ts.net. Your policy file decides which nodes can reach which. A new tailnet lets every device reach every other device until you add an acls section.
Can Tailscale read my traffic?
Not the contents. Traffic is encrypted end to end between nodes with WireGuard, private keys never leave the nodes, and a DERP relay forwards packets it has no way to decrypt. Tailscale does see metadata: machine names, owners, public keys, endpoint addresses and when each node is online. It also distributes keys, so a compromised coordination server could try to insert a node your fleet would then trust. Tailnet lock blocks that by requiring signatures from your own trusted nodes, and Headscale removes the hosted control plane from the picture.
Do I need to open firewall ports for Tailscale?
Almost never inbound. Tailscale's own guidance is that "most of the time, you don't need to open any firewall ports." For a locked down network, Tailscale lists four outbound rules: TCP to port 443, UDP to port 3478, UDP from source port 41641, and HTTP over TCP to port 80. TCP 443 reaches the coordination server and the DERP relays, and in Tailscale's words, "any device that can open an HTTPS connection to an arbitrary host can build a tunnel using DERP relays." UDP 3478 carries STUN, which helps a node discover its public address so a direct path can form. Direct tunnels use UDP with a source port that defaults to 41641 and can be reconfigured. TCP 80 is the one Tailscale calls not mandatory: the connection to the coordination server prefers it and falls back to HTTPS on 443 when it does not answer, and it is also used for captive portal detection. Blocking it can delay connections, and captive portal detection will not work properly. Allowing UDP 41641 inbound is optional, and it only helps direct connections succeed on awkward networks.
Should I run Headscale instead of Tailscale's coordination server?
Run Headscale when the device graph or the key distribution must stay on infrastructure you control, or when the tailnet has to work with no dependency on an outside service. The clients and the protocol are the same. The cost is that you now operate the coordination server, and when it goes down, new nodes cannot join and policy changes do not apply. For a small fleet, the hosted control plane with tailnet lock enabled is usually the better trade.