« Go Back

Managing Linux VPN Configurations Print

  • VPN, VPN Configuration, VPN Profile
  • 34

How do I manage my VPN configurations in Linux?

 

Managing a Running Session

Once a VPN session has started, it should be seen in the session list: openvpn3 sessions-list

Using the openvpn3 session-manage there are a few things which can be done, but most typically it is the –disconnect or –restart alternatives which are most commonly used. openvpn3 session-manage --config ${CONFIGURATION_PROFILE_NAME} --restart. This disconnects and re-connects to the server again, re-establishing the connection. The ${CONFIGURATION_PROFILE_NAME} is the configuration name as displayed in openvpn3 sessions-list

 

It is also possible to use the D-Bus path to the session as well: openvpn3 session-manage --session-path /net/openvpn/v3/sessions/..... --disconnect. This command above will disconnect a running session. Once this operation has completed, it will be removed from the openvpn3 sessions-list overview. Important: you will be able to start a new session with this or another OpenVPN profile only after you have disconnected from the current session using the command in this step

 

It is also possible to retrieve real-time tunnel statistics from running sessions: openvpn3 session-stats --config ${CONFIGURATION_PROFILE_NAME} or openvpn3 session-stats --session-path /net/openvpn/v3/sessions/...

And to retrieve real-time log events as they occur, run the following command: openvpn3 log --config ${CONFIGURATION_PROFILE_NAME}. This might be quite silent, as it does not provide any log events from the past. Issue an openvpn3 session-manage –restart from a different terminal, and log events will occur. You may want to boost the log-level with –log-level 6. Valid log levels are from 0 to 6, where 6 is the most verbose. Note: VPN sessions are also owned by the user which started it. But the Session Manager also provides its own Access Control List feature via openvpn3 session-acl.

Changing the OpenVPN Profile of an Autoloading VPN Session

 

Please note that every time you start a session, it will load automatically on the system start-up. In order to change the profile of an OpenVPN Session that is autoloaded, follow the steps below:

 

Run the command: sudo openvpn3 sessions-list. It will show information about your active session. Check the value of Path parameter

 

Run the command: sudo openvpn3 session-manage --session-path YOUR_PATH --disconnect, where YOUR_PATH is the value of Path parameter from Step 1

 

Run the command: sudo openvpn3 sessions-list. You shouldn’t see any active sessions

 

Run the command: sudo openvpn3 configs-list. It will show information about your active configurations. Check the name assigned to your active config. In this case, this is OpenVPN Cloud

 

Run the command: sudo openvpn3 config-remove --config "YOUR_CONFIG_NAME", where YOUR_CONFIG_NAME is the name of the configuration file from Step 4. You will be asked to confirm the removal of the configuration. Type YES (in uppercase) to confirm

 

Run the command: sudo openvpn3 configs-list. You shouldn’t see any active configurations

 

Run the command: sudo nano /etc/openvpn3/autoload/connector.conf. This is the profile that will be replced. Notice that it uses the eu-central region

 

Press ctrl + End, then hold ctrl + shift + ↑ until the whole file is highlighted, and finally press ctrl + K

 

Open the OpenVPN profile you wish to use instead of the existing one. Press ctrl + A and then ctrl + C. Notice that it uses the ca-east region

 

Then go back to the Terminal, and press the right mouse button and choose Paste. Notice the difference between the old and the new profile

 

Once you’ve replaced the profile, press ctrl + X and confirm changes by typing y and pressing Enter

You can run cat /etc/openvpn3/autoload/connector.conf to check the changes are saved

 

Run the command: sudo openvpn3 config-import --config /etc/openvpn3/autoload/connector.conf --name "OpenVPN Cloud"

 

Run the command: sudo openvpn3 session-start --config "OpenVPN Cloud"

 

Run the command: sudo openvpn3 sessions-list. It will show that a new session is active and connected to the ca-east region, that of the new profile

 

Restart the computer and check if the autostart profile has indeed been changed. Just run the sudo openvpn3 sessions-list command once again. Indeed, the autoload is now set for the new profile!


Was this answer helpful?