Updated on 2025-05-14 GMT+08:00

Ubuntu

Version Requirements

Table 1 lists the client versions supported by Ubuntu.
Table 1 Version requirements

Ubuntu Version

OpenSSL Version

OpenVPN Version

Operation Guide

24.10

3.3.1

Versions later than 2.5

Ubuntu 24.10

22.04 (Jammy)

1.1.1

2.5 or later

Ubuntu 22.04 (Jammy)

Ubuntu 24.10

  1. Log in to the Ubuntu system as the root user and open the CLI.
  2. Run the following command to back up the original configuration file of the system:

    cp -a /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak

  3. Install APT repositories.

    1. Run the following command to configure APT repositories:

      vim /etc/apt/sources.list.d/ubuntu.sources

    2. Enter the following content in the command window:
      Types: deb
      URIs: https://xxx.cn/ubuntu/
      Suites: oracular oracular-updates oracular-backports
      Components: main restricted universe multiverse
      Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
      
      Types: deb
      URIs: https://xxx.cn/ubuntu/
      Suites: oracular-security
      Components: main restricted universe multiverse
      Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

      Replace https://xxx.cn/ with the actual source.

    3. Press Esc, enter :wq, and press Enter.

      The system saves the configuration and exits the editor.

  4. Run the following command to check the current OpenVPN version:

    openvpn --version

    Information similar to the following is displayed:

    OpenVPN 2.6.12 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] [DCO]
    library versions: OpenSSL 3.3.1 4 Jun 2024, LZO 2.10
    • If the OpenVPN version is displayed, go to 5.
    • If no OpenVPN version is displayed, perform the following operations to install OpenVPN:
      1. Run the following command to install OpenVPN:

        apt install -y openvpn

        A download progress bar is displayed. When the download progress reaches 100%, the installation is complete.

        The following information is displayed:
        Installing:
          openvpn
        
        Suggested packages:
          openvpn-dco-dkms  openvpn-systemd-resolved  easy-rsa
        ...
        ...
        ...
        No services need to be restarted.
        
        No containers need to be restarted.
        
        No user sessions are running outdated binaries.
        
        No VM guests are running outdated hypervisor (qemu) binaries on this host.
      2. Run the following command again to check the OpenVPN version:

        openvpn --version

        Information similar to the following is displayed:
        OpenVPN 2.6.12 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] [DCO]
        library versions: OpenSSL 3.3.1 4 Jun 2024, LZO 2.10

  5. Download the client configuration file on a Windows system.

    1. Log in to the management console.
    2. Click in the upper left corner and select the desired region and project.
    3. Click in the upper left corner, and choose Networking > Virtual Private Network.
    4. In the navigation pane on the left, choose Virtual Private Network > Enterprise – VPN Gateways.
    5. Click the P2C VPN Gateways tab, and click Download Client Configuration in the Operation column of the target VPN gateway.

      The downloaded client configuration file is client_config.zip.

  6. Decompress client_config.zip to a specified directory, for example, D:\.

    After the decompression, the client_config.ovpn and client_config.conf files are generated.

  7. Open the client_config.conf file using Notepad or Notepad++.
  8. Add the client certificate and private key to the file.

    Enter the client certificate content and the corresponding private key in between <cert></cert> and <key></key> tags, respectively.
    <cert>
    -----BEGIN CERTIFICATE-----
    Client certificate content
    -----END CERTIFICATE-----
    </cert>
    
    <key>
    -----BEGIN PRIVATE KEY-----
    Client private key
    -----END PRIVATE KEY-----
    </key>

  9. Save the .conf configuration file.
  10. Upload the .conf configuration file to the Ubuntu system using Xftp (a file transfer tool). In this example, the file is uploaded to the /opt/ directory.
  11. On Ubuntu, run the following command to go to the directory where the client configuration file is stored:

    cd /opt/

  12. Run the following command to start the OpenVPN client and connect to the VPN gateway:

    openvpn --config /opt/openvpn_config_user-01.conf

    If the following information in bold is displayed, the OpenVPN connection is successfully established:

    2025-02-27 19:22:41 Note: Kernel support for conf-dco missing, disabling data channel offload.
    2025-02-27 19:22:41 OpenVPN 2.6.12 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] [DCO]
    2025-02-27 19:22:41 library versions: OpenSSL 3.3.1 4 Jun 2024, LZO 2.10
    ...
    ...
    ...
    2025-02-27 19:22:42 Initialization Sequence Completed
    ...
    ...

  13. Run the following command to verify the connectivity:

    ping XX.XX.XX.XX

    XX.XX.XX.XX indicates the private IP address of the ECS to be connected. Replace it with the actual private IP address.

    If information similar to the following is displayed, the client can communicate with the ECS:

    64 bytes from XX.XX.XX.XX: icmp_seq=1 ttl=63 time=1.27 ms
    64 bytes from XX.XX.XX.XX: icmp_seq=2 ttl=63 time=1.36 ms
    64 bytes from XX.XX.XX.XX: icmp_seq=3 ttl=63 time=1.40 ms
    64 bytes from XX.XX.XX.XX: icmp_seq=4 ttl=63 time=1.29 ms
    64 bytes from XX.XX.XX.XX: icmp_seq=5 ttl=63 time=1.35 ms
    64 bytes from XX.XX.XX.XX: icmp_seq=6 ttl=63 time=1.52 ms

Ubuntu 22.04 (Jammy)

  1. Log in to the Ubuntu system as the root user and open the CLI.
  2. Run the following command to install the OpenVPN client:

    yum install -y openvpn

  3. Download the client configuration file on a Windows system.

    1. Log in to the management console.
    2. Click in the upper left corner and select the desired region and project.
    3. Click in the upper left corner, and choose Networking > Virtual Private Network.
    4. In the navigation pane on the left, choose Virtual Private Network > Enterprise – VPN Gateways.
    5. Click the P2C VPN Gateways tab, and click Download Client Configuration in the Operation column of the target VPN gateway.

      The downloaded client configuration file is client_config.zip.

    6. Decompress client_config.zip to a specified directory, for example, D:\.

      After the decompression, the client_config.ovpn and client_config.conf files are generated.

    7. Open the client_config.conf file using Notepad or Notepad++.
    8. Add the client certificate and private key to the file.
      Enter the client certificate content and the corresponding private key in between <cert></cert> and <key></key> tags, respectively.
      <cert>
      -----BEGIN CERTIFICATE-----
      Client certificate content
      -----END CERTIFICATE-----
      </cert>
      
      <key>
      -----BEGIN PRIVATE KEY-----
      Client private key
      -----END PRIVATE KEY-----
      </key>
    9. (Optional) Comment out disable-dco. Perform this step only when OpenVPN 2.5 or earlier is used.
      1. Press Ctrl+F to search for and locate disable-dco.
      2. Enter # in front of the line where disable-dco is located to comment out the line.
        ...
        ...
        # disable-dco
        ...
        ...
    10. Save the .conf configuration file.

  4. Upload the .conf configuration file to the Ubuntu system using Xftp. In this example, the file is uploaded to the /etc/openvpn/conf/ directory.
  5. On Ubuntu, run the following command to go to the directory where the client configuration file is stored:

    cd /etc/openvpn/conf/

  6. Run the following command to start the OpenVPN client and connect to the VPN gateway:

    openvpn --config /etc/openvpn/conf/config.conf --daemon

    On Linux, you are advised not to modify the DNS configuration of the operating system after starting OpenVPN. Otherwise, the new DNS configuration of the operating system will be overwritten by the DNS configuration of the OpenVPN client when OpenVPN is started next time.