In this tutorial, we will show you how to install OpenVPN on a Debian 9 Cloud VPS.
Through a VPN, you can browse the internet anonymously – it allows you to access websites and web application in complete anonymity. This helps keep you protected while browsing online, which is becoming more and more important in today’s age of tracking and analytics. Let’s get started with the installation.
- A Debian 9 Cloud VPS
- A system user with root privileges
Step 1. Log in to your Server via SSH and Update the System:
ssh [email protected]_ip -p port_number
Make sure to replace server_ip and port_number with their respective values for your VPS.
Once you are logged in, run the following command to and make sure all installed packages are updated to the latest available version:
apt-get update && apt-get upgrade
Step 2. Check your Server’s IP address
To check the public IP address on your server, you can use this command:
# ip a
The command will show you something like this:
Step 3. Configure your Firewall
We are now going to configure the firewall – please change the network interfaces like “tun0” and “eth0” to match yours, then run the commands.
# iptables -A INPUT -i <span style="color: #ff0000;">tun0</span> -j ACCEPT # iptables -A INPUT -p udp -m state --state NEW -m udp --dport 1194 -j ACCEPT # iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o <span style="color: #ff0000;">eth0</span> -j MASQUERADE
Please also note that if you do not wish to enable iptables on your server, you can skip this step.
Step 4. Install OpenVPN Server
You can install OpenVPN from the repository, but in this tutorial, we will show you the installation using an installation script. This should install the latest version of OpenVPN and save us some time.
Download the script and make it executable.
# wget https://git.io/vpn -O openvpn-install.sh # chmod +x openvpn-install.sh
Then, run the script.
Make sure you choose the correct public IP address you have on your server. Then, you will be asked for information through several questions, as seen in the following picture.
After pressing any key to continue, the server will run the newly installed OpenVPN server.
If you see an error message when trying to run OpenVPN server after the installation, you can edit this file,
/lib/systemd/system/[email protected], and comment out the LimitNPROC line.
nano /lib/systemd/system/[email protected]
systemctl daemon-reload systemctl start openvpn
In the process of installing the OpenVPN server, you were asked to provide a name for VPN client. In this tutorial, we used “vpnclient” as the client name. The installer automatically created the VPN client configuration file in
/root/vpnclient.ovpn based on that name. You can either open the file and copy its contents, or download it to your local computer with which you want to connect to the OpenVPN server from. If you want to connect to your OpenVPN Sever from your Windows machine, you need to save the .ovpn file to the
C:\Program Files\OpenVPN\config directory.
To connect to your OpenVPN server, you’ll need a VPN client, which you can download it at https://openvpn.net/community-downloads/ .
Once you have installed the OpenVPN client on your local machine and downloaded the configuration file, you can try to connect to your newly installed OpenVPN server.
That is it. OpenVPN Server has been successfully installed on your Debian 9 Cloud VPS.
Of course, you don’t have to Install OpenVPN Server on Debian 9 if you use one of our Managed Linux Cloud VPS Hosting services, in which case you can simply ask our expert Linux admins to install OpenVPN Server on Debian 9 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on How to Install OpenVPN Server on Debian 9, please share it with your friends on the social networks using the share shortcuts, or simply leave a reply below. Thank you.