PiVPN - Turn Raspberry Pi into a Fully Functional VPN Server for More Privacy
PiVPN is a lightweight, super user-friendly project that simplifies setting up a VPN server on a Raspberry Pi.
It allows you to configure either OpenVPN or WireGuard, two of the most popular VPN protocols, to securely access your home network from anywhere.
With PiVPN, you can protect your data, bypass regional restrictions, and connect securely to your home network, even on public Wi-Fi.
Features
- Support for OpenVPN and WireGuard protocols
- Simple setup through a command-line installer
- Manage VPN clients easily with generated profiles and QR codes
- Access local devices and networks remotely
- Enhanced security through encryption
- Automatic updates and maintenance tools
- Integrates with Bitwarden
- iOS keychain support
- Supports multiple DNS providers
- Supports Custom DNS Servers
- Custom Search Domains (OpenVPN Only)
- Runs with Pi-Hole®
- Doesn't need to be a Raspberry Pi™, It runs on any x86_64 system
- Supports unattended installation for automated deployments
- Elliptic curve encryption keys up to 512 bit
Installation Guide: PiVPN on Raspberry Pi
Prerequisites:
- Raspberry Pi running a compatible OS (e.g., Raspberry Pi OS).
- Access to the terminal (either directly or via SSH).
- Static IP configured on your router for the Raspberry Pi (recommended).
- Port forwarding set up on your router (for VPN access).
Step 1: Update the System
Open a terminal and update your Raspberry Pi to ensure you have the latest software.
sudo apt update && sudo apt upgrade -y
Step 2: Install PiVPN
Execute the following command to download and run the PiVPN installer:
curl -L https://install.pivpn.io | bash
This will initiate an interactive setup process.
Step 3: Choose a VPN Protocol
The installer will ask you to choose between OpenVPN and WireGuard.
- OpenVPN: Widely supported but may be slower due to higher encryption overhead.
- WireGuard: A faster, modern VPN protocol with a lean codebase.
Select the protocol based on your needs.
Step 4: Configure Network Settings
The installer will prompt you to select:
- Interface: Choose your Pi’s network interface (typically
eth0
orwlan0
). - Port Number: Use the default or specify your own (ensure it matches the port forwarded on your router).
Step 5: Create VPN Clients
After installation, you can create VPN profiles with the following command:
pivpn add
You will need to provide a client name and, for WireGuard, the installer will generate a QR code for easy import into mobile apps.
Step 6: Test the VPN Connection
- Download the client profile from your Raspberry Pi.
- Import it into a VPN client on your device (such as the OpenVPN app or WireGuard app).
- Test the connection by connecting to the VPN and verifying access to your home network.
Step 7: Managing PiVPN
- List Clients:
pivpn list
- Revoke a Client:
pivpn revoke [client-name]
- Show WireGuard QR Code:
pivpn -qr [client-name]
Final Note
Setting up a VPN with PiVPN on a Raspberry Pi is an excellent way to protect your online activities and access your home network remotely.
Whether you use OpenVPN for its versatility or WireGuard for its speed, PiVPN makes the process straightforward, even for beginners. With just a few commands, you can turn your Raspberry Pi into a personal VPN server.