{"id":915,"date":"2022-12-14T19:41:32","date_gmt":"2022-12-14T14:11:32","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=915"},"modified":"2022-12-14T19:41:37","modified_gmt":"2022-12-14T14:11:37","slug":"install-openvpn-on-linuxconfigure-vpn-between-network","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/install-openvpn-on-linuxconfigure-vpn-between-network\/","title":{"rendered":"Install Openvpn on Linux|Configure VPN between network"},"content":{"rendered":"<p>We have been roaming around to establish VPN connection between our network to AWS network. There are servers which are in private network which needs to be accessed from our local network. Here comes the post on how to establish a VPN connection between your network to other network<\/p>\n<p><strong>Prerequisites:<\/strong><\/p>\n<ol>\n<li>Ubuntu 14.04 or latest version<\/li>\n<li>Windows Client Machine\/Linux Machine where you will connect<\/li>\n<\/ol>\n<p><strong>Installation:<\/strong><\/p>\n<p>Let&#8217;s install openvpn server on the Ubuntu server.<\/p>\n<p><code>apt-get install openvpn easy-rsa<\/code><\/p>\n<p>Create a installation directory.<\/p>\n<p><code>make-cadir ~\/openvpn-ca<\/code><\/p>\n<p>Move to the installation directory.<\/p>\n<p><code>cd ~\/openvpn-ca<\/code><\/p>\n<p>Open&nbsp;<em>vars&nbsp;<\/em>file and modify the below settings.<\/p>\n<p><code>vim vars<\/code><\/p>\n<pre>export KEY_COUNTRY=\"IN\"\nexport KEY_PROVINCE=\"KARNATAKA\"\nexport KEY_CITY=\"Bangalore\"\nexport KEY_ORG=\"PheonixSolutions\"\nexport KEY_EMAIL=\"test-key-vpn@pheonixsolutions.com\"\nexport KEY_OU=\"Devops\"\n\n# X509 Subject Field\nexport KEY_NAME=\"server\"\n<\/pre>\n<p>Source the file&nbsp;<em>vars.<\/em><\/p>\n<p><code>source vars<\/code><\/p>\n<p>Create the CA certificate<\/p>\n<p><code>.\/build-ca<\/code><\/p>\n<p>Just give enter for all the options and leave it blank for password. Note that, these options will be taken from&nbsp;<em>vars&nbsp;<\/em>file.<\/p>\n<p>Create the &nbsp;keyserver<\/p>\n<p><code>.\/build-key-server server<\/code><\/p>\n<p>Create dh.pem<\/p>\n<p><code>.\/build-dh<\/code><\/p>\n<p>Create ta.key<\/p>\n<p><code>openvpn --genkey --secret keys\/ta.key<\/code><\/p>\n<p>We will be creating client key on the same machine and copying the key to client machine.<\/p>\n<p><code>.\/build-key client1<\/code><\/p>\n<p>Copy the server.key,server.crt,ca.crt,ca.crt,ta.key,dh2048.pem<\/p>\n<p><code><\/code><code>cp ca.crt ca.key server.crt server.key ta.key dh2048.pem \/etc\/openvpn<\/code><\/p>\n<p>Create server.conf<\/p>\n<p><code>gunzip -c \/usr\/share\/doc\/openvpn\/examples\/sample-config-files\/server.conf.gz | sudo tee \/etc\/openvpn\/server.conf<\/code><\/p>\n<p>Add or update the following lines on <em>\/etc\/openvpn\/server.conf<\/em>.<\/p>\n<p><code>vim \/etc\/openvpn\/server.conf<\/code><\/p>\n<blockquote><p>tls-auth ta.key 0 # This file is secret<br \/>\nkey-direction 0<\/p>\n<p>auth SHA256<br \/>\nuser nobody<br \/>\ngroup nogroup<br \/>\ndh dh2048.pem<br \/>\npush &#8220;redirect-gateway def1 bypass-dhcp&#8221;<\/p><\/blockquote>\n<p>Enable Ip forward on the kernel level.<\/p>\n<p><code>echo 1 &gt; \/proc\/sys\/net\/ipv4\/ip_forward<\/code><\/p>\n<p>Append the following line&nbsp;<em>\/etc\/sysctl.conf<\/em><\/p>\n<p><code>vim \/etc\/sysctl.conf<\/code><\/p>\n<blockquote><p>net.ipv4.ip_forward=1<\/p><\/blockquote>\n<p>mkdir -p ~\/client-configs\/files<br \/>\nchmod 700 ~\/client-configs\/files<br \/>\ncp \/usr\/share\/doc\/openvpn\/examples\/sample-config-files\/client.conf ~\/client-configs\/base.conf<\/p>\n<p>vim ~\/clien-configs\/base.conf<br \/>\nremote server_IP_address 1194<br \/>\ncipher AES-128-CBC<br \/>\nauth SHA256<br \/>\nvim ~\/client-configs\/make_config.sh<br \/>\n#!\/bin\/bash<\/p>\n<p># First argument: Client identifier<\/p>\n<p>KEY_DIR=~\/openvpn-ca\/keys<br \/>\nOUTPUT_DIR=~\/client-configs\/files<br \/>\nBASE_CONFIG=~\/client-configs\/base.conf<\/p>\n<p>cat ${BASE_CONFIG} \\<br \/>\n&lt;(echo -e &#8216;&lt;ca&gt;&#8217;) \\<br \/>\n${KEY_DIR}\/ca.crt \\<br \/>\n&lt;(echo -e &#8216;&lt;\/ca&gt;\\n&lt;cert&gt;&#8217;) \\<br \/>\n${KEY_DIR}\/${1}.crt \\<br \/>\n&lt;(echo -e &#8216;&lt;\/cert&gt;\\n&lt;key&gt;&#8217;) \\<br \/>\n${KEY_DIR}\/${1}.key \\<br \/>\n&lt;(echo -e &#8216;&lt;\/key&gt;\\n&lt;tls-auth&gt;&#8217;) \\<br \/>\n${KEY_DIR}\/ta.key \\<br \/>\n&lt;(echo -e &#8216;&lt;\/tls-auth&gt;&#8217;) \\<br \/>\n&gt; ${OUTPUT_DIR}\/${1}.ovpn<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have been roaming around to establish VPN connection between our network to AWS network. There are servers which are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_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","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-915","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-eL","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=915"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/915\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}