{"id":2577,"date":"2014-11-23T01:35:36","date_gmt":"2014-11-22T20:05:36","guid":{"rendered":"http:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/?p=44"},"modified":"2023-01-24T12:05:32","modified_gmt":"2023-01-24T06:35:32","slug":"how-to-install-configure-openvpn-on-centos-6","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/","title":{"rendered":"How to install &#038; configure OpenVPN on Centos 6"},"content":{"rendered":"<p>OpenVPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities. It uses a custom security protocol that utilizes SSL\/TLS for key exchange. It is capable of traversing network address translators (NATs) and firewalls.<\/p>\n<p>Firstly, verify if VPN interface(tun0) is created using ifconfig command:<\/p>\n<blockquote><p># ifconfig<\/p><\/blockquote>\n<p>Output should have &#8220;tun0&#8221; listed. And check the output of below command<\/p>\n<blockquote><p># cat \/dev\/net\/tun<\/p>\n<p>Out should be as below<br \/>\ncat: \/dev\/net\/tun: File descriptor in bad state<\/p><\/blockquote>\n<p>OpenVPN and it\u2019s dependencies are not available in the CentOS default repositories. So, we should install the \u201cEPEL\u201d repository in order to install OpenVPN and its dependencies.<\/p>\n<blockquote><p># wget ftp:\/\/ftp.rediris.es\/volumes\/sites\/centos.org\/6.6\/extras\/i386\/Packages\/epel-release-6-8.noarch.rpm<br \/>\n# rpm -Uvh epel-release-6-8.noarch.rpm<\/p><\/blockquote>\n<p>Install OpenVPN using yum<\/p>\n<blockquote>\n<pre># yum install openvpn -y<\/pre>\n<\/blockquote>\n<p>Copy the configuration file to its destination:<\/p>\n<blockquote><p># cp \/usr\/share\/doc\/openvpn-*\/sample-config-files\/server.conf \/etc\/openvpn<br \/>\n# vi \/etc\/openvpn\/server.conf<\/p><\/blockquote>\n<p>Uncomment below line in the server.conf file:<\/p>\n<blockquote><p>push &#8220;redirect-gateway def1 bypass-dhcp&#8221;<br \/>\npush &#8220;dhcp-option DNS 8.8.8.8&#8221;<br \/>\npush &#8220;dhcp-option DNS 8.8.4.4&#8221;<br \/>\nuser nobody<br \/>\ngroup nobody<\/p><\/blockquote>\n<p>Now we will have to generate Keys and Certificates Using easy-rsa, for that install easy-rsa using yum:<\/p>\n<blockquote><p># yum install easy-rsa<\/p><\/blockquote>\n<p>The easy-rsa scripts are located by default in the \/usr\/share\/easy-rsa\/ directory. Make a directory \/easy-rsa\/keys inside the \/etc\/openvpn directory. Copy the scripts as given below:<\/p>\n<blockquote><p># mkdir -p \/etc\/openvpn\/easy-rsa\/keys<br \/>\n# cp -ar \/usr\/share\/easy-rsa\/2.0\/* \/etc\/openvpn\/easy-rsa\/<\/p><\/blockquote>\n<p>Now we will have to edit the &#8220;vars&#8221; file with required information:<\/p>\n<blockquote><p># vi \/etc\/openvpn\/easy-rsa\/vars<\/p><\/blockquote>\n<p>Fill up the desired details at correct place. Don&#8217;t leave any of these fields blank.<\/p>\n<blockquote><p>export KEY_COUNTRY=&#8221;US&#8221;<br \/>\nexport KEY_PROVINCE=&#8221;NY&#8221;<br \/>\nexport KEY_CITY=&#8221;New York&#8221;<br \/>\nexport KEY_ORG=&#8221;Organization Name&#8221;<br \/>\nexport KEY_EMAIL=&#8221;administrator@example.com&#8221;<br \/>\nexport KEY_OU=server<\/p><\/blockquote>\n<p>Then follow below commands:<\/p>\n<blockquote><p># cd \/etc\/openvpn\/easy-rsa\/<br \/>\n# cp openssl-1.0.0.cnf openssl.cnf<br \/>\n# source .\/vars<br \/>\n# .\/clean-all<\/p><\/blockquote>\n<p>Then, run the following command to generate CA certificate and CA key:<\/p>\n<blockquote><p># .\/build-ca<\/p><\/blockquote>\n<p>Keep pressing &#8220;Enter&#8221; for variables, when asked by build-key-server, answer yes to commit.<\/p>\n<blockquote><p># .\/build-key-server server<\/p><\/blockquote>\n<p>Enter the following command to generate DH parameter, and then copy below files to &#8220;\/etc\/openvpn&#8221;.<\/p>\n<blockquote><p># .\/build-dh<br \/>\n# cd \/etc\/openvpn\/easy-rsa\/keys<br \/>\n# cp dh2048.pem ca.crt server.crt server.key \/etc\/openvpn<\/p><\/blockquote>\n<p>The necessary keys and certificates are generated and placed at correct directory.<br \/>\nNow we are going to generate client certificate:<\/p>\n<blockquote><p># cd \/etc\/openvpn\/easy-rsa<br \/>\n# .\/build-key client<\/p><\/blockquote>\n<p>You must copy all client certificates and keys to the remote VPN clients in order to authenticate to the VPN server. Below are the required files to be downloaded\/copied:<\/p>\n<blockquote><p>ca.crt<br \/>\nclient.crt<br \/>\nclient.key<\/p><\/blockquote>\n<p>On Windows, the path for the files to be copied would be &#8220;C:\\Program Files\\OpenVPN\\config&#8221;, which will come with &#8220;OpenVPN Community Edition binaries&#8221;.<\/p>\n<p>On Mac OS X, the open source application &#8220;Tunnelblick&#8221; provides an interface similar to OpenVPN GUI on Windows, and comes prepackagd with OpenVPN and required TUN\/TAP drivers. Here the destination folder for&nbsp;.ovpn configuration would be &#8220;~\/Library\/Application Support\/Tunnelblick\/Configurations&#8221;.<\/p>\n<p>You will need to create an iptables rule to allow proper routing of our VPN subnet.<\/p>\n<blockquote><p># iptables -t nat -A POSTROUTING -s 10.8.0.0\/24 -o eth0 -j MASQUERADE<br \/>\n# service iptables save<\/p><\/blockquote>\n<p>Then, enable IP Forwarding in sysctl:<\/p>\n<blockquote><p>vi \/etc\/sysctl.conf<br \/>\n# Controls IP packet forwarding<br \/>\nnet.ipv4.ip_forward = 0&nbsp;&nbsp; =========&gt; change it to 1<\/p><\/blockquote>\n<p>Apply new settings and start the OpenVPN server:<\/p>\n<blockquote><p># sysctl -p<br \/>\n# service openvpn start<br \/>\n# chkconfig openvpn on<\/p><\/blockquote>\n<p>With our certificates now on the client system, we will create another new file called client.ovpn, where &#8220;client&#8221; should match the name of the client being deployed (from build-key), the contents should be as follows, replacing &#8220;x.x.x.x&#8221; with your OpenVPN server&#8217;s IP address, and with the appropriate files pasted into the designated areas.<\/p>\n<blockquote><p>client<br \/>\ndev tun<br \/>\nproto udp<br \/>\nremote x.x.x.x 1194 #- your OPENVPN server IP and port<br \/>\nresolv-retry infinite<br \/>\nnobind<br \/>\ntun-mtu 1500<br \/>\ntun-mtu-extra 32<br \/>\nmssfix 1450<br \/>\npersist-key<br \/>\npersist-tun<br \/>\nca ca.crt<br \/>\nauth-user-pass<br \/>\ncomp-lzo<br \/>\nverb 3<\/p><\/blockquote>\n<p>Make your vpn tunnel start upon boot (this will add the command to rc.local)<\/p>\n<blockquote><p># echo openvpn \/etc\/openvpn\/server.conf &gt;&gt; \/etc\/rc.d\/rc.local<br \/>\n# openvpn \/etc\/openvpn\/server.conf<\/p><\/blockquote>\n<p>Once done, reboot the server.<\/p>\n<p>Further, you can create and assign new user to your VPN server:<\/p>\n<p>To create a new user we type: (replace myuser with your username)<br \/>\n# useradd myuser -s \/bin\/false<\/p>\n<p>To create the password we type<br \/>\n# passwd myuser<\/p>\n<p>To Delete a user type<br \/>\n# userdel myuser<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenVPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities. It uses a custom security protocol that utilizes SSL\/TLS for key exchange. It is capable of traversing network address translators (NATs) and firewalls. Firstly, verify if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3536,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[30],"tags":[31,32],"class_list":["post-2577","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-centos","tag-cpanel"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to install &amp; configure OpenVPN on Centos 6 \u2013 24x7serversupport-Blog<\/title>\n<meta name=\"description\" content=\"Open VPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities.\" \/>\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.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/\" \/>\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; configure OpenVPN on Centos 6 \u2013 24x7serversupport-Blog\" \/>\n<meta property=\"og:description\" content=\"Open VPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-11-22T20:05:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-24T06:35:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png\" \/>\n\t<meta property=\"og:image:width\" content=\"299\" \/>\n\t<meta property=\"og:image:height\" content=\"168\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/\",\"name\":\"How to install & configure OpenVPN on Centos 6 \u2013 24x7serversupport-Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png?fit=299%2C168&ssl=1\",\"datePublished\":\"2014-11-22T20:05:36+00:00\",\"dateModified\":\"2023-01-24T06:35:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"description\":\"Open VPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png?fit=299%2C168&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png?fit=299%2C168&ssl=1\",\"width\":299,\"height\":168,\"caption\":\"How to install & configure OpenVPN on Centos 6\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install &#038; configure OpenVPN on Centos 6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install & configure OpenVPN on Centos 6 \u2013 24x7serversupport-Blog","description":"Open VPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities.","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.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/","og_locale":"en_US","og_type":"article","og_title":"How to install & configure OpenVPN on Centos 6 \u2013 24x7serversupport-Blog","og_description":"Open VPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities.","og_url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/","og_site_name":"24x7serversupport Blog","article_published_time":"2014-11-22T20:05:36+00:00","article_modified_time":"2023-01-24T06:35:32+00:00","og_image":[{"width":299,"height":168,"url":"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png","type":"image\/png"}],"author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/","url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/","name":"How to install & configure OpenVPN on Centos 6 \u2013 24x7serversupport-Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png?fit=299%2C168&ssl=1","datePublished":"2014-11-22T20:05:36+00:00","dateModified":"2023-01-24T06:35:32+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"description":"Open VPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities.","breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#primaryimage","url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png?fit=299%2C168&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png?fit=299%2C168&ssl=1","width":299,"height":168,"caption":"How to install & configure OpenVPN on Centos 6"},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-configure-openvpn-on-centos-6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to install &#038; configure OpenVPN on Centos 6"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2014\/11\/open-vpsn.png?fit=299%2C168&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/2577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=2577"}],"version-history":[{"count":1,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/2577\/revisions"}],"predecessor-version":[{"id":3537,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/2577\/revisions\/3537"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media\/3536"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=2577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=2577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=2577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}