<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>how to configure openvpn server on centos 8 Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/how-to-configure-openvpn-server-on-centos-8/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Fri, 27 Mar 2020 11:33:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.12</generator>
	<item>
		<title>How To Install OpenVPN on CentOS 8</title>
		<link>https://www.osradar.com/how-to-install-openvpn-on-centos-8/</link>
					<comments>https://www.osradar.com/how-to-install-openvpn-on-centos-8/#comments</comments>
		
		<dc:creator><![CDATA[sabi]]></dc:creator>
		<pubDate>Fri, 27 Mar 2020 11:33:04 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[how to configure openvpn server on centos 8]]></category>
		<category><![CDATA[how to install openvpn server on centos 8]]></category>
		<category><![CDATA[openvpn installation on linux]]></category>
		<category><![CDATA[openvpn server installation on centos 8]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=18981</guid>

					<description><![CDATA[<p>Today we are going to learn that how to install OpenVPN on Centos 8. First of all let&#8217;s have a short introduction about it. A VPN “Virtual Private Network” is a technology that permits you to create a fully secured network over the Internet. This may lets you encrypt your internet visitors and shield your [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-openvpn-on-centos-8/">How To Install OpenVPN on CentOS 8</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Today we are going to learn that <a href="https://www.osradar.com/?p=18981">how to install OpenVPN on Centos 8</a>.  First of all let&#8217;s have a short introduction about it. A VPN “Virtual Private Network” is a technology that permits you to create a fully secured network over the  Internet. This may lets you encrypt your internet visitors and shield your online identity. It is in general used to connect  business networks securely over the Internet &amp; allows you to attach a enterprise network from anywhere.</p>



<p>In simple terms, a VPN connects your Cellular, Computer, &amp; Tablet to any other computer (server) over the Internet and lets in you to access the Internet.<br>It will connect you using that server&#8217;s internet and also get entry to the local community via bypassing Internet censorship remotely. VPN has many other different advantages you can google them for learning in more details.<br>So, today we will learn that how we can Install VPN on our CentOS 8 system to stay secure and browser different activities securely. Just follow the below steps for an easy installation.</p>



<h3><strong>Step 1: Update your system</strong></h3>



<p>As usual we do, update your system by runnig</p>



<pre class="wp-block-verse">sudo yum update &amp;&amp; sudo yum upgrade</pre>



<h3><strong>Step 2: Disable SELinux</strong></h3>



<p>After updating system don&#8217;t forget to disable SELinux before further proceeding. Open the file <strong>/etc/selinux/config</strong> &amp; then change the following line to <strong>disable SELinux</strong></p>



<pre class="wp-block-verse">sudo nano /etc/selinux/config<br>SELINUX=disabled</pre>



<p>Then save the file &amp; exit.</p>



<h3><strong>Step 3: Enable IP Forwarding</strong></h3>



<p>Now, enable the IP forwarding in CentOS 8. It will allows the coming packets &amp; then forward it to the network when destination is on another network.</p>



<p>For enabling IP Forwarding type</p>



<pre class="wp-block-verse">sudo nano /etc/sysctl.conf</pre>



<p>Then add the following line </p>



<pre class="wp-block-verse">net.ipv4.ip_forward = 1</pre>



<p>After it save the file &amp; exit.</p>



<h3><strong>Step 4: Installing OpenVPN Server</strong></h3>



<p>If you&#8217;ve already installed EPEL repository in your system, leave the first step below. If you don&#8217;t have install it by</p>



<pre class="wp-block-verse">sudo dnf install epel-release -y</pre>



<p>After it run the command to install OpenVPN server</p>



<pre class="wp-block-verse">sudo dnf install openvpn -y</pre>



<p>When the installation finished, switch to the <strong>/etc/openvpn</strong> directory &amp; download the <strong>easy-rsa</strong> for Security purposes.</p>



<pre class="wp-block-verse">cd /etc/openvpn<br>sudo wget https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.6/EasyRSA-unix-v3.0.6.tgz</pre>



<p>Then extract the downloaded package.</p>



<pre class="wp-block-verse">sudo tar -xvzf EasyRSA-unix-v3.0.6.tgz</pre>



<p>And move the resulting</p>



<pre class="wp-block-verse">sudo mv EasyRSA-v3.0.6 easy-rsa</pre>



<h3><strong>Step 5: Configuring Easy RSA</strong></h3>



<p>As for security reasons, we&#8217;ve to add SSL certificates. And for these purposes configure the Easy RSA on our system.</p>



<p>Switch to the <strong>/etc/openvpn/easy-rsa</strong> directory &amp; create a new file</p>



<pre class="wp-block-verse">cd /etc/openvpn/easy-rsa<br>sudo nano vars</pre>



<p>Then paste the below content into the file</p>



<pre class="wp-block-verse">set_var EASYRSA                 "$PWD"<br> set_var EASYRSA_PKI             "$EASYRSA/pki"<br> set_var EASYRSA_DN              "cn_only"<br> set_var EASYRSA_REQ_COUNTRY     "PAKISTAN"<br> set_var EASYRSA_REQ_PROVINCE    "PUNJAB"<br> set_var EASYRSA_REQ_CITY        "MULTAN"<br> set_var EASYRSA_REQ_ORG         "osradar CERTIFICATE AUTHORITY"<br> set_var EASYRSA_REQ_EMAIL        "admin@osradar.com"<br> set_var EASYRSA_REQ_OU          "osradar EASY CA"<br> set_var EASYRSA_KEY_SIZE        2048<br> set_var EASYRSA_ALGO            rsa<br> set_var EASYRSA_CA_EXPIRE        7500<br> set_var EASYRSA_CERT_EXPIRE     365<br> set_var EASYRSA_NS_SUPPORT        "no"<br> set_var EASYRSA_NS_COMMENT        "osradar CERTIFICATE AUTHORITY"<br> set_var EASYRSA_EXT_DIR         "$EASYRSA/x509-types"<br> set_var EASYRSA_SSL_CONF        "$EASYRSA/openssl-easyrsa.cnf"<br> set_var EASYRSA_DIGEST          "sha256"</pre>



<p><strong>Note:</strong> Replace the <strong>country, province, city &amp; email address</strong> with yours.</p>



<p>Save the file &amp; exit.</p>



<p>After it run the command to initiate the PKI directory.</p>



<pre class="wp-block-verse">./easyrsa init-pki</pre>



<p>Output:</p>



<p>You&#8217;ll see the output like this.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="719" height="208" src="https://www.osradar.com/wp-content/uploads/2020/03/1-13.png" alt="how to install openvpn on centos 8" class="wp-image-19130" srcset="https://www.osradar.com/wp-content/uploads/2020/03/1-13.png 719w, https://www.osradar.com/wp-content/uploads/2020/03/1-13-300x87.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/1-13-696x201.png 696w" sizes="(max-width: 719px) 100vw, 719px" /></figure>



<p>Now, build the CA certificates </p>



<pre class="wp-block-verse">sudo ./easyrsa build-ca</pre>



<p>Output: </p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="1024" height="386" src="https://www.osradar.com/wp-content/uploads/2020/03/2-15-1024x386.png" alt="how to install openvpn on centos 8" class="wp-image-19131" srcset="https://www.osradar.com/wp-content/uploads/2020/03/2-15-1024x386.png 1024w, https://www.osradar.com/wp-content/uploads/2020/03/2-15-300x113.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/2-15-768x289.png 768w, https://www.osradar.com/wp-content/uploads/2020/03/2-15-696x262.png 696w, https://www.osradar.com/wp-content/uploads/2020/03/2-15-1068x402.png 1068w, https://www.osradar.com/wp-content/uploads/2020/03/2-15-1115x420.png 1115w, https://www.osradar.com/wp-content/uploads/2020/03/2-15.png 1354w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>Note: You&#8217;ll be given two files named as <strong>ca.key</strong> &amp; <strong>ca.crt</strong> from the above running command. You can use them while logging in to server &amp; clients.</p>



<h3><strong>Step 6: Generating Server Certificate Files</strong></h3>



<p>Now, run the command to generate the key-pair &amp; certificate request.</p>



<pre class="wp-block-verse">sudo ./easyrsa gen-req osradar-server nopass</pre>



<p>Output:</p>



<p>Here&#8217;s output sample</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="845" height="424" src="https://www.osradar.com/wp-content/uploads/2020/03/3-15.png" alt="how to install openvpn on centos 8" class="wp-image-19132" srcset="https://www.osradar.com/wp-content/uploads/2020/03/3-15.png 845w, https://www.osradar.com/wp-content/uploads/2020/03/3-15-300x151.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/3-15-768x385.png 768w, https://www.osradar.com/wp-content/uploads/2020/03/3-15-696x349.png 696w, https://www.osradar.com/wp-content/uploads/2020/03/3-15-837x420.png 837w" sizes="(max-width: 845px) 100vw, 845px" /></figure></div>



<h3><strong>Step 7: Sign the Server Key Using CA</strong></h3>



<p>Now, sign in the <strong>osradar-server</strong> key with the help of your CA certificate.</p>



<p>To do this just fire the command</p>



<pre class="wp-block-verse">sudo ./easyrsa sign-req server osradar-server</pre>



<p>Output:</p>



<p>You will see the output like this</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="787" height="489" src="https://www.osradar.com/wp-content/uploads/2020/03/4-11.png" alt="how to install openvpn on centos 8" class="wp-image-19133" srcset="https://www.osradar.com/wp-content/uploads/2020/03/4-11.png 787w, https://www.osradar.com/wp-content/uploads/2020/03/4-11-300x186.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/4-11-768x477.png 768w, https://www.osradar.com/wp-content/uploads/2020/03/4-11-356x220.png 356w, https://www.osradar.com/wp-content/uploads/2020/03/4-11-696x432.png 696w, https://www.osradar.com/wp-content/uploads/2020/03/4-11-676x420.png 676w" sizes="(max-width: 787px) 100vw, 787px" /></figure></div>



<pre class="wp-block-verse">openssl verify -CAfile pki/ca.crt pki/issued/osradar-server.crt </pre>



<p>You&#8217;ll see the similar output upon successful configuration.</p>



<pre class="wp-block-verse">pki/issued/osradar-server.crt: OK</pre>



<p>Now, generate the Diffie-Hellman key for exchange key purposes</p>



<pre class="wp-block-verse">sudo ./easyrsa gen-dh</pre>



<p>Output:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="731" height="176" src="https://www.osradar.com/wp-content/uploads/2020/03/5-12.png" alt="how to install openvpn on centos 8" class="wp-image-19134" srcset="https://www.osradar.com/wp-content/uploads/2020/03/5-12.png 731w, https://www.osradar.com/wp-content/uploads/2020/03/5-12-300x72.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/5-12-696x168.png 696w" sizes="(max-width: 731px) 100vw, 731px" /></figure></div>



<p>As you finished all these just copy them to the <strong>/etc/openvpn/server/</strong> directory</p>



<pre class="wp-block-verse">cp pki/ca.crt /etc/openvpn/server/<br>cp pki/dh.pem /etc/openvpn/server/<br>cp pki/private/osradar-server.key /etc/openvpn/server/<br>cp pki/issued/osradar-server.crt /etc/openvpn/server/</pre>



<h3><strong>Step 8: Generating Client Certificate &amp; Key File</strong></h3>



<p>Generate the client key file using</p>



<pre class="wp-block-verse">sudo ./easyrsa gen-req client nopass</pre>



<p>Output:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="1024" height="407" src="https://www.osradar.com/wp-content/uploads/2020/03/6-10-1024x407.png" alt="how to install openvpn on centos 8" class="wp-image-19135" srcset="https://www.osradar.com/wp-content/uploads/2020/03/6-10-1024x407.png 1024w, https://www.osradar.com/wp-content/uploads/2020/03/6-10-300x119.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/6-10-768x305.png 768w, https://www.osradar.com/wp-content/uploads/2020/03/6-10-696x277.png 696w, https://www.osradar.com/wp-content/uploads/2020/03/6-10.png 1047w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>Now, sign the client key with the help of your CA certificate</p>



<pre class="wp-block-verse">sudo ./easyrsa sign-req client client</pre>



<p>Output:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="757" height="372" src="https://www.osradar.com/wp-content/uploads/2020/03/7-7.png" alt="how to install openvpn on centos 8" class="wp-image-19136" srcset="https://www.osradar.com/wp-content/uploads/2020/03/7-7.png 757w, https://www.osradar.com/wp-content/uploads/2020/03/7-7-300x147.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/7-7-324x160.png 324w, https://www.osradar.com/wp-content/uploads/2020/03/7-7-533x261.png 533w, https://www.osradar.com/wp-content/uploads/2020/03/7-7-696x342.png 696w" sizes="(max-width: 757px) 100vw, 757px" /></figure></div>



<p>After finishing these changes, copy them to the <strong>/etc/openvpn/client/</strong> directory</p>



<pre class="wp-block-verse">cp pki/ca.crt /etc/openvpn/client/<br>cp pki/issued/client.crt /etc/openvpn/client/<br>cp pki/private/client.key /etc/openvpn/client/</pre>



<h3><strong>Step 9: Configuring OpenVPN Server</strong></h3>



<p>Make a new config file under the <strong>/etc/openvpn/client</strong> with your favourite editor</p>



<pre class="wp-block-verse">sudo nano /etc/openvpn/server/server.conf</pre>



<p>Then paste the below content into it.</p>



<pre class="wp-block-verse">port 1194<br> proto udp<br> dev tun<br> ca /etc/openvpn/server/ca.crt<br> cert /etc/openvpn/server/osradar-server.crt<br> key /etc/openvpn/server/osradar-server.key<br> dh /etc/openvpn/server/dh.pem<br> server 10.8.0.0 255.255.255.0<br> push "redirect-gateway def1"<br> push "dhcp-option DNS 208.67.222.222"<br> push "dhcp-option DNS 208.67.220.220"<br> duplicate-cn<br> cipher AES-256-CBC<br> tls-version-min 1.2<br> tls-cipher TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-256-CBC-SHA256:TLS-DHE-RSA-WITH-AES-128-GCM-SHA256:TLS-DHE-RSA-WITH-AES-128-CBC-SHA256<br> auth SHA512<br> auth-nocache<br> keepalive 20 60<br> persist-key<br> persist-tun<br> compress lz4<br> daemon<br> user nobody<br> group nobody<br> log-append /var/log/openvpn.log<br> verb 3</pre>



<p>After it save &amp; exit the file.</p>



<h3><strong>Step 10: Start OpenVPN Services</strong></h3>



<p>Simply run the command below to start &amp; enable the OpenVPN Services</p>



<pre class="wp-block-verse">sudo systemctl start openvpn-server@server<br>sudo systemctl enable openvpn-server@server</pre>



<p>Make sure that the status is active by</p>



<pre class="wp-block-verse">systemctl status openvpn-server@server</pre>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="746" height="395" src="https://www.osradar.com/wp-content/uploads/2020/03/8-4.png" alt="how to install openvpn on centos 8" class="wp-image-19137" srcset="https://www.osradar.com/wp-content/uploads/2020/03/8-4.png 746w, https://www.osradar.com/wp-content/uploads/2020/03/8-4-300x159.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/8-4-696x369.png 696w" sizes="(max-width: 746px) 100vw, 746px" /></figure></div>



<p>Upon successful setup, OpenVPN Server will create a new network interface. Check it by typing</p>



<pre class="wp-block-verse">ifconfig</pre>



<p>Output:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="1024" height="462" src="https://www.osradar.com/wp-content/uploads/2020/03/9-4-1024x462.png" alt="how to install openvpn on centos 8" class="wp-image-19138" srcset="https://www.osradar.com/wp-content/uploads/2020/03/9-4-1024x462.png 1024w, https://www.osradar.com/wp-content/uploads/2020/03/9-4-300x135.png 300w, https://www.osradar.com/wp-content/uploads/2020/03/9-4-768x347.png 768w, https://www.osradar.com/wp-content/uploads/2020/03/9-4-696x314.png 696w, https://www.osradar.com/wp-content/uploads/2020/03/9-4-1068x482.png 1068w, https://www.osradar.com/wp-content/uploads/2020/03/9-4-931x420.png 931w, https://www.osradar.com/wp-content/uploads/2020/03/9-4.png 1365w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<h3><strong>Step 11: Generating Client Configuration File</strong></h3>



<p>It is necessary to generate the client configuration file in order to connect to the OpenVPN server from the client system.</p>



<pre class="wp-block-verse">sudo nano /etc/openvpn/client/client.ovpn</pre>



<p>Then paste the below data into it.</p>



<pre class="wp-block-verse">client<br> dev tun<br> proto udp<br> remote vpn-server-ip 1194<br> ca ca.crt<br> cert client.crt<br> key client.key<br> cipher AES-256-CBC<br> auth SHA512<br> auth-nocache<br> tls-version-min 1.2<br> tls-cipher TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-256-CBC-SHA256:TLS-DHE-RSA-WITH-AES-128-GCM-SHA256:TLS-DHE-RSA-WITH-AES-128-CBC-SHA256<br> resolv-retry infinite<br> compress lz4<br> nobind<br> persist-key<br> persist-tun<br> mute-replay-warnings<br> verb 3</pre>



<p>Save &amp; exit the file</p>



<h3><strong>Step 12: Configuring Routing </strong></h3>



<p>Allow the service through the firewalld by typing</p>



<pre class="wp-block-verse">firewall-cmd --permanent --add-service=openvpn<br> firewall-cmd --permanent --zone=trusted --add-service=openvpn<br> firewall-cmd --permanent --zone=trusted --add-interface=tun0</pre>



<p>And then add the MASQUERADE on the default zone.</p>



<pre class="wp-block-verse">firewall-cmd --add-masquerade<br>firewall-cmd --permanent --add-masquerade</pre>



<p>After it allow the coming requests from VPN to local system (VPN Network to local network)</p>



<pre class="wp-block-verse">osradar=$(ip route get 8.8.8.8 | awk 'NR==1 {print $(NF-2)}')<br> firewall-cmd --permanent --direct --passthrough ipv4 -t nat -A POSTROUTING -s 10.8.0.0/24 -o $osradar -j MASQUERADE</pre>



<p>Reload the changes</p>



<pre class="wp-block-verse">firewall-cmd --reload</pre>



<h3><strong>Step 13: Use OpenVPN from Clients</strong></h3>



<p>To use the OpenVPN from the client machine, you&#8217;ve to install the OpenVPN package with the following command</p>



<pre class="wp-block-verse">dnf install epel-release -y<br>dnf install openvpn -y</pre>



<p>After it download the OpenVPN client config files from server to client system.</p>



<p>Run the given command on client system</p>



<pre class="wp-block-verse">scp -r root@vpn-server-ip:/etc/openvpn/client  .</pre>



<p>As it get finished switch to the client directory and type</p>



<pre class="wp-block-verse">cd client<br>openvpn --config client.ovpn</pre>



<p>When the connection becomes successful, OpenVPN will assign the IP address to your system. Type the command to verify it.</p>



<pre class="wp-block-verse">ifconfig tun0</pre>



<p>So, this is how you can configure and install the OpenVPN server and client on CentOS 8.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-openvpn-on-centos-8/">How To Install OpenVPN on CentOS 8</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-install-openvpn-on-centos-8/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
