<?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>WireGuard Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/wireguard/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Tue, 01 Dec 2020 18:54:57 +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 setup WireGuard VPN with ubuntu 20.04</title>
		<link>https://www.osradar.com/how-to-setup-wireguard-vpn-with-ubuntu-20-04/</link>
					<comments>https://www.osradar.com/how-to-setup-wireguard-vpn-with-ubuntu-20-04/#respond</comments>
		
		<dc:creator><![CDATA[rajneesh]]></dc:creator>
		<pubDate>Tue, 01 Dec 2020 18:54:54 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vpn]]></category>
		<category><![CDATA[WireGuard]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=25895</guid>

					<description><![CDATA[<p>Here, we will learn today how to configure WireGuard VPN with Ubuntu 20.04. Wireguard® is an amazingly straightforward yet quick and present-day VPN that uses cutting edge cryptography. It expects to be quicker and more straightforward. It means to be significantly more performant than OpenVPN. At first, was released for the Linux part, WireGuard VPN [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-setup-wireguard-vpn-with-ubuntu-20-04/">How to setup WireGuard VPN with ubuntu 20.04</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Here, we will learn today how to configure WireGuard VPN with Ubuntu 20.04. <a href="https://www.wireguard.com/">Wireguard</a>® is an amazingly straightforward yet quick and present-day VPN that uses cutting edge cryptography. It expects to be quicker and more straightforward. It means to be significantly more performant than OpenVPN. At first, was released for the Linux part, WireGuard VPN is currently cross-stage (Windows, macOS, BSD, iOS, Android) and broadly deployable.</p>



<h3>Key Features</h3>



<ul><li><strong>Easy to use</strong>: With the help of a simple key exchange, a VPN connection made here.</li><li><strong>Trusted Cryptography:</strong> It uses state of the art cryptography like-Curve25519, HKDF, or Blake2. </li><li><strong>Performance:</strong> Suitable for both low and high configuration devices. </li><li><strong>Quick deployment:</strong>  Can be setup quickly, with very few commnads. </li></ul>



<h3>Server Settings for WireGuard VPN</h3>



<p>Let&#8217;s deploy WireGuard VPN with Ubuntu 20.04 LTS. The client machine (Ubuntu 20.04) is required as well.</p>



<p>Update server. </p>



<pre class="wp-block-preformatted"># apt-get update </pre>



<p>Install package.</p>



<pre class="wp-block-preformatted"># apt-get install wireguard</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="506" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-49-1024x506.png" alt="Install wireguard package" class="wp-image-25905" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-49-1024x506.png 1024w, https://www.osradar.com/wp-content/uploads/2020/11/image-49-300x148.png 300w, https://www.osradar.com/wp-content/uploads/2020/11/image-49-768x380.png 768w, https://www.osradar.com/wp-content/uploads/2020/11/image-49-696x344.png 696w, https://www.osradar.com/wp-content/uploads/2020/11/image-49-1068x528.png 1068w, https://www.osradar.com/wp-content/uploads/2020/11/image-49.png 1111w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Install wireguard package</figcaption></figure>



<p>Have a look if ip forwarding enabled or not.</p>



<pre class="wp-block-preformatted"># nono /etc/sysctl.conf</pre>



<p> </p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-50.png" alt="Enable IP forwarding for server" class="wp-image-25923" width="513" height="334" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-50.png 724w, https://www.osradar.com/wp-content/uploads/2020/11/image-50-300x196.png 300w, https://www.osradar.com/wp-content/uploads/2020/11/image-50-696x454.png 696w" sizes="(max-width: 513px) 100vw, 513px" /><figcaption>Enable IP forwarding for server</figcaption></figure>



<p>WireGuard work on port 51820, allow that.</p>



<pre class="wp-block-preformatted"> #ufw allow 51820/udp
Rules updated
Rules updated (v6)</pre>



<p>Both client and server require to generate their own private and public keys, let&#8217;s do that for the server first. </p>



<pre class="wp-block-preformatted"># cd /etc/wireguard/</pre>



<p>Change permissions.</p>



<pre class="wp-block-preformatted"># umask 077</pre>



<p>Generate private and public keys.</p>



<pre class="wp-block-preformatted">#wg genkey | tee privatekey | wg pubkey &gt; publickey</pre>



<p>Have a look, if keys are generated.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="748" height="353" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-51.png" alt="Generate private and public keys for server" class="wp-image-25937" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-51.png 748w, https://www.osradar.com/wp-content/uploads/2020/11/image-51-300x142.png 300w, https://www.osradar.com/wp-content/uploads/2020/11/image-51-696x328.png 696w" sizes="(max-width: 748px) 100vw, 748px" /><figcaption>Generate private and public keys for server</figcaption></figure>



<p>Amend WireGuard configuration file, create file /etc/wiregurard.</p>



<pre class="wp-block-preformatted">#touch wg0.conf </pre>



<p>Edit wg0.conf.</p>



<pre class="wp-block-preformatted"># nano wg0.conf</pre>



<p>You can copy configuration file from here:</p>



<pre class="wp-block-preformatted">[Interface]
PrivateKey = CA1l0/AkJRoE9HXkjOECJySGD+8D14nwwoRO3HVVCls=
Address = 192.168.1.239/24
SaveConfig=true
PostUp=iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown=iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
ListenPort = 51820</pre>



<p>
Where,</p>



<p><strong>PrivateKey</strong>=  Copy private key.</p>



<p><strong>Address</strong>= Server IP address. </p>



<p>Copy IP tables rule from here. </p>



<p><strong>ListenPort</strong>= WireGuard VPN default port.</p>



<p>  </p>



<figure class="wp-block-image size-large"><img loading="lazy" width="977" height="409" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-57.png" alt="Edit wg0.conf file for server" class="wp-image-25958" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-57.png 977w, https://www.osradar.com/wp-content/uploads/2020/11/image-57-300x126.png 300w, https://www.osradar.com/wp-content/uploads/2020/11/image-57-768x322.png 768w, https://www.osradar.com/wp-content/uploads/2020/11/image-57-696x291.png 696w" sizes="(max-width: 977px) 100vw, 977px" /><figcaption>Edit wg0.conf file for server</figcaption></figure>



<pre class="wp-block-preformatted"><strong> </strong>Make network interface up for WireGuard</pre>



<pre class="wp-block-preformatted"># wg-quick up wg0

**Command Output***

[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 192.168.1.0/24 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE </pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="911" height="120" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-53.png" alt="make WireGuard VPN up" class="wp-image-25949" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-53.png 911w, https://www.osradar.com/wp-content/uploads/2020/11/image-53-300x40.png 300w, https://www.osradar.com/wp-content/uploads/2020/11/image-53-768x101.png 768w, https://www.osradar.com/wp-content/uploads/2020/11/image-53-696x92.png 696w" sizes="(max-width: 911px) 100vw, 911px" /><figcaption>make WireGuard VPN up</figcaption></figure>



<p>Check WireGuard service status</p>



<pre class="wp-block-preformatted"># wg</pre>



<p>Output</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="554" height="99" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-54.png" alt="check wg service status" class="wp-image-25950" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-54.png 554w, https://www.osradar.com/wp-content/uploads/2020/11/image-54-300x54.png 300w" sizes="(max-width: 554px) 100vw, 554px" /><figcaption>check wg service status</figcaption></figure>



<h3>Client Settings for WireGuard VPN</h3>



<p>Let&#8217;s login to client. Here we have another Ubuntu machine. Install WireGuard VPN client with apt install WireGuard command as we did for server.   </p>



<p>Generate keys</p>



<pre id="block-d811f5bb-4c9c-4ac0-a5a8-67eb8f451869" class="wp-block-preformatted">#wg genkey | tee privatekey | wg pubkey &gt; publickey</pre>



<p> Create and edit wg0.conf file for client. Where</p>



<p><strong>[Interface]</strong></p>



<p>PrivateKey= The key generated for client. </p>



<p>ListenPort=The Default port for WireGuard VPN. </p>



<p>Address= IP address of that client machine.</p>



<p><strong>[Peer]</strong></p>



<p>PublicKey= copy public key from server.</p>



<p>EndPoint= Ip address of the server. </p>



<p>AllowedIPs = all all traffic via WireGuard VPN.</p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="696" height="543" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-56.png" alt="edit WireGuard client conf file " class="wp-image-25955" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-56.png 696w, https://www.osradar.com/wp-content/uploads/2020/11/image-56-300x234.png 300w" sizes="(max-width: 696px) 100vw, 696px" /><figcaption>edit WireGuard client conf file </figcaption></figure>



<p>Make WireGuard up</p>



<pre class="wp-block-preformatted">#wg-quick up wg0</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="540" height="313" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-58.png" alt="Make service up for client " class="wp-image-25961" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-58.png 540w, https://www.osradar.com/wp-content/uploads/2020/11/image-58-300x174.png 300w" sizes="(max-width: 540px) 100vw, 540px" /><figcaption>Make WireGuard service up for client </figcaption></figure>



<p>Check services</p>



<pre class="wp-block-preformatted"># wg</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="594" height="191" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-59.png" alt="" class="wp-image-25962" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-59.png 594w, https://www.osradar.com/wp-content/uploads/2020/11/image-59-300x96.png 300w" sizes="(max-width: 594px) 100vw, 594px" /><figcaption>Check wg service status </figcaption></figure>



<p>Add client to the server, copy client key and paste in server wg conf file, run following command, and paste copied key.</p>



<p></p>



<pre class="wp-block-preformatted">wg set wg0 peer 21aCR8N0sUDuqUlVVm/Y7r5OKVV8FT9cZZr0YcEagUg= allowed-ips 192.168.1.0/24</pre>



<p>You can add as many clients are required by adding private keys, and ip ddresses of the clients. </p>



<p>Stop and start back wg service and check, if any update in the conf file. Yes, we can see the changes. </p>



<pre class="wp-block-preformatted"># wg-quick down wg0 &amp;&amp; wg-quick up wg0</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="364" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/11/image-61-1024x364.png" alt="Check WireGuard VPN conf file on server for changes" class="wp-image-25966" srcset="https://www.osradar.com/wp-content/uploads/2020/11/image-61-1024x364.png 1024w, https://www.osradar.com/wp-content/uploads/2020/11/image-61-300x107.png 300w, https://www.osradar.com/wp-content/uploads/2020/11/image-61-768x273.png 768w, https://www.osradar.com/wp-content/uploads/2020/11/image-61-696x248.png 696w, https://www.osradar.com/wp-content/uploads/2020/11/image-61.png 1032w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Check WireGuard VPN conf file on server for changes</figcaption></figure>



<p>Here all your WireGuard VPN is set to go. Though WireGuard is getting popular day by day, but still so many changes are going on. WireGuard should be avoided for any critical live environment.</p>



<p> </p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-setup-wireguard-vpn-with-ubuntu-20-04/">How to setup WireGuard VPN with ubuntu 20.04</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-setup-wireguard-vpn-with-ubuntu-20-04/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
