Skip to content
GEEKnodes

Raspberry Pi

Tailscale on Raspberry Pi: Remote Access Without Open Ports

Install Tailscale on your Raspberry Pi and get home from anywhere without opening ports, even behind CG-NAT: subnet router, exit node, SSH and Pi-hole.

Tailscale creates a private network among your devices: your phone, laptop and home Raspberry Pi see each other as if on the same network, wherever you are. No ports to open on the router and no public IP needed, so it works even behind CG-NAT. In this guide we install it on the Pi and use it to reach the whole home network.

In short

  • Tailscale is a mesh VPN based on WireGuard: modern encryption, almost zero configuration.
  • You open no ports on the router and it works even if your provider uses CG-NAT.
  • It installs with one command and turns on with sudo tailscale up.
  • With a subnet router, the Pi gives you access to the whole home network: printer, NAS, cameras.
  • The Personal plan is free for home use; the coordination server belongs to the company.

How does it work?

In a classic VPN, your phone connects to an open port on your home router. Tailscale does it the other way round: each device reaches out to a coordination server, which only serves to exchange keys and know where each one is.

Then devices connect directly to each other through an encrypted WireGuard tunnel. If the network does not allow a direct connection, traffic goes through relay servers (DERP), still end-to-end encrypted: the relay cannot read it.

Each device gets a private IP in the 100.x.y.z range that does not change, and a name thanks to MagicDNS, for example raspberrypi.

The home server and the phone away from home register with a coordination service and then connect through a direct encrypted tunnel, with no ports open on the router
Coordination only hands out keys; data goes through a direct encrypted tunnel.

Tailscale or WireGuard with PiVPN

We already explained how to set up your own WireGuard VPN with PiVPN. Both use the same encryption but are set up very differently:

TailscaleWireGuard with PiVPN
Open a router portNoYes (UDP 51820)
Works behind CG-NATYesNo, without public IP
Dynamic DNSNot neededNeeded if your IP changes
External accountYes, to sign inNo
Full controlCoordination server is the company’sEverything on your Raspberry Pi
Add a deviceInstall app and sign inGenerate config and QR

If your provider uses CG-NAT or you do not want to touch the router, Tailscale is the simplest. If you prefer not to depend on any external service, plain WireGuard. To understand why opening ports has risks, read NAT and opening ports on your router.

Comparison between a classic VPN, with open port, public IP and manual setup, and a mesh network with no open ports and sign-in
Classic VPN versus mesh network: same encryption, very different setup.

Step 1: create the account

Go to the Tailscale website and sign up with a Google, Microsoft, GitHub or Apple account, among others. Tailscale keeps no passwords of its own: it uses those providers’ sign-in.

The Personal plan is free, with user and device limits more than enough for a home. Check current limits on their pricing page.

Step 2: install Tailscale on the Raspberry Pi

Connect to the Pi over SSH (if you do not know how, enable SSH without monitor or keyboard) and run the official script, which adds their repository and installs the package:

curl -fsSL https://tailscale.com/install.sh | sh

Then connect the Pi to your network:

sudo tailscale up

The command shows a link. Open it in your computer’s browser, sign in and authorize the device. Check the assigned IP:

tailscale ip -4
tailscale status

Step 3: install the app on phone and laptop

Install Tailscale on your other devices (there are apps for Android, iOS, Windows, macOS and Linux) and sign in with the same account. From then on, the phone can reach the Pi even on mobile data:

ssh pi@raspberrypi

Or open its web services by name, for example http://raspberrypi:8080 if you run Nextcloud on the Raspberry Pi.

Step 4: disable key expiry

For security, devices must sign in again periodically. On a phone it is no bother, but on a home server it is: if the key expires while you are away, you lose access.

In the web admin console, in the machine list, open the Raspberry Pi’s menu and choose Disable key expiry. Only do it for devices you control.

Step 5: access the whole home network (subnet router)

So far you reach the Pi, but not the printer or NAS, which have no Tailscale. The solution is to make the Pi a subnet router: it advertises the home network and forwards traffic.

  1. Enable packet forwarding in the system:
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
  1. Advertise your local network (change the range to yours; if unsure, use the subnet calculator):
sudo tailscale set --advertise-routes=192.168.1.0/24
  1. In the admin console, open the machine, go to Edit route settings and approve the route.

Phones use it automatically. On Linux clients you must accept it with sudo tailscale set --accept-routes.

The phone away from home reaches through the private network the board acting as subnet router, and from it the printer, camera and NAS on 192.168.1.0/24
With the subnet router, the Pi gives access to home devices without Tailscale.

Handy extras

FeatureCommand on the PiPurpose
Exit nodesudo tailscale set --advertise-exit-nodeBrowse from public Wi-Fi exiting through your home connection
Tailscale SSHsudo tailscale set --sshSSH in authenticated with your account, without managing keys
Statustailscale statusSee which devices are connected
Diagnosticstailscale netcheckKnow whether the connection is direct or relayed

The exit node must also be approved in the console, then selected in the phone app when needed.

Block ads away from home with Pi-hole

If you run Pi-hole on the Raspberry Pi, you can use it on your phone anywhere:

  1. In the Tailscale console, DNS section, add the Pi’s 100.x.y.z IP as nameserver and enable Override DNS servers.
  2. In Pi-hole, allow queries from other networks in the DNS interface settings, because requests arrive through the Tailscale interface.
  3. On the Pi itself, run sudo tailscale set --accept-dns=false so it does not query itself in a loop.

Frequently asked questions

Can Tailscale see my data? No. Traffic is end-to-end encrypted with WireGuard and private keys never leave your devices. What the company does know is which devices you have and when they connect.

Is there an alternative without the company? Yes: Headscale, an open source coordination server compatible with Tailscale clients. It needs a server reachable from the internet, so it is more complex. If you want full independence, WireGuard with PiVPN is more direct.

Does it work with Docker? Yes. You can install it on the system, as here, and reach all containers by their ports. There is also an official image to use it inside Docker, useful in advanced setups.

Does it tax the Raspberry Pi? No. With no traffic it barely uses CPU, and WireGuard is very efficient even on old models.

Accessibility preferences

Quick profiles

Text and reading

Text size
Default
Line height
Default
Letter spacing
Default
Word spacing
Default

Colour

Motion and orientation

Cursor