OpenVPN 3 Linux

repository·master·Indexed 20 days ago

https://github.com/openvpn/openvpn3-linux

A modern VPN platform for Linux featuring a service-oriented architecture with privilege separation and D-Bus communication. It provides session management via the openvpn3, openvpn2, and openvpn3-admin CLI utilities. Key features include support for Routed TUN, Kernel-based Data Channel Offload (DCO) for improved throughput, and Device Posture Checks (DPC) using Enterprise Profiles. The platform supports integration with systemd-resolved and provides specific SELinux policy modules for secure TUN device management.

Tokens
47.8K
Snippets
136
Records
185
Agent score
70%

What's inside openvpn3-linux

  1. Use the openvpn3 CLI for management and configuration

    master

    The openvpn3 utility is the primary command-line interface for managing OpenVPN 3 Linux. It uses a command-based syntax where the first argument is a command operator, followed by specific options for that command.

    General usage patterns:

    • To see the version: openvpn3 version
    • To see help for the main utility: openvpn3 --help or openvpn3 help
    • To see help for a specific command: openvpn3 [COMMAND] --help
    openvpn3 [ COMMAND ] [ OPTIONS ]
  2. Use the openvpn2 CLI wrapper

    master

    The openvpn2 command is a wrapper for OpenVPN 3 Linux designed to provide a command-line interface similar to the classic OpenVPN 2.x releases.

    Important Limitations:

    • Client Only: OpenVPN 3 Linux currently only supports client-side functionality. All server-side options are unavailable.
    • Option Compatibility: Because OpenVPN 3 does not support all OpenVPN 2.x options, some flags may be ignored or unavailable.
    • No External Scripts: Unlike OpenVPN 2.x, OpenVPN 3 does not execute external scripts (e.g., via --up or --down) for security reasons. Instead, users should use D-Bus signals to react to VPN events.
    # Basic usage
    openvpn2 [ OPTIONS ]
    
    # Show help
    openvpn2 --help
  3. Use openvpn3-service-log for log management

    master

    The openvpn3-service-log program is the internal log service for OpenVPN 3 Linux. It operates in two modes:

    1. D-Bus Service (Default): Automatically started by dbus-daemon via net.openvpn.v3.log.service when backend services need to send logs. This is the secure, production-standard mode where backend services attach directly to the log service.
    2. Stand-alone Program: Used primarily for debugging. In this mode, you must use the --signal-broadcast option (on the backend services) for this program to pick up events. Note that in this mode, any user on the system can listen to the log signals.

    By default, logs are printed to the terminal, but they can be redirected to files, syslog, or systemd-journald.

    openvpn3-service-log [OPTIONS]
  4. Overview of OpenVPN 3 Linux Architecture

    master

    OpenVPN 3 Linux differs from OpenVPN 2.x by providing full configuration and session management within the platform itself, rather than relying on external tools like Network Manager or systemd unit files.

    Key Architectural Concepts

    • Privilege Separation: The architecture splits functionality into several independently running backend services that communicate with a user front-end via D-Bus. This allows unprivileged users to manage their own VPN sessions securely.
    • Backend Services: A collection of D-Bus services that handle specific tasks like configuration management, session management, and network configuration.
    • User Front-end: The interface used by users to interact with the backend services. This project provides CLI utilities and a Python 3 module for building custom front-ends.
    • D-Bus Integration: The primary communication mechanism. Any language supporting D-Bus can be used to extend or implement new front-ends.

    Supported Configurations

    • Routed TUN: Supported.
    • TAP and Bridged: Not supported.
  5. Overview of the OpenVPN 3 Network Configuration Service

    master

    The Network Configuration Service (net.openvpn.v3.netcfg) is a D-Bus service used to manage virtual network interfaces.

    Key characteristics:

    • Access Control: This service is intended to be used and accessed exclusively by the OpenVPN 3 client service.
    • Lifecycle: The backend process is transient; it terminates automatically after a period of inactivity. It is only required while a VPN connection is active.
    • Model: The interface is conceptually similar to the Android VpnService interface, but adapted for Linux and D-Bus.
  6. How the OpenVPN 3 Session Manager works

    master

    The Session Manager is the primary D-Bus front-end interface for managing VPN tunnels. It tracks all currently running VPN tunnels and acts as a proxy, forwarding method calls and signals between independent VPN backend client processes and user front-end processes.

    It provides two main levels of interaction via D-Bus:

    1. The Global Session Manager: Located at /net/openvpn/v3/sessions, used for discovering sessions, creating new tunnels, and monitoring system-wide events.
    2. Individual Session Objects: Located at /net/openvpn/v3/sessions/${UNIQUE_ID}, used for controlling a specific tunnel (connect, disconnect, pause, etc.) and accessing its specific properties and logs.
  7. How OpenVPN 3 Autoload works

    master

    The OpenVPN 3 Autoload feature uses JSON files with the .autoload extension to store environment-specific settings (like credentials, proxies, or tunnel configurations) that are separate from the main site-independent .ovpn or .conf files.

    Requirements:

    • The .autoload file must be located in the same directory as the main configuration file.
    • The base filename must be identical to the .ovpn or .conf file (e.g., client.ovpn and client.autoload).
    • All sections and properties within the JSON are optional.
  8. Core D-Bus concepts for OpenVPN 3 Linux

    master

    D-Bus is an object-oriented Inter-Process Communication (IPC) solution used by OpenVPN 3 Linux. To interact with the service, you must understand four key components:

    1. Bus Type:
      • system bus: Strictly controlled and locked down; used for system-wide services.
      • session bus: Reachable by a single user session (e.g., a graphical desktop login).
    2. Destination (Well-known Bus Name): A human-readable string (often reversed domain name format) used to identify a service, such as net.openvpn.v3.configuration or net.openvpn.v3.backends.
    3. Object Path: A unique path within a service that identifies a specific object (e.g., /net/openvpn/v3/configuration).
    4. Interface: A collection of Methods (functions you call), Properties (variables you read/write), and Signals (asynchronous events you subscribe to) available on an object.

    To successfully communicate with an OpenVPN 3 service, you must provide all four: the correct bus, the destination name, the object path, and the specific interface.

  9. Understand OpenVPN 3 Linux D-Bus logging architecture

    master

    Logging in OpenVPN 3 Linux is primarily handled via D-Bus signals. This design allows front-end implementations to decide how and when to present log information to the user.

    Key Architectural Concepts

    • Default Behavior: Log signals are sent to the net.openvpn.v3.log service (provided by openvpn3-service-log). This service automatically subscribes to log events from other services during startup, ensuring it is the primary recipient of log messages.
    • Signal Broadcast Mode: Services can be run with the --signal-broadcast argument. In this mode, log signals are broadcast to all listeners. This is not recommended for production and is intended for debugging.
    • D-Bus Policy: When using broadcast mode, the D-Bus policy (located at /etc/dbus-1/system.d/net.openvpn.v3.conf) must be updated, as the default policy restricts who can receive signals from OpenVPN 3 services.
    • File Logging: Logging to files can be managed by a separate process or activated within individual D-Bus services. Regardless of file logging, services will still emit the Log signal over the D-Bus message bus.
  10. Use the OpenVPN 3 D-Bus Backend Process Starter

    master

    The net.openvpn.v3.backends service is a specialized D-Bus service used by the session manager to initiate new backend VPN client processes (openvpn3-service-client).

    When the session manager needs to start a new VPN session, it calls this service to trigger the backend process. The service provides the necessary information for the backend client to register with the session manager and retrieve configuration profiles from the configuration manager.

    Lifecycle Note: This backend process is transient; it will automatically terminate itself after being idle for a short period. Its primary purpose is to act as a starter for the actual VPN client process.

    D-Bus destination: `net.openvpn.v3.backends` 
    Object path: `/net/openvpn/v3/backends`
  11. Create .autoload configuration files

    master

    To automate settings for a specific VPN profile, create a JSON file with the .autoload extension. This file must be located in the same directory as the main configuration file (.ovpn or .conf) and must have the same base filename.

    Example: If your profile is vpn-client.conf, your automation file must be vpn-client.autoload.

    Basic JSON Structure:

    {
       "autostart": false,
       "name": "My VPN Profile",
       "acl": {
           "public": false,
           "locked-down": false,
           "set-owner": 1000
       },
       "crypto": {
           "tls-params": {
               "cert-profile": "preferred",
               "min-version": "tls_1_2"
           }
       },
       "remote": {
           "proto-override": "udp",
           "port-override": 1194,
           "timeout": 10,
           "compression": "no",
           "proxy": {
               "host": "proxy.example.com",
               "port": 8080,
               "username": "user",
               "password": "pass",
               "allow-plain-text": false
           }
       },
       "tunnel": {
           "ipv6": "default",
           "persist": true,
           "dns-fallback": "google",
           "dns-scope": "global",
           "dns-setup-disabled": false
       },
       "user-auth": {
           "autologin": true,
           "username": "vpnuser",
           "password": "vppass",
           "pk_passphrase": "keypass",
           "dynamic_challenge": "static_response"
       }
    }