6.14 Installation and configuration of the OpenVPN server
OpenVPN is reliable open-source software for creating secure VPN tunnels. It allows secure data transmission through public networks by encrypting all traffic.
Using a VPN server provides the ability to securely connect to corporate networks remotely, bypass geographical restrictions, and protect personal data when working through public Wi-Fi networks.
Today, OpenVPN is considered one of the most secure VPN solutions due to its use of reliable encryption algorithms and open source code that is continuously reviewed by the community.
Important: before starting installation, make sure You have the following privileges:
- You have root access to the server.
- Your server has a static IP address.
- Required ports are open on the server (UDP 1194 by default).
- The system is updated to the latest version.
Installation Procedure
The OpenVPN installation process depends on the operating system. Before starting installation, it’s important to ensure that the system meets all necessary requirements and has sufficient resources for stable VPN server operation.
OpenVPN installation includes not only copying files but also configuring system security, creating certificates, and setting up network parameters. It’s important to perform all steps sequentially and carefully, as errors at this stage can lead to security or server functionality issues.
Installation on Debian/Ubuntu:
- System update:
- Installing OpenVPN and easy-rsa utility:
- PKI setup:
Installation on CentOS/AlmaLinux/RockyLinux:
- System update:
- Adding EPEL repository:
- Installing OpenVPN:
- Preparing directories:
PKI and Certificate Preparation
Public Key Infrastructure (PKI) is a critically important component of OpenVPN security. It provides creation and management of digital certificates used for authentication and connection encryption. Easy-RSA is a PKI management utility that allows easy creation of certificates for servers and clients.
During PKI setup, the following are created:
- Root certificate (CA) for signing other certificates
- Server certificate and private key
- Diffie-Hellman parameters for secure key exchange
- Additional TLS key for DOS attack protection
Execute the following commands in sequence. During execution, one of the following actions may occur:
- Action confirmation. If a confirmation prompt appears, enter
yes
and press Enter. - Password entry. Some commands may require a password. Remember that during password entry, characters are not displayed in the console. Simply enter the password and press
Enter
. - Username or
commonName
request. In some cases, the system may request a username or commonName value. This can be the server or client name. Enter the desired value (for example, server for the server or client1 for the client) and pressEnter
.
Server Configuration
This stage includes creating the main OpenVPN configuration file, which defines server operation parameters, including protocol, port, encryption and authentication methods, as well as network settings for clients.
Creating basic configuration:
Next, we prepare the operating system for working with the VPN server, including IP forwarding configuration, which allows packet transmission between different network interfaces, which is necessary for VPN functionality.
Enabling IP forwarding (for all OS):
Firewall Configuration
Firewall configuration includes creating rules for filtering incoming and outgoing traffic, setting up NAT (Network Address Translation) to provide client access to external resources, and configuring traffic routing between different network interfaces.
In this section, we’ll look at configuring different types of firewalls, including traditional iptables, UFW (Uncomplicated Firewall) for Ubuntu/Debian, and firewalld for CentOS. Each of these tools has its own features and advantages, so the choice of a specific solution depends on Your needs and administration experience.
Iptables Configuration:
Important: replace eth0
with Your actual network interface.
- NAT and forwarding configuration:
- Saving Iptables rules.
For Debian/Ubuntu:
For CentOS/AlmaLinux/RockyLinux:
UFW on Ubuntu/Debian:
- UFW Configuration:
- Forwarding configuration:
Firewalld on CentOS/AlmaLinux/RockyLinux:
- Basic settings:
- Forwarding configuration:
- Applying changes:
Client Certificate Generation
- Generating certificates for the client:
- Creating client configuration:
- Adding certificates to configuration:
Starting the Server
For Debian/Ubuntu:
For CentOS/AlmaLinux/RockyLinux:
Information: how to check service status:
Computer Connection
Setting up OpenVPN on a personal computer provides secure remote access to corporate resources and protected connection when working through public networks. The setup process differs depending on the operating system, but the general principles remain the same.
Windows
Connecting on Windows computers can be done using the official OpenVPN GUI client. This client offers a convenient graphical interface for managing VPN connections and supports all modern Windows versions. The setup process includes installing the program and importing configuration files.
-
Client installation:
- Download the OpenVPN client.
- Run the installer and follow the standard installation steps.
-
Setup:
- Move configuration files to
C:\Users\Your_User\OpenVPN\config\
orC:\Program Files\OpenVPN\config\
. - Required files (may need 1 to 4 files, depending on server settings):
- Configuration (
*.ovpn
). - Client certificate (
*.crt
). - Private key (
*.key
). - CA certificate (
ca.crt
).
- Configuration (
- Move configuration files to

Information: for convenience, You can create a separate folder for each configuration.
- Connection:
- Launch the OpenVPN GUI client.
- Right-click on the icon in the system tray.
- Select
Connect
.
Linux
Linux provides flexible options for configuring OpenVPN through both command line and graphical interface. Thanks to built-in OpenVPN support in most distributions, the setup process usually doesn’t cause difficulties for users familiar with Linux systems.
Terminal Installation:
- Terminal configuration:
- Starting connection:
Graphical Interface Installation:
- Install Network Manager OpenVPN plugin:
- Open network settings.
- Add VPN connection.
- Import
.ovpn
file.
MacOS
For MacOS users, You can use a special version of OpenVPN Connect that fully integrates with the system and provides a simple and reliable way to manage VPN connections. The application supports all modern MacOS versions and offers an intuitive interface.
-
Installation:
- Download OpenVPN Connect
- Run the installer and follow standard installation steps.
-
Setup:
- Open OpenVPN Connect.
- Click
+
to add a profile. - Import the
.ovpn
file by dragging or through theBrowse
menu. - Enter necessary credentials.
- Save the profile.
Here’s the text translated into Russian while maintaining the specified formatting:
Подключение на мобильных устройствах
Мобильные устройства стали важной частью нашей жизни, поэтому безопасный доступ к сети через VPN на смартфонах и планшетах может понадобиться для защиты данных. OpenVPN предлагает официальные клиенты для всех популярных мобильных платформ.
Важно: большинство бесплатных мобильных клиентов OpenVPN не поддерживают протокол tap
, который используется по умолчанию. Чтобы избежать проблем, настройте сервер OpenVPN для работы с протоколом tun
.
Android
OpenVPN Connect для Android обеспечивает надежный и безопасный способ подключения к VPN-серверам. Приложение доступно через Google Play Market и поддерживает широкий спектр Android-устройств, включая смартфоны и планшеты различных производителей. Интерфейс программы оптимизирован для удобного использования на мобильных устройствах.
-
Установка:
- Загрузите OpenVPN Connect из Google Play Market.
-
Настройка:
- Перенесите
.ovpn
файл на устройство. - Откройте OpenVPN Connect.
- Нажмите
+
и выберите способ импорта:URL
илиUpload File
.
- Перенесите
- Мы используем
Upload File
, нажимаемBrowse
для выбора файла конфигурации
- Найдите и выберите ранее загруженный
.ovpn
файл. - Введите название подключения (
Profile Name
) и учетные данные (Username
иPassword
).
iOS
OpenVPN Connect для iOS разработан с учетом особенностей экосистемы Apple и обеспечивает бесперебойную работу на iPhone и iPad. Приложение полностью соответствует требованиям безопасности App Store и интегрируется с системными настройками iOS для максимального удобства использования.
-
Установка:
- Загрузите OpenVPN Connect из App Store.
-
Настройка:
- Импортируйте профиль одним из способов:
- Через файл
.ovpn
(iCloud, Dropbox). - Через URL подключения.
- Через прямой импорт от провайдера.
- Введите название подключения и учетные данные.
- Через файл
- Импортируйте профиль одним из способов:
Важно:
- Убедитесь в наличии всех необходимых файлов сертификатов.
- Используйте только официальные источники для загрузки клиентов.
- Регулярно обновляйте программное обеспечение.
- Храните конфигурационные файлы в надежном месте.
Информируем: для получения дополнительной информации обращайтесь к официальной документации OpenVPN и документации Вашего устройства.