Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 19, 2025

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 19, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 19, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 19, 2025

      My latest hands-on could be the best value AI laptop of the summer, but I still have questions

      May 19, 2025

      DOOM: The Dark Ages had the lowest Steam launch numbers in series history — Is it suffering from the ‘Game Pass Effect’?

      May 19, 2025

      Microsoft won’t be left exposed if something “catastrophic” happens to OpenAI — but may still be 3 to 6 months behind ChatGPT

      May 19, 2025

      Microsoft Copilot gets OpenAI’s GPT-4o image generation support — but maybe a day late and a dollar short for the hype?

      May 19, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      ES6: Set Vs Array- What and When?

      May 19, 2025
      Recent

      ES6: Set Vs Array- What and When?

      May 19, 2025

      Transform JSON into Typed Collections with Laravel’s AsCollection::of()

      May 19, 2025

      Deployer

      May 19, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      My latest hands-on could be the best value AI laptop of the summer, but I still have questions

      May 19, 2025
      Recent

      My latest hands-on could be the best value AI laptop of the summer, but I still have questions

      May 19, 2025

      DOOM: The Dark Ages had the lowest Steam launch numbers in series history — Is it suffering from the ‘Game Pass Effect’?

      May 19, 2025

      Microsoft won’t be left exposed if something “catastrophic” happens to OpenAI — but may still be 3 to 6 months behind ChatGPT

      May 19, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to Set Up a Home VPN Using Tailscale on a Raspberry Pi

    How to Set Up a Home VPN Using Tailscale on a Raspberry Pi

    March 28, 2025

    In this article, you’ll learn how to set up a VPN which you can host on a Raspberry Pi. I am a fan of Raspberry Pis because these small form factor computers are a favourite tool for tinkerers, like me.

    This VPN will allow you to access your home network from anywhere as if you’re still at home. So why is this useful, you might ask? Well, it allows you to use your home network IP, no matter where you are, which is a good for privacy.

    In this article, we’ll use Tailscale, an open-source mesh VPN (Virtual Private Network) service that streamlines connecting devices and services securely across different networks. It enables encrypted point-to-point connections using the open-source WireGuard protocol. This means that only devices on your private network can communicate with each other.

    Table of Contents

    • Prerequisites

    • Install Raspberry Pi OS Lite (32-bit)

    • Boot The Raspberry Pi

    • SSH Into The Raspberry Pi and Login

    • Install Tailscale on Raspberry Pi

    • Key Expiry

    • Configuring the Raspberry Pi as an Exit Node

    • Conclusion

    Prerequisites

    • Raspberry Pi (I am working with a Raspberry Pi 5)

    • Raspberry Pi Imager

    • A Micro SD Card (8GB is enough)

    • A Micro SD Card reader for your computer.

    • Home Router

    • A Tailscale account

    Install Raspberry Pi OS Lite (32-bit)

    We’ll start this process by installing the Raspberry Pi OS Lite (32-bit) on the micro SD card we have. We will be making use of the Raspberry Pi Imager software which is available for free here.

    When you run the imager software, pick the Raspberry Pi Device, which for me is a Raspberry Pi 5.

    Then in Operating System, click on Raspberry Pi OS (other), then scroll down to Raspberry Pi OS Lite (32-bit)

    Next, select your SD card which you have inserted into the card reader, and the card reader into the computer. Your screen should look similar to what you see below. Click on next.

    A Screenshot of the Raspberry Pi Imager software start menu.

    After next, you should see a pop-up asking if you would like to apply OS customisation settings.

    A screenshot of the Raspberry Pi Imager software customisation prompt menu

    Next, click on edit settings. Enable set hostname and write the name you want to give the Pi. For this tutorial, I will be using dapivpn. Then enable set username and password. Pick a username and a strong and secure password

    You can enable configure wireless LAN if you plan to use Wifi, but if you are team Ethernet cable, you can skip this. I will be using WiFi in this tutorial though.

    Now you’ll need to enable set local settings and pick your correct time zone and keyboard layout.

    After that, go to the Services tab, then enable SSH and click on “Use password authentication”. Then click save, then yes on the apply customisation screen, and yes again. Remember this will erase all the data on the SD card, so make sure you’re using one without any important files on it.

    This is how your Raspberry Pi Imager should look now:

    A screenshot of the Raspberry Pi Imager software performing the write operation.

    Boot the Raspberry Pi

    After this is done, take the SD card and insert it into your Raspberry Pi. Then plug the power cable into the Raspberry Pi and wait some minutes for it to boot properly. You will know it is ready when the green LED light stays on.

    Now you should go to your router and set a static IP to the Raspberry Pi. For mine, I set it to 192.168.8.21.

    SSH into the Raspberry Pi and Login

    Open up your command line terminal. Type “ssh <pi username>@<raspberry_pi_ip_address>”. For me, this would be:

    ssh danpi@192.168.8.21
    

    Then type in the password you used. You should see your username and the Pi hostname and this confirms you have logged in successfully to it.

    Command line interface showing a successful SSH process

    Type in:

    sudo apt update && sudo apt upgrade -y
    

    You run this command to make sure everything is up to date locally.

    Command line interface showing the update command running

    Now reboot your Pi after this by typing:

    sudo reboot
    

    Install Tailscale on Raspberry Pi

    Now you’re going to add Tailscale’s package signing key and repository.

    curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null 
    curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
    

    Install Tailscale using these commands:

    sudo apt-get update
    sudo apt-get install tailscale
    

    Next, you need to connect your Pi to your Tailscale network and authenticate. You can do that with the following command:

    sudo tailscale up
    

    Your browser should look like this.

    Screenshot of the browser showing the authentication screen

    To locate the Tailscale IPv4 address for the Raspberry Pi, run this command:

    tailscale ip -4
    

    You can also see it on the Tailscale dashboard in your browser.

    At this point, you’re done installing Tailsacle and you just need to do some finishing touches.

    Key Expiry

    There is something you need to know when it comes to adding a device to Tailsacle. By default, and as a security feature, Tailscale requires devices to re-authenticate after a certain period of time has elapsed, usually 180 days.

    If the re-authentication does not occur, keys expire and the connection stops working. It’s up to you to choose what you prefer, as this is a security feature that comes with some inconvenience.

    I will be disabling the key expiry on the Raspberry Pi, as I fully trust it. To do this, you need to:

    • Open the Machines page of the Tailscale admin console.

    • Find the Raspberry Pi on the row and select the option menu there.

    • Click on the Disable Key Expiry option. You should see an Expiry Disable label below the machine name.

    How to Configure the Raspberry Pi as an Exit Node

    Another thing you’ll need to know about when it comes to Tailscale is what an exit node is. A Tailscale exit node is a designated device in your Tailscale network that routes all of your internet traffic through it. No matter where you are, once you have this device activated as an exit node, when you turn on Tailscale, it routes your internet traffic through the device.

    Ideally, you want a device that is powered on 24/7 to serve as your exit node. That’s why we are picking the Raspberry Pi, as it is a low-powered computer.

    We are already 90% of the way, as we have Tailscale running on our Pi. Remember to also have Tailscale installed on as many devices on your local network as possible. What’s left is to allow your Pi to act as an exit node, so all your internet traffic or LAN traffic routes through it, giving you access to:

    • Local network devices at home

    • Your home public IP

    • Internal services like NAS, printers, cameras, and so on

    To do this, SSH into your Raspberry Pi and follow these steps:

    • Enable IP Forwarding. IP forwarding allows your Raspberry Pi to pass traffic between its network interfaces. Run the commands below line by line:

        echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
      
        echo "net.ipv6.conf.all.forwarding=1" | sudo tee -a /etc/sysctl.conf
      
        sudo sysctl -p /etc/sysctl.conf
      
    • Advertise the Raspberry Pi as an exit node:

        sudo tailscale up --advertise-exit-node
      
    • Open the Machines page of the Tailscale admin console.

    • Find the Raspberry Pi on the row. You should see an Exit Node label on its name.

    • Click on the options menu there and select Edit Route Settings.

    • Check the box for Use as an exit node, then save.

    Now you should see the option of routing the internet through an exit node when you open up your Tailscale app on mobile or PC or anywhere you have it installed. When you see that option, you will also see the Raspberry Pi as an exit node option. You can also add more devices as an exit node if you want more options.

    Conclusion

    Using the Tailscale app on other devices, you can now route traffic securely through the Raspberry Pi by selecting it as an exit node. Tailscale also provides clear, step-by-step guides tailored to each device type for setting up and using an exit node.

    You can now be away from your home internet but still connect to the internet as if you were home. See you next time.

    Source: freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHow to Deploy a Restful Web Service on Microsoft Azure App Service
    Next Article How to Send Emails in Python using Mailtrap SMTP and the Email API

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 19, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-48259 – Juan Carlos WP Mapa Politico España CSRF

    May 19, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    CVE-2025-4297 – PHPGurukul Men Salon Management System SQL Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Meet Moxin LLM 7B: A Fully Open-Source Language Model Developed in Accordance with the Model Openness Framework (MOF)

    Development

    Fortifying React Native: Security Enhancements to Watch for in Upcoming Releases🔐

    Web Development

    Kentucky Man Sentenced for Faking His Own Death By Hacking Into Government Sites

    Development

    Highlights

    Linux

    FOSS Weekly #25.18: Linux Magazine, Modern Terminals, Muse Pi, apt Guide and More

    May 1, 2025

    Before the age of blogs, forums, and YouTube tutorials, Linux users relied on printed magazines…

    CVE-2025-47770 – Apache HTTP Server Cross-Site Request Forgery

    May 10, 2025

    Decades-Old Security Vulnerabilities Found in Ubuntu’s Needrestart Package

    November 21, 2024

    This Self-Driving Taxi Could Replace Uber by 2025 — And It’s Backed by Toyota

    April 24, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.