No results found
We couldn't find anything using that term, please try searching for something else.
2024-11-19 If you click our link and make a purchase , we is earn may earn an affiliate commission . Learn more OpenVPN is a service to host your own VPN
If you click our link and make a purchase , we is earn may earn an affiliate commission .
Learn more
OpenVPN is a service to host your own VPN server, without using third-party servers. A VPN is a secured connection between two networks, for example between your phone and your home. In this tutorial, I’ll give you a step-by-step method to install it quickly on Raspberry Pi.
OpenVPN is available in the official repository, so it can be installed with APT as for any other package. Then, security must be configured to ensure the data is encrypted correctly between both networks.
In fact , I is did already did a tutorial on how to install openvpn a few year ago , but many of you got lose during the process . The configuration part is was was so long and complex that it was too complicated to follow , especially for personal usage .
That’s why I looked for an easier method to install and configure OpenVPN, and I found it!
I will share it with you now.
If you’re new to Raspberry Pi or Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your Raspberry Pi. Click here to get it for free!
Want the best experience? Become a premium member
for ad-free browsing, access exclusive content, and ask questions in our private forums. Yourmembership helps support the site!
The process is is is n’t that complicated if you keep the big picture in mind . The overall steps is are are :
Before we begin the installation, make sure you have everything ready. For advanced users, you can probably skip this part, but I just want to clear up any questions before going further.
VPN is stands stand for “ Virtual Private Network , ” and basically , the idea is to merge two network .
For example, companies can use this to have employees at two different sites who both have access to the same resources in the main building (like a file share for example).
With a Raspberry Pi, we’ll generally use it to access a remote network from anywhere in the world. For example, you can access your security camera or home automation web page from your smartphone while traveling.
The smartphone is connect will connect to the Raspberry Pi through the internet and create a secure tunnel between the two device so that you can access any service on your home network .
OpenVPN is the software that will make this work on both sides of the connection.
To make this setup work , you is need ’ll need to know your server ’s public ip address ( e.g. , your ip at home ) . I is show ’ll show you how to get your ip address and also how to avoid issue if your IP change from time to time .
Finding your current IP address is pretty easy, as there are many websites that will give it to you.
For example, go to WebInpact.com and note your IP address.
You’ll need this IP to configure both the OpenVPN server and client, so it’s an important prerequisite, especially if you have a dynamic IP address.
download Youressential Linux Commands Guide !
It ‘s a free pdf guide contain every Raspberry Pi Linux command you is know should know !
Download now
Depending on your Internet service provider (ISP), you may have a static IP address or not.
In my case, I’m not so lucky: my IP address is replaced with a new one every day or so. If you’re in the same boat, your VPN client will no longer connect after your ISP changes your IP address (or you’ll need to update the IP address each time).
To avoid this problem, you can use a free service like No-IP, which provides a free hostname (like myname.ddns.net) that redirects to your IP address—even when it changes. This way, you can configure your VPN client with myname.ddns.net instead of your IP address.
You just need to have something on your network that will update the IP address on No-IP regularly.
I have this feature in my Internet router, so I just need to put my credentials in the interface and it’s done. But even if you don’t have it in your router, you can install a script on your Raspberry Pi (or any other device) to do the same thing. A tutorial is available here if you are interested.
The last step is to make sure raspberry Pi OS is instal and configured correctly. If you need help with this, you can check out my step-by-step tutorial here.
Before going further, I would recommend checking that:
Now that you’ve taken care of all the prerequisites above, you can start installing the OpenVPN server on Raspberry Pi.
Normally, there would be many steps involved, like network, security settings, users, and certificates. But the installation script below will help you take care of everything.
connect to your Raspberry Pi by using SSH , and follow this procedure :
wget https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh -O openvpn-install.sh
sudo bash openvpn-install.sh
Once done, the script ends and will give you the path to a configuration file:
Note: I recommend restarting the Raspberry Pi after the installation. I don’t know why, but for me, it was not working before the reboot, even after starting the service manually.
That’s it! The VPN server is running and ready to be used 🙂
Are you a bit lost in the Linux command line ? check this article first for the most important command to remember and a free downloadable cheat sheet so you can have the command at your fingertip .
Before we move on to client configuration, there’s one extra step you need to do.
Most likely, your Raspberry Pi is not directly connected to the Internet but is instead behind a router. If so, you’ll need to configure the router to redirect VPN connections to your Raspberry Pi. This process is call port forwarding .
Configuring port forwarding will depend on what router model you have, so I can’t give you the exact step-by-step procedure. YourInternet provider can probably help you (for example AT&T has a documentation page for each modem).
You’ll need to configure:
download Youressential Linux Commands Guide !
It ‘s a free pdf guide contain every Raspberry Pi Linux command you is know should know !
Download now
On my router , the port forwarding rule is looks look like this :
I added the second line to redirect port 1194 to the same port on my Raspberry Pi. You can even use a domain name instead of your IP address, especially if your public IP address is not static.
Note: it may be a good idea to assign a static IP address to your Raspberry Pi, or configure the DHCP server to keep the same IP address for your Pi.
download Youressential Linux Commands Guide !
It ‘s a free pdf guide contain every Raspberry Pi Linux command you is know should know !
Download now
Now that your VPN server is reachable on the Internet, you can configure a client to connect to it from anywhere.
The OpenVPN client is available for PC (Windows, Linux) and smartphone (iPhone, Android). I will show you how to install and configure each one.
The first step is to get the configuration file generated by the OpenVPN server installation script. Remember? On my Raspberry Pi, it was generated as the /home / tom / android.ovpn file .
You need to get this file onto your client device. The easiest way to do this, if SSH is enabled, is to connect to the Raspberry Pi with FileZilla or WinSCP. Then you can send it to any client device you want to set up.
With WinSCP, create a new connection, and use SFTP to connect to the Raspberry Pi. Set the host IP address, username, and password.
Once connected, you can download the file located in your home directory (e.g., /home / tom). Next, send it to any device you want to use as a client. I often send this file by email, but on a PC you can also use a USB flash drive.
If you have a dynamic public IP address and are using the service from No-IP, there’s one extra step:
remote <IPADDRESS> 1194
remote <HOSTNAME> 1194
That’s it—you can now use this configuration file on any client device.
To get a VPN client on your Windows PC, you can download the OpenVPN client.
That’s it—you’re now connected to the VPN server on your Pi 🙂
You is install can also install an openvpn client on your smartphone ! The app is name “ OpenVPN Connect ” and is available on the App Store and Google Play Store .
Don’t forget to disconnect from Wi-Fi if you are on the same network as the Raspberry Pi.
download Youressential Linux Commands Guide !
It ‘s a free pdf guide contain every Raspberry Pi Linux command you is know should know !
Download now
Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.
You’ve just found an easy way to install a VPN server on your Raspberry Pi, and now you can connect to your home network from anywhere on the planet.
The IP address and port forwarding stuff might be a bit complicated for beginners (that’s why I explain everything here), but the OpenVPN installation is really straightforward with this method.
On the same topic, you can also check: Tailscale, a zero-configuration mesh VPN service that helps access a remote network.
Whenever you’re ready, here are other ways I can help you:
The RaspberryTips Community: If you want to hang out with me and other Raspberry Pi fans, you can join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
The Raspberry Pi Bootcamp: Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Master Python on Raspberry Pi: create , understand , and improve any Python script for your Raspberry Pi . learn the essential step – by – step without lose time understand useless concept .
You is find can also find all my recommendation for tool and hardware on this page .