OpenVPN is a service that allows you to host your own VPN server without using third-party servers.
A VPN is a secure connection between two networks, for example between your phone and your home.
In this tutorial I’ll give you a step-by-step method for a quick installation on Raspberry Pi.
How do I install OpenVPN on Raspberry Pi?
OpenVPN is available in the official repository, so it can be installed just like any other package.
Then you need to configure the security to ensure adequate encryption of the data between the two networks.
In fact, I have already done a tutorial on how to install OpenVPN a few years ago, but many of them were lost during installation.
Part of the configuration is so long and complex that it was too difficult to control it, especially for personal use.
So I was looking for an easier way to install and configure OpenVPN and I found it!
I’ll share it with you.
Make sure you have everything ready for installation.
For advanced users you can probably skip this part, I just want to answer all the questions before continuing.
What is VPN?
VPN stands for Virtual Private Network, and the basic idea is to combine the two networks.
For example, companies may use it to employ staff in two different locations, but use the same resources in the main building (e.g. file sharing).
With Raspberry Pi we normally have access to the network remotely, anywhere in the world.
For example, you can use your smartphone to access your surveillance camera or your home automation website while on the move.
The smartphone connects to Raspberry Pi over the Internet and creates a secure tunnel between two devices, allowing you to access any service on your home network.
OpenVPN is the software that makes it work in both directions.
Find your IP address
In order to do this, you need to know the public IP address of your home and configure it on the customer side.
In case you don’t know, I will show you how to get your IP address and also how to avoid problems when your IP address changes from time to time.
What is my intellectual property?
It is quite easy to find your current IP address, as many websites will give it to you.
For example, go to MyIP.com and note down your IP address.
You only need it at the end of the tutorial to configure the OpenVPN client, but it is an important requirement, especially if you have a dynamic IP address.
Static or dynamic?
Depending on your Internet service provider, you may or may not have a static IP address.
In my case, I’m not so lucky, so my IP address is replaced with a new one every day.
In this case, your VPN customer will stop working after the first change (or you will have to change the IP address each time).
To prevent this, you can use a free service called PIN, which gives a free hostname (for example myname.ddns.net) which will be sent to your IP address even after a change. This allows you to configure the VPN client with my name.ddns.net instead of your IP address..
You just need to have something in your network that regularly updates the IP address to a PIN code.
I have this function in my internet router, so all I have to do is enter my access data into the interface and that’s it.
But even if you don’t have it in your router, you can install the script on Raspberry Pi (or any other device) to do the same. The tutorial Raspberry Pi is available here if you are interested in.
Raspberry Pi OSInstall
The final step is to make sure Raspberry Pi OS is properly installed and configured.
If you need help with this topic, you can view my step-by-step instructions.
Before we go any further, I suggest you take a look at this:
- The Raspberry Pi operating system is installed (the Lite version is sufficient for VPN servers).
- You have access to your network and the Internet (if possible with an Ethernet connection).
- Your system has been updated
- And some is made, especially if you want it to work with VPN service 24 hours a day.
Configuration of the OpenVPN server
As soon as everything is ready, we can start installing the server on Raspberry Pi.
They cover many aspects such as the network, security settings, users and certificates. But the installation script takes care of everything.
Log in to Raspberry Beer with SSH and follow this procedure:
- We use the installation script from Angristan to GitHub.
You can check the code under this link for installation, if you wish.
- Copy this command and paste it into your terminal to download:
wget https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh -O openvpn-install.sh
- Then run the script:
sudo bash openvpn-install.sh
- The script shows you your local IP address (which you will need in the next step), your public IP address and asks you some questions.
- In most cases you will keep the default values, so press the Enter key for each question if you don’t know.
The OpenVPN installation starts.
- Within a few seconds you will be asked a question about the first user that has been created.
Give it a name (e.g. your name or the device you are connecting to) and set a password if necessary (optional).
The scripts end and give you the path to the first configuration file:
That’s it, the VPN server is operational and your first client is ready to go.
Pay attention: I recommend restarting the Raspberry Pi after installation. I don’t know why, but it didn’t work for me before the restart, even after the shift started manually.
An additional step must be taken before the customer carries out the installation.
Chances are that your Raspberry Pi is not directly online, but behind your router. So you need to configure this router to redirect VPN connections to your Raspberry Pi.
The configuration depends on your router model, so I can’t give you precise step-by-step instructions, but your ISP will probably be able to help you (for example, AT&T has documentation on page tab for each modem).
You need to settle down:
- External gate: can be 1194 or other for simplicity.
- Internal IP address : The script shows them at the beginning, or you can open this tutorial to get it now.
- Local port: which is 1194 by default, or what you specify in the script if you don’t save the default value.
In my case, this is what it looks like:.
So I added the second line to redirect port 1194 to Raspberry Pi, the same port.
Hint: A good idea might be to use a static IP address on your Raspberry Pitab, or configure a DHCP server to store Raspberry Pi’s IP address.
Configuring the OpenVPN client
Our VPN server is now available on the Internet, so we can configure the client to connect to anything.
OpenVPN is available for PCs (Windows, Linux) and smartphones (iPhone, Android). I’ll show you how to install and configure it.
OVPN– File retrieval
The first step, regardless of your system, is to restore the file created by the OpenVPN wizard on Raspberry Pi.
Do you remember that? For me it was /home/pi/android.
You need to get it on the client on which you want to install OpenVPN.
If SSH is enabled, the easiest way to connect to Raspberry Pi with FileZilla or WinSCP and transfer the file to your computer is to use SSH.
You can then send it to any device you like.
Create a new website on FileZilla and use SFTP to connect to Raspberry Pi.
Enter the IP address of the host and a username and password..
Once connected you can download the file in /home/pi and send it to the device you want to use as a client (I often do this by e-mail, but for a PC you can also use the USB stick).
Change the file to use the host name PIN#.
If you have a dynamic public IP address and you are using a No-IP service, there is an extra step:
- Open the .ovpn file.
- Find this line at the beginning:
- Replace it:
Remote control 1194
- Save and exit the file
That’s it. Now you can use it on any device.
Installation under Windows
- Download the OpenVPN installer from the official website
- Define them (you can save the default values).
- Next, the OpenVPN symbol should appear in the taskbar next to the clock in the lower right corner of the screen.
You can also start it from the main menu.
- Right-click on this icon and select Import a file……
- Select and confirm the file created on Raspberry Pi.
- Right-click again and click the Connect button.
It only works if the device is not connected to your home network, but you can test it by sharing a phone connection, for example.
- Enter your password if you selected it in the configuration.
That’s it, now you’re connected to your VPN server.
Installation on iPhone / Android
You can also install OpenVPN on your phone!
The application is called OpenVPN Connect and is available via the new Open App Store and Google Play Store.
- Install the application on your phone
- Transfer the .ovpn file to your : The easiest way is to send them by email and download them from your email application.
- Open an OpenVPN connection
- Go to Import profile > File and select the .ovpn file Download
- Click Import and Add.
- A new profile has been added and you can login by clicking on the data
Don’t forget to disconnect the Wi-Fi connection if you are on the same network as Raspberry Pi.
- That’s it, now you are connected:
That’s it, now you know an easy way to install OpenVPN on Raspberry Pi and connect to your home network anywhere in the world.
Sending IP addresses and ports can be a bit complicated for beginners, but setting up OpenVPN with this method is really easy.
raspberry pi openvpn server setup,openvpn raspberry pi server,wireguard raspberry pi,raspberry pi zero vpn,pivpn wireguard,pivpn web interface,pivpn youtube,dietpi vpn