Tailscale is a commercial, yet widely open-sourced VPN provider, based on the Wireguard protocol.
The service enables to connect devices to each other, without having to open anything up to the broader internet.
It can be used extensively for free, up to 3 users.
Basic commands
Advanced stuff
In your Tailscale network, DNS configurations can be made
Alternatives
- Headscale is an open-source Tailscale control server: https://headscale.net/stable/
- Netbird is also an alternative for self-hosting: https://github.com/netbirdio/netbird
- Newt Pangolin https://docs.pangolin.net/ can also be self-hosted
Coupling Tailscale with...
For Nginx, there are configurations available.
See more in
Docker with Tailscale
Tailscale can be combined with Docker to build applications that are only accessible via the tailscale network.
See: https://www.youtube.com/watch?v=YTjYXii4WzI
A Docker Compose setup
Requirements: Create a TS_AUTHKEY in: https://login.tailscale.com/admin/settings/keys
Furthermore, you might consider activating
version: "3.7"
services:
tailscale:
image: tailscale/tailscale:latest
hostname: webserver
container_name: tailscale-webserver
environment:
- TS_AUTHKEY=${TS_AUTHKEY}
- TS_STATE_DIR=/var/lib/tailscale
- TS_USERSPACE=false
volumes:
- tailscale-data:/var/lib/tailscale
devices:
- /dev/net/tun:/dev/net/tun
cap_add:
- net_admin
- sys_module
restart: unless-stopped
healthcheck:
test: ["CMD", "tailscale", "status"]
interval: 30s
timeout: 10s
retries: 3
webserver:
image: nginx:latest
container_name: nginx-webserver
depends_on:
tailscale:
condition: service_healthy
network_mode: service:tailscale
volumes:
- ./index.html:/usr/share/nginx/html/index.html:ro
restart: unless-stopped
volumes:
tailscale-data:
driver: local
How Tailscale works
Briefly
Tailscale
In more depth
sequenceDiagram
participant A as Device A<br/>(Client)
participant CS as Coordination Server<br/>(controlplane.tailscale.com)
participant DERP as DERP Relay Server
participant B as Device B<br/>(Server)
Note over A,B: 1. Initial Setup & Authentication
A->>CS: Login & registriere Public Key
B->>CS: Login & registriere Public Key
CS->>A: Liste der autorisierten Peers<br/>(Public Keys, IPs, ACLs)
CS->>B: Liste der autorisierten Peers<br/>(Public Keys, IPs, ACLs)
Note over A,B: 2. Verbindungsaufbau (immer via DERP)
A->>DERP: Initiale Verbindung zu Device B
DERP->>B: Leite Pakete weiter
B->>DERP: Antwort
DERP->>A: Leite Antwort weiter
Note over A,B: 3. NAT Traversal (parallel)
A->>A: STUN: Erkenne eigene<br/>öffentliche IP:Port
B->>B: STUN: Erkenne eigene<br/>öffentliche IP:Port
A->>B: UDP Hole Punching Versuch
B->>A: UDP Hole Punching Versuch
Note over A,B: 4a. Erfolgreicher Direct Path
A->>B: Direkte P2P Verbindung<br/>(WireGuard encrypted)
B->>A: Direkte Antwort
Note over A,B: DERP wird nicht mehr benötigt
Note over A,B: 4b. Fallback (wenn NAT Traversal fehlschlägt)
A->>DERP: Weiterhin Relay-Verbindung
DERP->>B: Traffic weiterleiten
Note over A,DERP: Periodische Versuche für<br/>direkten Pfad laufen weiter