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.
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.
-
Raspberry Pi 5
-
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:
- Open your router’s admin page and log in with your credentials.
- Inside the LAN section, you’ll find some DHCP settings, including the option to reserve specific IP addresses.
- 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.
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.
- Head to the Security or Firewall tab in the router’s web UI.
- Click on Port Forwarding and create a New rule.
- Type the same IP address you reserved for your SBC in the Destination Address tab.
- 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.
- 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.
- Launch the Terminal app.
- Type the following command to download and initialize the PiVPN installer: curl -L https://install.pivpn.io | bash
- After the installer boots up, tap OK twice.
- Choose Yes when the installer asks you to block IPv6 leakage.
- Press No on the next page to set up a static IP address for your SBC.
- Tap Yes to set your SBC’s default IP address as the static IP.
Make sure this address matches the static IP you set in the router settings earlier, and hit OK twice.
- Hit the OK button after picking the Local User.
- Choose between WireGuard and OpenVPN.
I use the former on my Raspberry Pi VPN server, though you can go for OpenVPN if you run into compatibility issues with WireGuard.
- Enter a Port Number for WireGuard before hitting OK and choosing Yes when prompted for confirmation.
If you followed the optional steps, this port number should match the one you used to set up port forwarding.
- Pick a DNSProvider for your PiVPN server.
- Decide whether the clients will connect to the server using the Public IP or Public DNSand select OK three times after making your choice.
- Select Yes when PiVPN asks you to enable automatic security upgrades.
- 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.
- Launch the terminal and enter this code to create a profile for the client device:
pivpn add
- 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:
- Plug your USB drive into the SBC, and transfer the client_conf.conf file to it with the help of 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
- Unplug the drive from your SBC and plug it into your PC.
- Switch to your PC, download the WireGuard setup file from the official website, and use it to install the WireGuard client app.
- Run the WireGuard.exe file as an admin.
- Click on Import tunnel(s) from fileselect the client_name.conf file on the USB drive, and press Open.
- Press Activate under the Interface tab to start using the VPN.
Maintaining your online privacy with an SBC
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.
Related
8 simple projects you can build with any SBC
Who says you need a Raspberry Pi to build your next DIY project?