John Jerald De Chavez

OpenVPN on Arch Linux

Today, I found myself in need of connecting to a VPN using OpenVPN on my Arch Linux system. This inspired me to create a guide to help you set up OpenVPN on your own machine. In the following steps, I'll walk you through the process of establishing a VPN connection on your Arch Linux system. Let's get started!

Requirements

To establish a VPN connection, you'll need the openvpn3 binary. To install openvpn3 using package manager yay, simply run the following command:

yay openvpn3

After installing openvpn3 try to run openvpn3 --help to ensure openvpn3 binary installed on your system.

Acess Openvpn Access Server

Ensure that you are logged in to your OpenVPN Access Server. Once logged in, click on "Yourself" (autologin profile), and this action will trigger the automatic download of the "client.ovpn" configuration file.

Connect to Openvpn

Once you have downloaded the client.ovpn file, you can import it using the following command:

openvpn3 config-import --config /path-to-your-client/client.opvpn

You can start a new VPN session:

openvpn3 session-start --config /path-to-your-client/client.opvpn

Congrats you are already connected on your vpn. In order to check your VPN session:

openvpn3 sessions-list

Result:

-----------------------------------------------------------------------------
        Path: /net/openvpn/v3/sessions/[session-name]
     Created: Thu Oct  5 16:06:41 2023                  PID: 70487
       Owner: user                                   Device: tun0
 Config name: ./path-to-your-client/client.ovpn
Session name: 13.236.220.186
      Status: Connection, Client connected

Disconnect on Openvpn

It's important to remember to disconnect from your VPN. To do so, use the following command:

openvpn3 session-manage --session-path /net/openvpn/v3/sessions/[session-name] --disconnect

To determine the flag --session-path, you can use the openvpn3 sessions-list command. After executing this command, examine the specific Path field to find the session-path information.

Reconnect to last session

To reconnect to your last session, you should already be familiar with your configuration paths. You can use the openvpn3 configs-list command to help identify the configurations available on your system. Here's an example of what the results may look like:

Configuration path
Imported                        Last used                 Used
Name                                                      Owner
------------------------------------------------------------------------------
/net/openvpn/v3/configuration/[config-name]
Thu Oct  5 15:14:16 2023        Thu Oct  5 15:20:14 2023  4
./path-to-your-client/client.ovpn                                   user

Once you have identified the configuration path, you can reconnect to the session using the following command:

openvpn3 session-start --config-path /net/openvpn/v3/configuration/[config-name]

Afterward, you can verify that you are connected to the session by running:

openvpn3 sessions-list

This will confirm your connection status within the session.

References