How To Protect Your Privacy With An SBC-Powered VPN Server

A PiVPN server is the best way to protect your privacy without exposing your data to a third-party VPN provider Virtual Private Networks (VPNs) are an effective means to enhance … Read more

Taylor Bell

Taylor Bell

Published on May 19, 2024

How To Protect Your Privacy With An SBC-Powered VPN Server

A PiVPN server is the best way to protect your privacy without exposing your data to a third-party VPN provider

A Raspberry Pi 5 placed on a Gigabyte Aorus AC300W cabinet

Virtual Private Networks (VPNs) are an effective means to enhance your privacy. By disguising your IP address, a VPN prevents third-parties from tracking your online activities on top of protecting your data from network-based hacking attacks.

However, it’s not a good idea to blindly trust all VPN providers you may come across on the Internet. Unreliable VPNs can track and monitor your browsing data, and even sell this information to generate revenue. So, if you’re not willing to invest in a premium VPN, you can try building a PiVPN server using an affordable SBC.

Best single board computer

Related

Best single board computer in 2024

If you’ve been thinking of tinkering with a SBC, we break down the most common ones and why you’d want them.

What you’ll need

Since setting up a VPN doesn’t require a lot of computational prowess, you can use pretty much any SBC on the market for this purpose. That said, cheaper and less powerful devices like the Raspberry Pi Zero can get bogged down if you try to connect too many clients and aren’t viable if you want extremely high speeds.

Assuming that your board uses a microSD card for storage, you can save some money by getting an 8GB card, as most modern SBC-centric operating systems don’t require too much space. Speaking of, we’ll assume you’ve already flashed an operating system onto your microSD card. I’ve gone with the Raspberry Pi OS, but you can go for any Debian-based operating system, including those with lightweight command-line interfaces.

  • A render of the Raspberry Pi 5

    Raspberry Pi 5

  • A render showing the SanDisk Ultra microSDXC card.

    SanDisk 256GB Ultra microSDXC card

Before you begin (Optional)

Once you’ve gathered the necessary components and booted into your preferred OS, you can go through some optional steps to access your SBC-powered VPN remotely from other networks.

The first step involves setting a static IP address for the SBC using your router’s web app. The exact steps will vary depending on your specific router, but the general procedure is as follows:

  1. Open your router’s admin page and log in with your credentials.
  2. Inside the LAN section, you’ll find some DHCP settings, including the option to reserve specific IP addresses.
    The Reserved IPs page on a router's web UI

  3. Click on the Create New button and enter the IP address of your SBC. You can use a network scanner application like Fing to get your SBC’s IP address.
Minecraft running on a PC, with the server running on a Raspberry Pi 5

Related

How to find your Raspberry Pi IP Address

You must know your Raspberry Pi’s IP address to connect it to the network. Here are a few ways you can find it.

Next, you’ll have to enable port forwarding on your router. Like static IP, your particular router may have a different location and parameters for this setting.

  1. Head to the Security or Firewall tab in the router’s web UI.
  2. Click on Port Forwarding and create a New rule.
    The port forwarding settings in a router

  3. Type the same IP address you reserved for your SBC in the Destination Address tab.
  4. For the Port Numberyou can choose 51820 (default port for Wire Guard), 1194 (default port for OpenVPN), or any other number between 49152 and 65535.
  5. If your router asks you to pick between TCP or UDPchoose the latter.

Installing PiVPN

With the preliminary steps out of the way, it’s time to install PiVPN.

  1. Launch the Terminal app.
    The Raspberry Pi terminal app

  2. Type the following command to download and initialize the PiVPN installer: curl -L https://install.pivpn.io | bash
    The terminal command to download PiVPN

  3. After the installer boots up, tap OK twice.
    The Automated Installer page when installing PiVPN

  4. Choose Yes when the installer asks you to block IPv6 leakage.
    The procedure to block IPv6 leaks in the PiVPN installer

  5. Press No on the next page to set up a static IP address for your SBC.
    The procedure to set up a static IP in the PiVPN installer

  1. Tap Yes to set your SBC’s default IP address as the static IP.
    The procedure to set the default IP address of an SBC as static IP in the PiVPN installer

    Make sure this address matches the static IP you set in the router settings earlier, and hit OK twice.

  2. Hit the OK button after picking the Local User.
    Picking a Local User in the PiVPN installer

  3. Choose between WireGuard and OpenVPN.
    The procedure to pick a VPN server in the PiVPN installer

    I use the former on my Raspberry Pi VPN server, though you can go for OpenVPN if you run into compatibility issues with WireGuard.

  4. Enter a Port Number for WireGuard before hitting OK and choosing Yes when prompted for confirmation.
    The procedure to set a port number in the PiVPN installer

    If you followed the optional steps, this port number should match the one you used to set up port forwarding.

  5. Pick a DNSProvider for your PiVPN server.
    The procedure to pick a DNS provider in the PiVPN installer

  6. Decide whether the clients will connect to the server using the Public IP or Public DNSand select OK three times after making your choice.
    Choosing between Public IP and Public DNS in the PiVPN installer

  7. Select Yes when PiVPN asks you to enable automatic security upgrades.
    The procedure to enable auto security updates in the PiVPN installer

  8. Reboot your SBC once the PiVPN installation is finished.

Accessing the PiVPN server

Once your SBC reboots, you’ll need to manually add your PC and other devices to the PiVPN server before you can connect to it.

  1. Launch the terminal and enter this code to create a profile for the client device:
    pivpn add
    The command to add a new client device in PiVPN

  2. Choose a Name for the client system before pressing Enter.

Once PiVPN has created a client_name.config fileyou’ll have to import it to the WireGuard GUI app on your preferred platform. The quickest way to do so involves using an external storage drive:

  1. Plug your USB drive into the SBC, and transfer the client_conf.conf file to it with the help of File Manager.
    The client.conf location in the File Manager

    On the Raspberry Pi OS, this file is located in the /home/user_name/config directory. You can also view the location of this file inside the terminal

  2. Unplug the drive from your SBC and plug it into your PC.
  3. Switch to your PC, download the WireGuard setup file from the official website, and use it to install the WireGuard client app.
  4. Run the WireGuard.exe file as an admin.
  5. Click on Import tunnel(s) from fileselect the client_name.conf file on the USB drive, and press Open.
    The procedure to import the client_name.conf file into the WireGuard PC app

  6. Press Activate under the Interface tab to start using the VPN.
    The procedure to enable PiVPN

Maintaining your online privacy with an SBC

An image of the Raspberry Pi Active Cooler mounted on the Pi 5

​​​​​​​Besides your PC, you can also connect other devices to the PiVPN server. For Android and iOS systems, you can download the WireGuard app from their respective app stores. To further simplify the setup procedure, type pivpn -qr into the SBC’s terminal and use the QR code that pops up to connect your smartphone to the PiVPN server.

Of course, there are a ton of other utility projects you can build with your SBC. There’s motioneyeOS, which lets you turn pretty much any SBC, not just the Raspberry Pi, into a motion-detecting surveillance system. Likewise, you can also install OpenWrt on your SBC to convert it into a powerful firewall for your home network.

Milk-V-Duo-S-2

Related

8 simple projects you can build with any SBC

Who says you need a Raspberry Pi to build your next DIY project?

Partager cet article

Inscrivez-vous à notre newsletter