{"id":3735,"date":"2017-11-17T14:07:09","date_gmt":"2017-11-17T19:07:09","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=3735"},"modified":"2017-11-17T14:07:09","modified_gmt":"2017-11-17T19:07:09","slug":"install-update-openvpn-u16","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/","title":{"rendered":"How to Install &#038; Update OpenVPN on Ubuntu 16"},"content":{"rendered":"<h1>How to Install &#038; Update OpenVPN on Ubuntu 16<\/h1>\n<div class=\"row\">\n<div class=\"col-lg-8\">\n<p>Using OpenVPN allows you to securely and safely access the internet, especially when you&#8217;re connected to a public or untrusted network. OpenVPN is a solution that will enable you to create a wide array of network configurations; the configurations allow customized private network solutions that can meet a variety of needs. OpenVPN is an open-source software that employs Secure Socket Layer (SSL) protocols for additional security.<\/p>\n<\/div>\n<div class=\"col-lg-4\">\n<a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/openvpn.net\/\"><img loading=\"lazy\" decoding=\"async\" width=\"208\" height=\"54\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png\" alt=\"Update OpenVPN\" class=\"alignright size-full wp-image-3743\" \/><\/a>\n<\/div>\n<\/div>\n<p>OpenVPN allows authentication through pre-shared secret keys, certificates, or a username and password combination. Through this authentication, secure point-to-point connections are established with high-level encryption protocols.<\/p>\n<h2>Getting Started<\/h2>\n<p>When you decide to install and update OpenVPN on Ubuntu 16.04, you will first need a node running Linux Ubuntu 16.04 LTS; the node you choose can be on a <strong><a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\">cloud server<\/a><\/strong> or a <strong><a href=\"https:\/\/www.globo.tech\/dedicated-server-hosting\">dedicated server<\/a><\/strong>. It&#8217;s important to verify that your operating system is running the most recent version, including any updates or patches that may need to be installed.<\/p>\n<h2>Update OpenVPN on Ubuntu 16<\/h2>\n<p>The first step in any successful implementation is updating the system, verifying that all necessary updates have been pushed and the install itself is clean. You can check this by running the following commands:<br \/>\n<code>$ apt-get update<br \/>\n$ apt-get upgrade <\/code><\/p>\n<p>Once the updates are pushed, you can then proceed with installing OpenVPN and EasyRSA on your node:<br \/>\n<code>$ apt-get install openvpn easy-rsa <\/code><\/p>\n<p>Now that OpenVPN and EasyRSA have been installed, it&#8217;s time to set up the CA Directory and then move to it:<br \/>\n<code>$ make-cadir ~\/openvpn-ca && cd ~\/openvpn-ca <\/code><\/p>\n<p>You will need to edit the vars file to match the information you have:<br \/>\n<code>$ nano vars <\/code><br \/>\n<code class=\"gris\">export KEY_COUNTRY=\"US\"<br \/>\nexport KEY_PROVINCE=\"CA\"<br \/>\nexport KEY_CITY=\"SanFrancisco\"<br \/>\nexport KEY_ORG=\"Fort-Funston\"<br \/>\nexport KEY_EMAIL=\"me@myhost.mydomain\"<br \/>\nexport KEY_OU=\"MyOrganizationalUnit\"<\/code><\/p>\n<p>If needed or if you choose, you can edit the keyname as well:<br \/>\n<code>export KEY_NAME=\"server\"<\/code><\/p>\n<p>After setting up the directory, editing the vars file, and editing the keyname if you chose to do so, it&#8217;s time to build the CA Authority:<br \/>\n<code>$ source vars<br \/>\n$ .\/clean-all<br \/>\n$ .\/build-ca <\/code><\/p>\n<p>At this point you will receive a set of prompts, you may type Enter at each prompt.<\/p>\n<p>When the prompts have completed, it&#8217;s time to create the server certificate, the key, and the encryption files. If you opted to change the KEY_NAME value earlier, you would need to verify that you&#8217;re building the correct key at this time:<br \/>\n<code>$ .\/build-key-server server<\/code><\/p>\n<p>Make sure to accept the default entry during the build.<\/p>\n<p>Now it&#8217;s time to generate the DH Key:<br \/>\n<code>$ .\/build-dh <\/code><\/p>\n<p>After generating the DH Key, the TLS Key will need to be generated:<br \/>\n<code>$ openvpn --genkey --secret keys\/ta.key<\/code><\/p>\n<p>There are two options for building a certificate here, once that generates a password and one that does not create a password.<\/p>\n<p><strong>No Password Option<\/strong><br \/>\nIt&#8217;s time to generate a client key pair and certificate, replacing &#8220;client&#8221; with the name of your generated certificate:<br \/>\n<code>$ cd ~\/openvpn-ca<br \/>\n$ source vars<br \/>\n$ .\/build-key client<\/code><\/p>\n<p><strong>Password Option<\/strong><br \/>\nIf you would prefer to have a password assigned to your certificate during this build, follow the below commands:<br \/>\n<code>$ cd ~\/openvpn-ca<br \/>\n$ source vars<br \/>\n$ .\/build-key-pass client<\/code><\/p>\n<p>Now that the certificate has been built, with or without a password, the OpenVPN server can be configured. During this configuration, make sure to match KEY_NAME with the correct name:<br \/>\n<code>$ cd ~\/openvpn-ca\/keys<br \/>\n$ cp ca.crt server.crt server.key ta.key dh2048.pem \/etc\/openvpn<br \/>\n$ gunzip -c \/usr\/share\/doc\/openvpn\/examples\/sample-config-files\/server.conf.gz | tee \/etc\/openvpn\/server.conf<\/code><\/p>\n<p>We need to edit the openvpn.conf file to continue the configuration, following all of the steps and commands outlined below, as applicable:<br \/>\n<code>$ nano \/etc\/openvpn\/server.conf<\/code><\/p>\n<p>Once the edits are complete, it&#8217;s time to configure the server to forward traffic through the VPN:<br \/>\n<code>$ nano \/etc\/sysctl.conf<\/code><br \/>\nadd:<br \/>\n<code class=\"gris\">net.ipv4.ip_forward=1<\/code><br \/>\n<code>Reload sysctl<br \/>\n$ sysctl -p<\/code><br \/>\nFirst, we need to locate the primary interface:<br \/>\n<code>$ ip route | grep default<br \/>\ndefault via 192.168.65.254 dev eth0 onlink<\/code><\/p>\n<p>After the primary interface is located, the UFW rules will need to be altered:<br \/>\n<code>$ nano \/etc\/ufw\/before.rules<\/code><br \/>\n<code class=\"gris\"># START OPENVPN RULES<br \/>\n# NAT table rules<br \/>\n*nat<br \/>\n:POSTROUTING ACCEPT [0:0]<br \/>\n# Allow traffic from OpenVPN client to eth0 (change to the interface you discovered!)<br \/>\n-A POSTROUTING -s 10.8.0.0\/8 -o eth0 -j MASQUERADE<br \/>\nCOMMIT<br \/>\n# END OPENVPN RULES<\/code><\/p>\n<p>During this alteration, the default UFW rules will also need to be edited:<br \/>\n<code>$ nano \/etc\/default\/ufw<\/code><br \/>\n<code class=\"gris\">DEFAULT_FORWARD_POLICY=\"ACCEPT\"<\/code><\/p>\n<p>When the necessary edits are complete, it&#8217;s time to open the firewall port on OpenVPN:<br \/>\n<code>$ ufw allow 1194\/udp<br \/>\n$ ufw allow OpenSSH<br \/>\n$ ufw disable<br \/>\n$ ufw enable<\/code><\/p>\n<p>It&#8217;s time to start and enable the OpenVPN server. When the server is enabled, make sure to check the server status:<br \/>\n<code>$ systemctl start openvpn@server<br \/>\n$ systemctl enable openvpn@server<br \/>\n$ systemctl status openvpn@server<\/code><\/p>\n<p>We need to create the client configuration file, making a few minor edits and adding some comments:<br \/>\n<code>$ mkdir -p ~\/client-configs\/files<br \/>\n$ chmod 700 ~\/client-configs\/files<br \/>\n$ cp \/usr\/share\/doc\/openvpn\/examples\/sample-config-files\/client.conf ~\/client-configs\/base.conf<br \/>\n$ nano ~\/client-configs\/base.conf<\/code><br \/>\nEdit the following lines:<br \/>\n<code class=\"gris\">remote server_IP_address 1194<br \/>\nproto udp<br \/>\nuser nobody<br \/>\ngroup nogroup<\/code><br \/>\nComment out these lines by adding &#8220;#&#8221;:<br \/>\n<code class=\"gris\">#ca ca.crt<br \/>\n#cert client.crt<br \/>\n#key client.key<\/code><br \/>\nThen add:<br \/>\n<code class=\"gris\">cipher AES-128-CBC<br \/>\nauth SHA256<br \/>\nkey-direction 1<\/code><\/p>\n<p>After completing the edits and comments, you will need to create a script that generates the config file, making sure to run the following commands and include any necessary changes:<br \/>\n<code>$ nano ~\/client-configs\/make_config.sh<\/code><br \/>\nThen add:<br \/>\n<code class=\"gris\">KEY_DIR=~\/openvpn-ca\/keys<br \/>\nOUTPUT_DIR=~\/client-configs\/files<br \/>\nBASE_CONFIG=~\/client-configs\/base.conf<\/code><br \/>\n<code class=\"gris\">cat ${BASE_CONFIG} \\<br \/>\n    <(echo -e '<ca>') \\<br \/>\n    ${KEY_DIR}\/ca.crt \\<br \/>\n    <(echo -e '<\/ca>\\n<cert>') \\<br \/>\n    ${KEY_DIR}\/${1}.crt \\<br \/>\n    <(echo -e '<\/cert>\\n<key>') \\<br \/>\n    ${KEY_DIR}\/${1}.key \\<br \/>\n    <(echo -e '<\/key>\\n<tls-auth>') \\<br \/>\n    ${KEY_DIR}\/ta.key \\<br \/>\n    <(echo -e '<\/tls-auth>') \\<br \/>\n    > ${OUTPUT_DIR}\/${1}.ovpn<\/code><br \/>\nChange the permissions:<br \/>\n<code>chmod 700 ~\/client-configs\/make_config.sh<\/code><\/p>\n<p>Finally, it&#8217;s time to generate the client file:<br \/>\n<code>cd ~\/client-configs<br \/>\n.\/make_config.sh client_name<\/code><br \/>\nYou should be able to access the client file:<br \/>\n<code>ls ~\/client-configs\/files<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>Congratulations, you&#8217;ve successfully installed and updated OpenVPN on your node running Ubuntu 16.04 LTS. You&#8217;re now ready to run your OpenVPN instance and begin securely connecting and transmitting data over a variety of networks; make sure to update OpenVPN as needed or when critical updates are pushed. If you found this guide helpful, please share it with other users engaging in similar setups. <\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to Install &#038; Update OpenVPN on Ubuntu 16 Using OpenVPN allows you to securely and safely access the internet, especially when you&#8217;re connected to a public or untrusted network. OpenVPN is a solution that will enable you to create a wide array of network configurations; the configurations allow customized private network solutions that can<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74],"tags":[],"class_list":["post-3735","post","type-post","status-publish","format-standard","hentry","category-networking","operating_system-ubuntu-16-04"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Install &amp; Update OpenVPN on Ubuntu 16 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"Using OpenVPN allows you to securely access the internet, especially when you&#039;re connected to a public network. To install and update OpenVPN on Ubuntu...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install &amp; Update OpenVPN on Ubuntu 16 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"Using OpenVPN allows you to securely access the internet, especially when you&#039;re connected to a public network. To install and update OpenVPN on Ubuntu...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-17T19:07:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/\",\"name\":\"How to Install & Update OpenVPN on Ubuntu 16 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png\",\"datePublished\":\"2017-11-17T19:07:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"Using OpenVPN allows you to securely access the internet, especially when you're connected to a public network. To install and update OpenVPN on Ubuntu...\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#primaryimage\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png\",\"contentUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png\",\"width\":208,\"height\":54,\"caption\":\"Update OpenVPN\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install &#038; Update OpenVPN on Ubuntu 16\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install & Update OpenVPN on Ubuntu 16 - Globo.Tech","description":"Using OpenVPN allows you to securely access the internet, especially when you're connected to a public network. To install and update OpenVPN on Ubuntu...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/","og_locale":"en_US","og_type":"article","og_title":"How to Install & Update OpenVPN on Ubuntu 16 - Globo.Tech","og_description":"Using OpenVPN allows you to securely access the internet, especially when you're connected to a public network. To install and update OpenVPN on Ubuntu...","og_url":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/","og_site_name":"Globo.Tech","article_published_time":"2017-11-17T19:07:09+00:00","og_image":[{"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png","type":"","width":"","height":""}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/","url":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/","name":"How to Install & Update OpenVPN on Ubuntu 16 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#primaryimage"},"image":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#primaryimage"},"thumbnailUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png","datePublished":"2017-11-17T19:07:09+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"Using OpenVPN allows you to securely access the internet, especially when you're connected to a public network. To install and update OpenVPN on Ubuntu...","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#primaryimage","url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png","contentUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/11\/openvpn_logo.png","width":208,"height":54,"caption":"Update OpenVPN"},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/install-update-openvpn-u16\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to Install &#038; Update OpenVPN on Ubuntu 16"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=3735"}],"version-history":[{"count":9,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3735\/revisions"}],"predecessor-version":[{"id":3747,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3735\/revisions\/3747"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=3735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=3735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=3735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}