OpenVPN3 quick usage

OpenVPN3 Client Quick Usage Guide

A streamlined guide to get your VPN tunnel up and running in minutes.

OpenVPN3 is the next-generation command-line client for managing OpenVPN connections on Linux systems. It offers a more unified and user-friendly interface compared to the classic openvpn client, with better session management and system integration.

This guide focuses on using the OpenVPN3 client on Ubuntu 24.04.


1. Installing OpenVPN3

1.1 Add the Official Repository

Install the OpenVPN repository key used by the OpenVPN 3 Linux packages:

1
sudo mkdir -p /etc/apt/keyrings && curl -fsSL https://packages.openvpn.net/packages-repo.gpg | sudo tee /etc/apt/keyrings/openvpn.asc

Add the proper repository for Ubuntu 24.04 (Noble):

1
echo "deb [signed-by=/etc/apt/keyrings/openvpn.asc] https://packages.openvpn.net/openvpn3/debian noble main" | sudo tee /etc/apt/sources.list.d/openvpn-packages.list

1.2 Install OpenVPN3

Update package lists and install:

1
2
sudo apt update
sudo apt install openvpn3

2. Configuration Setup

Before starting a connection, you’ll need your VPN provider’s configuration file (usually a .ovpn or .conf file) along with your username and password.

Tip: Create a dedicated folder, such as ~/openvpn, to organize these files.

2.1 Create a Credential File

To avoid entering credentials manually each time, create a secure credential file:

1
nano ~/openvpn/credential

Add your username and password (each on a separate line):

1
2
your_username
your_password

Set appropriate permissions:

1
chmod 600 ~/openvpn/credential

2.2 Modify the Configuration File

Edit your .ovpn file to reference the credential file:

1
nano ~/openvpn/client.ovpn

Locate the auth-user-pass line and modify it to use an absolute path:

1
auth-user-pass /home/your_username/openvpn/credential

Important: Always use absolute paths; relative paths like ~/credential won’t work.

2.3 Import the Configuration

Import your configuration with a persistent profile name:

1
openvpn3 config-import --config ~/openvpn/client.ovpn --name myvpn --persistent
  • --config: Path to your .ovpn file
  • --name: A unique profile identifier (e.g., myvpn) for connection management
  • --persistent: Ensures the profile persists across system reboots

2.4 Enable Compression (Optional)

To potentially improve performance on slower connections:

1
openvpn3 config-manage --config myvpn --allow-compression yes

3. Connection Management

3.1 Start a VPN Connection

Establish a VPN session:

1
openvpn3 session-start --config myvpn

The connection will run in the foreground. To run it as a background daemon instead:

1
openvpn3 session-start --config myvpn --daemon

3.2 Create Command Aliases (Optional)

Add these aliases to your ~/.bashrc file for convenience:

1
2
3
# Add to ~/.bashrc
alias vpn_up='openvpn3 session-start --config myvpn'
alias vpn_down='openvpn3 session-manage --config myvpn --disconnect'

Reload your configuration and use the shortcuts:

1
2
3
source ~/.bashrc
vpn_up # Connect to VPN
vpn_down # Disconnect from VPN

3.3 Monitor Active Sessions

Check current VPN connections:

1
openvpn3 sessions-list

This displays session details including unique identifiers and connection timestamps.


4. Additional Commands

Action Command
List imported profiles openvpn3 configs-list
Remove a configuration openvpn3 config-remove --config myvpn

Reference


OpenVPN3 quick usage
https://dyliu0312.github.io/blog.github.io/2025/12/09/OpenVPN3-quick-usage/
Author
dyliu
Posted on
December 9, 2025
Licensed under