PiVPN is a tool used to create a Private Virtual Network (VPN) on a Raspberry Pi, which allows you to access your network remotely or secure your internet traffic.
In this tutorial, you will learn how to install PiVPN on Alpine Linux Latest.
Before you begin, ensure that you have the following:
To install PiVPN, run the commands below in the terminal or shell:
curl -L https://install.pivpn.io | bash
During the installation process, you will be prompted to configure the PiVPN settings such as the client settings, OpenVPN ports, and other settings as required.
Follow the prompts to complete the installation process.
IP forwarding must be enabled on your Raspberry Pi to route traffic from your VPN clients. To enable IP forwarding, follow the steps below:
/etc/sysctl.d/
directory by running the command.cd /etc/sysctl.d/
99-sysctl.conf
and insert the following line.sudo nano 99-sysctl.conf
net.ipv4.ip_forward=1
Save the file and exit.
sudo sysctl -p /etc/sysctl.d/99-sysctl.conf
To allow traffic from VPN clients to pass through the firewall, you need to modify the rules to allow OpenVPN traffic.
sudo nano /etc/ufw/before.rules
# Allow traffic from OpenVPN clients
-A ufw-before-input -p udp -m udp --dport 1194 -j ACCEPT
-A ufw-before-input -p tcp -m tcp --dport 1194 -j ACCEPT
Close and save the file.
Reload the firewall.
sudo ufw reload
Next, you need to generate a client configuration file for the OpenVPN client to establish a connection to the PiVPN server.
sudo pivpn add
Follow the prompts to create a new client and configure its settings.
Save and exit when done.
The configuration file for the newly created client will be stored in the /home/pi/ovpns/
directory.
To connect to the VPN, follow the steps below:
Install the OpenVPN client on your local computer.
Copy the client configuration file (*.ovpn
) to your local computer.
Open the OpenVPN client application and choose Import Profile
.
Select the client configuration file (*.ovpn
) and click Open
.
Enter your login credentials in the fields provided and click Connect
.
You will be connected to the VPN and can access your local network or browse the internet securely.
Congratulations! You have successfully installed PiVPN on Alpine Linux Latest and created a VPN server on your Raspberry Pi.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!