Have you ever wanted to access your Raspberry Pi from anywhere in the world, without worrying about port forwarding, dynamic DNS, or firewall rules? If so, this blog post is for you. In this post, I will show you how to use Tailscale to remotely access your Raspberry Pi from your phone, tablet, or another computer.
Tailscale is a zero-config VPN that creates a secure network of your devices using WireGuard, a fast and modern encryption protocol. By using Tailscale, you can access your Raspberry Pi from anywhere, as if it were on your local network. Here are the steps to follow:
Step 0: Prerequisites
To install Tailscale on your Raspberry Pi, you will need to meet the following prerequisites:
- Raspberry Pi: You will need a Raspberry Pi board. Tailscale supports most models, including Raspberry Pi Zero, Raspberry Pi 2, Raspberry Pi 3, and Raspberry Pi 4.
- Operating System: Make sure you have a compatible operating system installed on your Raspberry Pi. Tailscale supports popular Linux distributions such as Raspbian, Ubuntu, and Debian.
- Internet Connection: Ensure your Raspberry Pi is connected to the internet. This can be through Ethernet or Wi-Fi.
- Terminal Access: You will need access to a terminal or command line interface on your Raspberry Pi. This can be done remotely via SSH or directly on the Pi using a keyboard and monitor.
- Finally, to ensure the smooth and secure operation of your system, it is important to keep the package list up to date and upgrade any outdated packages. You can do this by executing two commands:
sudo apt updateto update the package list, and
sudo apt upgradeto upgrade the outdated packages. Regularly performing these commands will help keep your system running smoothly and securely.
That’s it! Once you have these prerequisites in place, you can proceed with installing Tailscale on your Raspberry Pi.
Step 1: Install Tailscale on your Raspberry Pi
The first step is to install Tailscale on your Raspberry Pi. You can do this by running the following command in a terminal:
curl -fsSL https://tailscale.com/install.sh | sudo bash
This will download and run the Tailscale installation script, automatically detecting your operating system and installing the appropriate package. You will need to enter your sudo password to proceed.
Alternatively, if you want to install it manually, you can follow the manual installation instructions for Raspberry Pi on the PiMyLifeUp website
Step 2: Sign up for a Tailscale account and join your network
Next, sign up for a Tailscale account and join your network. You can do this by running the following command in a terminal:
sudo tailscale up
Now, open the link printed in the terminal in a browser, This will prompt you to authenticate with your email or a supported identity provider, such as Google, GitHub, etc… Once you authenticate, you will see a message that your device has joined your Tailscale network, also known as a tailnet. You will also see your device’s unique Tailscale IP address, which will be in the 100.64.0.0/10 subnet.
Step 3: Install Tailscale on your remote device
The third step is to install Tailscale on your remote device. You can download Tailscale from their website and follow the instructions to install it on your preferred platform. Tailscale supports Windows, Mac, Linux, iOS, Android, and more. You must sign in with the same email or identity provider you used on your Raspberry Pi and join the same Tailscale network.
Here I have connected to the same tailnet (tailscale network) from my iPhone.
Step 4: Access your Raspberry Pi using its Tailscale IP address
The final step is to access your Raspberry Pi using its Tailscale IP address. You can find your Raspberry Pi’s Tailscale IP address by running the following command in a terminal:
tailscale ip -4
You can also find it on the Tailscale app or website, under the Devices tab. Once you have the IP address, you can use any tool or protocol that you normally use to access your Raspberry Pi, such as SSH, VNC, HTTP, or RDP. For example, if you want to SSH into your Raspberry Pi, you can run the following command on your remote device:
ssh pi@<tailscale_ip of your pi>
You will need to enter your Raspberry Pi’s password to log in. You can also use the -X flag to enable X11 forwarding, which will allow you to run graphical applications on your Raspberry Pi and display them on your remote device. Read more about X11 forwarding on goteleport.com
As you can see in the above screenshot I have connected to the Raspberry Pi from my Windows machine using the Tailscale IP address of our Pi instead of the local IP address. Now we can use the PI from anywhere in the world as if it’s on our local network, isn’t that exciting!
That’s it! You have successfully set up a simple and secure way to remotely access your Raspberry Pi from anywhere using Tailscale. You can now use your Raspberry Pi as if it was on your local network, without exposing it to the internet or opening any firewall ports.
You can also use Tailscale to access other resources on your network, such as printers, servers, or cameras. Tailscale also supports Access Control Lists (ACLs) to manage access for users and groups to devices, IP’s, subnets, and ports.
You can learn more about Tailscale and its features in their documentation. I hope you found this blog post helpful and informative. If you have any questions or feedback, please leave a comment below. Thank you for reading!