{"id":5465,"date":"2020-04-16T23:10:21","date_gmt":"2020-04-16T20:10:21","guid":{"rendered":"https:\/\/kifarunix.com\/?p=5465"},"modified":"2020-04-18T13:01:04","modified_gmt":"2020-04-18T10:01:04","slug":"connect-to-openvpn-using-network-manager-on-centos-8-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/connect-to-openvpn-using-network-manager-on-centos-8-ubuntu-18-04\/","title":{"rendered":"Connect to OpenVPN using Network Manager on CentOS 8\/Ubuntu 18.04"},"content":{"rendered":"\n<p>Sometimes it is easier to connect to an <a href=\"https:\/\/openvpn.net\/\" target=\"_blank\" rel=\"noreferrer noopener\">OpenVPN<\/a> server from the graphical user interface using the Network Manager. In this guide, we are going to show you how you can so easily connect to OpenVPN using Network Manager on CentOS 8\/Ubuntu 18.04.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Connect to OpenVPN using Network Manager on CentOS 8\/Ubuntu 18.04<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Install NetworkManager VPN Plugin for OpenVPN<\/h3>\n\n\n\n<p>In order to be able to connect to create OpenVPN network profile and connect to an OpenVPN server via gui, you need to install NetworkManager vpn plugin for OpenVPN which provides the necessary software for integrating VPN capabilities with the OpenVPN server with NetworkManager.<\/p>\n\n\n\n<p>On Ubuntu 18.04, the NetworkManager VPN plugin is available on the default repos and can be installed by running the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install network-manager-openvpn<\/code><\/pre>\n\n\n\n<p>On CentOS 8, you need to install EPEL repos to enable you install the NetworkManager VPN plugins;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install epel-release<\/code><\/pre>\n\n\n\n<p>Then install install the plugins;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install NetworkManager-openvpn<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install NetworkManager VPN Plugin for GNOME<\/h3>\n\n\n\n<p>Apart from the OpenVPN NetworkManager plugin installed above, you as well need the plugin which provides GNOME bits of NetworkManager&#8217;s OpenVPN plugin otherwise you may get an error, <strong><code>Unable to load VPN connection editor<\/code><\/strong>, while adding OpenVPN connection profile.<\/p>\n\n\n\n<p>On Ubuntu 18.04, you can install GNOME OpenVPN Network Manager plugin by running the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install network-manager-openvpn-gnome<\/code><\/pre>\n\n\n\n<p>On CentOS 8, you as well need EPEL repos to install GNOME network manager openvpn plugin. Since we already installed them, you can simply execute the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install NetworkManager-openvpn-gnome<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Obtain OpenVPN Configuration File<\/h3>\n\n\n\n<p>In most cases, you would usually receive the <strong>CA certificate<\/strong>, the respective<strong> client certificate and key<\/strong>, the <strong>HMAC authentication key<\/strong>, below are examples of these files in the respective order for user koromicha that were generated on an OpenVPN server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ca.crt\nkoromicha.crt\nkoromicha.key\nta.key<\/code><\/pre>\n\n\n\n<p>It is also possible to receive an OpenVPN configuration file (.ovpn) with all the above file contents put in-line.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>koromicha.ovpn<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Connect to OpenVPN using Network Manager on CentOS 8\/Ubuntu 18.04<\/h3>\n\n\n\n<p>Both CentOS 8 and Ubuntu 18.04 uses Gnome display environment by default and thus, how you connect to OpenVPN using NetworkManager is similar.<\/p>\n\n\n\n<p>Launch the Network Settings and click the plus sign (+) on VPN section to add the VPN connection. You should see such a screen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"544\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/add-vpn.png\" alt=\"Connect to OpenVPN using Network Manager on CentOS 8\/Ubuntu 18.04\" class=\"wp-image-5469\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/add-vpn.png?v=1587067055 973w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/add-vpn-768x429.png?v=1587067055 768w\" sizes=\"(max-width: 973px) 100vw, 973px\" \/><\/figure>\n\n\n\n<p>Two things here: if you have, the CA cert, the client cert and the client key in separate files, click <strong><code>OpenVPN<\/code><\/strong> otherwise click <strong><code>Import from file...<\/code><\/strong> as commented in the screenshot above.<\/p>\n\n\n\n<p>When you click OpenVPN, such a screen as in below screenshot opens up. Set the name of the VPN connection, enter the VPN server IP and port on the Gateway bar, choose TLS Certificates for authentication type, import the CA cert, the client cert and the client key.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"815\" height=\"637\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/import-vpn-files.png\" alt=\"Connect to OpenVPN using Network Manager on CentOS 8\/Ubuntu 18.04\" class=\"wp-image-5470\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/import-vpn-files.png?v=1587067136 815w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/import-vpn-files-768x600.png?v=1587067136 768w\" sizes=\"(max-width: 815px) 100vw, 815px\" \/><\/figure>\n\n\n\n<p>Pay attention to <strong>HMAC authentication<\/strong> (the use of <strong>ta.key<\/strong>). If your OpenVPN Server HMAC authentication enabled, click <strong>Advanced<\/strong> settings.<\/p>\n\n\n\n<p>Click <strong>Security tab<\/strong> and set the HMAC algorithm to the value defined on the OpenVPN server.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"794\" height=\"357\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/hmac-algorithm.png\" alt=\"Connect to OpenVPN using Network Manager on CentOS 8\/Ubuntu 18.04\" class=\"wp-image-5471\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/hmac-algorithm.png?v=1587067181 794w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/hmac-algorithm-768x345.png?v=1587067181 768w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/figure>\n\n\n\n<p>Click on <strong>TLS Authentication<\/strong> tab and under additional TLS authentication or encryption, choose <strong>TLS Auth<\/strong>, select the <strong>ta.key<\/strong> file and set Key direction to <strong>1<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"783\" height=\"656\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/hmac-tls-auth.png\" alt=\"\" class=\"wp-image-5472\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/hmac-tls-auth.png?v=1587067215 783w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/hmac-tls-auth-768x643.png?v=1587067215 768w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/figure>\n\n\n\n<p>Click Ok when finished.<\/p>\n\n\n\n<p>Ensure that the configurations sync with what is defined on the OpenVPN server configuration. Otherwise, connection will fail.<\/p>\n\n\n\n<p>Once done, click <strong>Add<\/strong> to create VPN connection when done setting up the options.<\/p>\n\n\n\n<p>Connect to VPN by toggling the ON\/OFF switch button or from network connection icon.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"363\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/04\/turn-on-vpn.png\" alt=\"\" class=\"wp-image-5473\" title=\"\"><\/figure>\n\n\n\n<p><strong>On CentOS 8, if SELinux is enforcing, the VPN interface may fail to turn on. Be sure to check the logs<\/strong>.<\/p>\n\n\n\n<p>You can check assigned IP address;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;koromicha@centos8 ~]$ ip add show tun0\n5: tun0: &lt;POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100\n    link\/none \n    inet 10.8.0.3\/24 brd 10.8.0.255 scope global noprefixroute tun0\n       valid_lft forever preferred_lft forever\n    inet6 fe80::d4c6:3ff0:e4e6:ee04\/64 scope link stable-privacy \n       valid_lft forever preferred_lft forever<\/code><\/pre>\n\n\n\n<p>If you have a <code><strong>.ovpn<\/strong><\/code> config file, you can simly click <strong>Import from file<\/strong>. All other settings will be populates automatically.<\/p>\n\n\n\n<p>You can as well use the <code><strong>openvpn<\/strong><\/code> or <code><strong>nmcli<\/strong><\/code> command to connect to VPN.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo openvpn --config koromicha.ovpn<\/code><\/pre>\n\n\n\n<p>To use NMCLI command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>nmcli connection import type openvpn file koromicha.ovpn<\/code><\/pre>\n\n\n\n<p>Check the connection;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>nmcli con s<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>NAME                UUID                                  TYPE      DEVICE \nWired connection 1  ae6debaf-8fdd-34b5-8b6c-52e04b7b9e0e  ethernet  enp0s3 \n<strong>koromicha           474ef516-f077-4570-b87e-17342551400d  vpn       --  <\/strong>  <\/code><\/pre>\n\n\n\n<p>Bring up the VPN connection;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo nmcli con up koromicha<\/code><\/pre>\n\n\n\n<p>When you bring it up, it creates a tun Interface with VPN IP;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>nmcli con s<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>NAME                UUID                                  TYPE      DEVICE \nWired connection 1  ae6debaf-8fdd-34b5-8b6c-52e04b7b9e0e  ethernet  enp0s3 \nkoromicha           474ef516-f077-4570-b87e-17342551400d  vpn       enp0s3 \n<strong>tun0                bb8044ed-90f3-4dd6-9ff0-86180edba4c6  tun       tun0<\/strong><\/code><\/pre>\n\n\n\n<p>Great, That is all on how to connect to OpenVPN using Network Manager on CentOS 8\/Ubuntu 18.04. Enjoy.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/assign-static-ip-addresses-for-openvpn-clients\/\" target=\"_blank\" rel=\"noreferrer noopener\">Assign Static IP Addresses for OpenVPN Clients<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/install-and-configure-openvpn-client-on-centos-8-ubuntu-18-04\/\" target=\"_blank\">Install and Configure OpenVPN Client on CentOS 8\/Ubuntu 18.04<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/setup-openvpn-server-on-centos-8\/\" target=\"_blank\">Setup OpenVPN Server on CentOS 8<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/connect-to-cisco-vpn-using-pcf-file-on-ubuntu\/\" target=\"_blank\">Connect to Cisco VPN Using PCF file on Ubuntu<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-and-setup-openvpn-server-on-fedora-29-centos-7\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install and Setup OpenVPN Server on Fedora 29\/CentOS 7<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes it is easier to connect to an OpenVPN server from the graphical user interface using the Network Manager. In this guide, we are going<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,282,34,321],"tags":[1142,1437,1438,1435,1439,67],"class_list":["post-5465","post","type-post","status-publish","format-standard","hentry","category-howtos","category-openvpn","category-security","category-vpn","tag-centos-8","tag-nmcli-connect-openvpn","tag-openvpn-centos-8","tag-openvpn-gnome-network-manager","tag-openvpn-ubuntu-18-04","tag-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/5465"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=5465"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/5465\/revisions"}],"predecessor-version":[{"id":5486,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/5465\/revisions\/5486"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=5465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=5465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=5465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}