Dec 02, 2025
Ignas R.
9min Read
A Virtual Private Network (VPN) secures users by creating a point-to-point connection that masks their internet traffic. Although paid VPN services are widely available, you may want to set up your own Linux VPN server with OpenVPN, a popular open-source option.
This tutorial will show you how to set up a Linux VPN server using OpenVPN. We will explain two methods – manual and automatic, using Hostinger’s operating system template.
You will also learn how to manage and test the tunnelling functionality. Moreover, we will also explain how to connect devices running various operating systems to the Linux VPN server.
Using a VPN for Linux desktops and virtual private servers (VPSs) is one of the best ways to remain secure over the internet. Here are the key benefits of a Linux VPN server:
In this section, we will demonstrate how to set up OpenVPN software on a VPS using an operating system template and commands. As both methods have the same outcome, choose whichever you prefer.
To set up a Linux VPN server, ensure you have a compatible machine. While you can set it up on a local system, we recommend using a VPS hosting service since it is more affordable and simpler to manage.
When choosing a VPS hosting plan, ensure it works with your chosen software. For example, Hostinger KVM plans support various VPN solutions, providing flexibility and options for your needs.
In addition, your VPS must be accessible remotely via SSH and offer full root access to ensure a smooth installation process. At Hostinger, users can run commands on their server directly using the Browser Terminal feature.
Lastly, your system must allow TCP over port 943 and UDP on port 1194 via iptables or Uncomplicated Firewall (UFW). If you use Hostinger, you can do so by simply creating VPS firewall rules via hPanel or asking our AI assistant, Kodee, to open the necessary ports on your server.

Before proceeding with the VPN server installation, we recommend reading the OpenVPN documentation to learn more about the protocol.
To manually set up OpenVPN on a Linux server, connect to your system using an SSH client like PuTTY or Hostinger’s Browser terminal. Find the login credentials under the SSH access tab on hPanel’s VPS overview menu.
Important! Instead of using root, switch to another account with superuser privileges when managing your server to avoid accidental destructive command execution.
Then, run the installation commands depending on your distribution:
Ubuntu and Debian derivatives
sudo apt update
sudo apt -y install ca-certificates wget net-tools gnupg
wget -qO - https://as-repository.openvpn.net/as-repo-public.gpg | apt-key add -
echo "deb http://as-repository.openvpn.net/as/debian focal main">/etc/apt/sources.list.d/openvpn-as-repo.list
sudo apt update && apt -y install openvpn-as
CentOS and RHEL derivatives
OpenVPN installation for CentOS is simpler because it only consists of two commands:
yum -y install https://as-repository.openvpn.net/as-repo-centos9.rpm
yum -y install openvpn-as
Remember, the package URL differs if you are using other Red Hat Enterprise Linux (RHEL) derivatives.
Once the installation is complete, you will see the Admin UI and the Client UI details. Remember the password since you will use it to log in.
Installing OpenVPN might be complicated for VPS or Linux beginners as it requires executing various commands. However, Hostinger users can easily do so in one click using an operating system template, which is bundled with an application or control panel.
In addition to being simple, this method is safer since you won’t run wrong commands that might break your server. We provide different VPS operating system templates pre-installed with various software.
For example, we offer the Ubuntu 22.04 64bit with OpenVPN template. Follow these steps to install it:

Wait until the process is complete, which should take a few minutes. During the installation, you can’t access or modify your server.
Warning! Back up your VPS data before changing or reinstalling its operating system as the process will wipe all the data.
Remember, you can only use Ubuntu 22.04 if you install OpenVPN using this method. To run other distributions, you must set up the application and operating system separately using commands.
Regardless of the installation method, you must configure the OpenVPN settings and account via the admin dashboard to complete the setup process. Here are the steps:
If you see the Your connection is not private error, an SSL certificate may not be installed on the VPS server. Click Continue to the site to proceed to the web interface.
Important! Keep in mind that the free version of OpenVPN allows up to two concurrent connections only.
A VPN tunnel is an encrypted connection between your device and the VPN. Follow these steps to enable it:
echo 'net.ipv4.ip_forward=1' | sudo tee -a /etc/sysctl.d/99-sysctl.conf
sudo sysctl -p
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo cd /etc/sysctl.d/
sudo nano 99-sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
sysctl -p
#::1 localhost ip6-localhost ip6-loopback
Now that the server is running, users can connect devices to it. We’ll cover the most popular operating system options: Windows, macOS, Linux, Android, and iOS.
The client installation for Linux differs from Windows and macOS since it requires commands. Open Terminal by pressing Ctrl + Alt + T and follow these steps:
sudo apt-get install openvpn
Meanwhile, run the following if you use CentOS 9 Stream or older:
sudo yum install openvpn
sudo service openvpn start
To connect to your OpenVPN Linux server from an Android device, open Google Play and install the OpenVPN Connect application.
Import a profile by entering the VPN server client URL, namely your VPS IP address with the OpenVPN port. Then, enter the following details:
Alternatively, use the client UI to import the OVPN file, which you must create first using the template within the /etc/openvpn/easy-rsa directory on your VPS.

To connect the OpenVPN client on iOS, download the OpenVPN Connect application from the App Store. Open the application and fill in all the required profile information or upload the profile file.
Refer to the previous section for the complete steps since configuring OpenVPN Connect on iOS is similar to Android.
Now that the VPN Access Server is running, check its configuration settings to ensure it works properly.
If you are connected to the VPN but cannot browse the Internet, check the OpenVPN logs at /var/log/openvpnas.log on the Access Server VPS.
If you find entries similar to the ones below, you are likely experiencing compression issues:
2022-03-23 18:24:05+0800 [-] OVPN 11 OUT: 'Mon Mar 23 08:59:05 2016 guest/123.45.67.89:55385 Bad compression stub decompression header byte: 251'
Resolve this error by disabling compression:
Although you can create multiple accounts, the free OpenVPN client supports two concurrent user connections. You must purchase the paid plan to enable more users to use the server.
To add and manage users, open the Admin dashboard and follow these steps:
OpenVPN lets you configure auto-login profiles, which will automatically route all non-local traffic via the VPN.
To set up auto-login, open the Admin dashboard and select User Permissions. Then, check the Allow Auto-login box on the profile you want to modify.
Alternatively, use User or Server-locked profiles to manually enable or disable the VPN.
Connect to the VPN client and check your IP to see if the OpenVPN server works as expected. You can use online tools like NordVPN’s What is My IP to check whether your IPv4 address changes.
Next, run a DNS leak test to check your OpenVPN server’s IPv4 address. On the website, choose the Extended test. The output should show the client devices’ DNS resolver IPs.
In addition, ensure the traffic uses the IPv4 protocol using Test your IPv6. The tool should display the server IP and a message stating that no IPv6 address was detected.
Setting up a VPN server can be beneficial, especially if you want to encrypt internet traffic and browse safely. In this article, we have explained how to configure one in a Linux VPS using OpenVPN.
To do so, download and install the software package using your package manager commands, like APT for Debian or yum for CentOS. Alternatively, Hostinger users can set it up in one click using a VPS template via hPanel.
We’ve also shown the OpenVPN server configuration procedure and client installations on various operating systems, including Windows, Linux, Android, iOS, and macOS.
We hope that you found this tutorial helpful. In case you have any questions, let us know in the comments section below.