UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    VPN: import OpenVPN and WireGuard configurations using NetworkManager 'nmcli'

    Scheduled Pinned Locked Moved Support
    8 Posts 5 Posters 6.4k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LuksusL Offline
      Luksus
      last edited by Luksus

      I encountered a new method for creating VPN connections, at least "new" for me, and I thought I share it here, since it seems to be very easy to be successful.

      Using the commandline interface nmcli for NetworkManager, It is possible to import configuration files for OpenVPN and WireGuard (that are the ones I tested).
      So if you have a *.ovpn or wireguard *.conf configuration file, simply open the terminal and type:

      OpenVPN:

      sudo nmcli connection import type openvpn file /path/to/your/file.ovpn
      Now you also should have access to this connection in the settings app and there you can add maybe required username and password, if needed.

      WireGuard

      For WireGuard you should rename your config-file to wg0.conf, otherwise nmcli is complaining about wrong interface name.
      sudo nmcli connection import type wireguard file /path/to/your/wg0.conf
      The Wireguard connection does not appear in the settings app.
      The newly created interface is getting activated immediately and also at reboots. For de-/activating it, you also need to use terminal-commands:

      • Bring it up: nmcli c up wg0
      • Shut it down: nmcli c down wg0

      nmcli general

      The configurations are stored at /etc/NetworkManager/system-connections.

      • watch a configuration file using sudo, for example: sudo cat /etc/NetworkManager/system-connections/wg0.nmconnection.
      • view all connections: nmcli c
        Active connections are at the top and colored
      • Enable/Disable autoconnect: sudo nmcli c modify wg0 autoconnect no (or yes for enabling it again)

      So, for me that method was a lot easier to setup my VPNs, than using the system-settings app only, i.e. for OpenVPN with 3 different certificates plus private key and tls options... and of course for setting up wireguard at all.
      I could imagine, since wireguard works with nmcli, it even should be possible (with moderate development-input) to make the settings-app also recognize the wireguard-connections, to display and toggle them using the UI.

      Devices: BQ e4.5, Fairphone 2, Fairphone 3, Lenovo X605F, Pinephone, Moto Z2 Force, OnePlus5T

      D K S 3 Replies Last reply Reply Quote 2
      • D Offline
        domubpkm @Luksus
        last edited by

        @Luksus Hello. Do you confirm that your method works using cellular data with a focal smartphone ? (with system parameters, proton vpn config works only using wifi). Regards.

        LuksusL 1 Reply Last reply Reply Quote 0
        • LuksusL Offline
          Luksus @domubpkm
          last edited by

          @domubpkm Yes, it does work for me on cellular. But I have only connections to my homeserver, not any public one like protonVPN.

          Devices: BQ e4.5, Fairphone 2, Fairphone 3, Lenovo X605F, Pinephone, Moto Z2 Force, OnePlus5T

          1 Reply Last reply Reply Quote 0
          • CiberSheepC CiberSheep moved this topic from General on
          • danfroD Offline
            danfro
            last edited by

            Quite an interesting combination gives this terminal command vpn setup and the option described recently here to add commands to drawer icons. I assume (haven't tested yet), that we could turn vpn on and off with this.

            LuksusL 1 Reply Last reply Reply Quote 1
            • LuksusL Offline
              Luksus @danfro
              last edited by

              @danfro since the system itself can already "hold" the wireguard connections, the better way would be, to modify the settings app and network indicator, to just display the wireguard connection-type, and make it at least switchable.

              But I did not have the time to look into it.

              Devices: BQ e4.5, Fairphone 2, Fairphone 3, Lenovo X605F, Pinephone, Moto Z2 Force, OnePlus5T

              danfroD 1 Reply Last reply Reply Quote 0
              • danfroD Offline
                danfro @Luksus
                last edited by

                @Luksus I agree. Adding it to system settings is the preferred solution. I thought more of a temporary solution until that hopefully happens.

                1 Reply Last reply Reply Quote 2
                • K Offline
                  kimo @Luksus
                  last edited by kimo

                  @Luksus @danfro
                  I tried it and it worked. This is great. I hope it is integrated into the VPN settings. It is simple and makes things much easier. This is a request. I hope you will consider it. Thank you.

                  1 Reply Last reply Reply Quote 0
                  • K kimo referenced this topic on
                  • S Offline
                    slimjim @Luksus
                    last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • N nogoogle referenced this topic

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • First post
                      Last post