VPN ( Virtual Private Network) allows you to securely connect to the Internet, a public network (such as free Wi-Fi at the airport), or any other area.
VPN also allows users to exchange data remotely over public networks. A VPN is also often required to access the resources of your corporate or office or home server.
You can bypass filters and unblock location-restricted websites with a VPN.
Through VPN, you can browse the web anonymously — this allows you to access websites and web applications in complete anonymity.
It helps protect you while browsing the Internet, which is becoming more and more important in this age of tracking and analytics. Let’s start installing.
- Debian Cloud VPS
- System user with root privileges
Step 1. Log in to your server via SSH and update the system:
ssh root@server_ip -p port_number
Be sure to replace server_ip and port_number with the appropriate values for your VPS.
After logging in, run the following command to ensure that all installed packages are updated to the latest available version:
apt-get update && apt-get upgrade
Step 2. Check the IP address of your server.
To check the public IP address on your server, you can use this command:
The command will show you something like this:
Step 3. Configure your firewall.
Now we are going to configure the firewall — please change the network interfaces such as “tun0” and “eth0” to match yours and then run the commands.
iptables -A INPUT -i tun0 -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 eth0 -j MASQUERADE
Also note that if you do not want 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 guide, we’ll show you how to install it using an install 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 select the correct public IP address on your server. You will then be asked to provide information using a few questions, as shown in the following image.
After pressing any key to continue, the server will start the newly installed OpenVPN server.
If you see an error message when trying to start the OpenVPN server after installation, you can edit this file, /lib/systemd/system/[email protected], and comment out the LimitNPROC line.
systemctl start openvpn
During the installation of the OpenVPN server, you were asked to provide a name for the VPN client. In this tutorial, we have used “vpnclient” as the client name. The installer automatically created a VPN client configuration file at /root/vpnclient.ovpn based on this name. You can either open the file and copy its contents, or download it to your local computer from which you want to connect to the OpenVPN server. If you want to connect to the OpenVPN server from a Windows computer, you need to save the .ovpn file in the directory
After you have installed the OpenVPN client on your local machine and downloaded the configuration file, you can try to connect to the newly installed OpenVPN server.
That’s all. OpenVPN server successfully installed on your Debian Cloud VPS.
PS. If you liked this post on how to set up an OpenVPN server on Debian, please share it with your friends on social media using sharing shortcuts, or just leave an answer below.