<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>WireGuard on Such geek. Wow.</title><link>https://www.ericlight.com/tags/wireguard.html</link><description>Recent content in WireGuard on Such geek. Wow.</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 08 May 2020 00:00:00 +1200</lastBuildDate><atom:link href="https://www.ericlight.com/tags/wireguard/index.xml" rel="self" type="application/rss+xml"/><item><title>WireGuard on Windows - Part 2</title><link>https://www.ericlight.com/post/wireguard_windows2.html</link><pubDate>Fri, 08 May 2020 00:00:00 +1200</pubDate><guid>https://www.ericlight.com/post/wireguard_windows2.html</guid><description>&lt;p&gt;A few days ago I spun up a &lt;a class="link" href="https://www.ericlight.com/post/windows_dev_vm.html" &gt;Windows Dev VM&lt;/a&gt; to have a play with &lt;a class="link" href="https://www.wireguard.com/install/" target="_blank" rel="noopener"
 &gt;WireGuard for Windows&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I didn&amp;rsquo;t really have a clear goal in mind when I started playing with this - part of it was in trying to create and launch a tunnel without using the GUI. Mostly I was just trying to learn more about a new implementation of a tool that I really like.&lt;/p&gt;
&lt;p&gt;If you read my &lt;a class="link" href="https://www.ericlight.com/post/wireguard_windows.html" &gt;previous article&lt;/a&gt;, you&amp;rsquo;ll recall that I started off trying to do this with just &lt;code&gt;wireguard.exe&lt;/code&gt;. Here are some things I&amp;rsquo;ve discovered:&lt;/p&gt;
&lt;h3 id="wireguardexe-does-a-whole-lot-of-stuff"&gt;wireguard.exe does a &lt;em&gt;whole lot&lt;/em&gt; of stuff
&lt;/h3&gt;&lt;p&gt;Wireguard.exe isn&amp;rsquo;t just a GUI, which I originally thought it was. It&amp;rsquo;s also the piece of software that shouts out to &lt;a class="link" href="https://www.wintun.net/" target="_blank" rel="noopener"
 &gt;WinTun&lt;/a&gt; to create the interface, as well as the utility that reads the &amp;rsquo;extended&amp;rsquo; attributes in your .conf file (e.g. the stuff that wg-quick takes care of), as well as the utility that &lt;a class="link" href="https://github.com/WireGuard/wireguard-windows/blob/master/tunnel/addressconfig.go" target="_blank" rel="noopener"
 &gt;sets up your routes, DNS&lt;/a&gt;, etc, etc, etc.&lt;/p&gt;
&lt;h3 id="wireguardexe-doesnt-create-privatepublic-keypairs"&gt;wireguard.exe doesn&amp;rsquo;t create private/public keypairs
&lt;/h3&gt;&lt;p&gt;&amp;hellip; To do this, you instead need to use wg.exe, which is installed under your System32 folder (so it&amp;rsquo;s in your path, so it&amp;rsquo;s accessible anywhere):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PS C:\&amp;gt; wg genkey | tee $ENV:APPDATA\WireGuard.priv | wg pubkey &amp;gt; $ENV:APPDATA\WireGuard.pub
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I did &lt;a class="link" href="https://www.ericlight.com/post/wireguard_windows.html" &gt;figure this out the other day&lt;/a&gt;, but I&amp;rsquo;m reiterating here.&lt;/p&gt;
&lt;h3 id="wgexe-can-read-conf-files--but-you-dont-really-want-it-to"&gt;wg.exe can read .conf files &amp;ndash; but you don&amp;rsquo;t really want it to
&lt;/h3&gt;&lt;p&gt;Last time, I was having trouble reading a .conf file from wg.exe:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PS C:\Users&amp;gt; wg setconf wg0 .\wg0.conf
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Line unrecognized: ` ■[&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Configuration parsing error
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;m not entirely sure what this was - I&amp;rsquo;ve since been able to read in a .conf file perfectly fine (for the record this is UTF-8 with Windows CRLF line-endings).&lt;/p&gt;
&lt;p&gt;However &amp;hellip; my breakthrough kinda sucks.&lt;/p&gt;
&lt;p&gt;Wireguard for Windows stores it&amp;rsquo;s config files in the Windows DPAPI-encrypted vault. This is &lt;strong&gt;&lt;em&gt;vastly&lt;/em&gt;&lt;/strong&gt; better than just bunging a file in &lt;code&gt;C:\Users\Blah&lt;/code&gt; and hoping for the best. Maybe it&amp;rsquo;s not perfect - I don&amp;rsquo;t know much about DPAPI - but it&amp;rsquo;s a far cry better than nothing.&lt;/p&gt;
&lt;p&gt;When you use wireguard.exe to import a tunnel from a .conf file, it will read it in, sanity-check it (mine failed because I accidentally hit the keyboard during copy/pasta, so it rejected the Base64 encoding), and then safely store it away in the DPAPI storage. You can then delete your original .conf file. Just do this, it&amp;rsquo;s better.&lt;/p&gt;
&lt;h3 id="you-need-both-wireguardexe-and-wgexe"&gt;You need &lt;strong&gt;both&lt;/strong&gt; wireguard.exe and wg.exe
&lt;/h3&gt;&lt;p&gt;OK so here&amp;rsquo;s the bit that I only fully realised tonight: wireguard.exe is like wg-quick, but it also provides the interface into the &lt;a class="link" href="https://github.com/WireGuard/wireguard-windows/blob/master/tunnel/service.go" target="_blank" rel="noopener"
 &gt;Windows network stack&lt;/a&gt; and the &lt;a class="link" href="https://github.com/WireGuard/wireguard-windows/blob/master/conf/store.go" target="_blank" rel="noopener"
 &gt;Windows DPAPI storage&lt;/a&gt; of your sensitive conf files. You can&amp;rsquo;t even run &lt;code&gt;wg set&lt;/code&gt; without it, because wireguard.exe &lt;a class="link" href="https://github.com/WireGuard/wireguard-windows/blob/master/manager/ipc_server.go" target="_blank" rel="noopener"
 &gt;is even responsible for creating the IPC Server&lt;/a&gt; that interfaces with WinTun.&lt;/p&gt;
&lt;p&gt;Honestly the Windows world is so much more complicated than the Linux world*. 🙄&lt;/p&gt;
&lt;p&gt;(* some caveats apply)&lt;/p&gt;
&lt;h2 id="conclusion"&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;What&amp;rsquo;s my plan now?&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m going to make a thing that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Installs wireguard.msi silently&lt;/li&gt;
&lt;li&gt;Uses wg.exe to create a private/public keypair&lt;/li&gt;
&lt;li&gt;Uses that keypair to create a temporary .conf file&lt;/li&gt;
&lt;li&gt;Uses wireguard.exe to import that .conf file from some predetermined location&lt;/li&gt;
&lt;li&gt;Deletes the .conf file (probably using &lt;a class="link" href="https://support.microsoft.com/en-nz/help/814599/how-to-use-cipher-exe-to-overwrite-deleted-data-in-windows-server-2003" target="_blank" rel="noopener"
 &gt;cipher.exe&lt;/a&gt; to scrub it)&lt;/li&gt;
&lt;li&gt;Uses wireguard.exe to install the tunnel so it opens automatically on login&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;m hoping that this will create us something like an always-on-VPN connection that can be deployed easily by an IT support person, and require no end-user interaction.&lt;/p&gt;</description></item><item><title>Getting WireGuard on Windows - quietly</title><link>https://www.ericlight.com/post/wireguard_windows.html</link><pubDate>Mon, 27 Apr 2020 00:00:00 +1200</pubDate><guid>https://www.ericlight.com/post/wireguard_windows.html</guid><description>&lt;img src="https://www.ericlight.com/post/wireguard_windows/WireGuard_launch.png" alt="Featured image of post Getting WireGuard on Windows - quietly" /&gt;&lt;p&gt;So, I mentioned in my post &lt;a class="link" href="https://www.ericlight.com/post/windows_dev_vm.html" &gt;yesterday&lt;/a&gt; that I&amp;rsquo;m trying to get a bit of a quiet installer for WireGuard on Windows. Not that the current one is &lt;em&gt;noisy&lt;/em&gt;, but I have a really simple use-case that I want to meet.&lt;/p&gt;
&lt;p&gt;I spent some time seeing if I could just extract &lt;code&gt;WireGuard.exe&lt;/code&gt; and run that. Nope, of course - it requires &lt;a class="link" href="https://www.wintun.net/" target="_blank" rel="noopener"
 &gt;WinTun&lt;/a&gt; to be installed to facilitate the Layer 3 tunneling.&lt;/p&gt;
&lt;p&gt;Next I played with the idea of just deploying WinTun directly, without installing the WireGuard package itself. I can only assume that this would have been &lt;em&gt;super easy&lt;/em&gt; if I&amp;rsquo;d ever built a proper MSI installer before, but in the end it was just way easier to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;WireGuard-amd64-0.1.0.msi /q
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&amp;hellip; It was still worth the tangential digging, but who would have ever guessed that &lt;a class="link" href="https://www.zx2c4.com/" target="_blank" rel="noopener"
 &gt;Jason Donenfeld&lt;/a&gt; would have already done things the best way. ¯\_(ツ)_/¯ &amp;lt;/s&amp;gt;&lt;/p&gt;
&lt;p&gt;Note you&amp;rsquo;ve got to run the above in an elevated command prompt, since it&amp;rsquo;s installing drivers. However, the installation is still not quiet - after install, it pops up the WireGuard GUI window!&lt;/p&gt;
&lt;p&gt;&lt;img alt="After running the installer with the ‘Quiet’ parameter, the WireGuard GUI still opens" class="gallery-image" data-flex-basis="320px" data-flex-grow="133" height="830" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://www.ericlight.com/post/wireguard_windows/WireGuard_launch.png" srcset="https://www.ericlight.com/post/wireguard_windows/WireGuard_launch_hu_359e0a7ca5787395.png 800w, https://www.ericlight.com/post/wireguard_windows/WireGuard_launch.png 1109w" width="1109"&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;That&amp;rsquo;s annoying,&amp;rdquo; I think to myself, &amp;ldquo;can I stop that?&amp;rdquo; To the &lt;a class="link" href="https://github.com/WireGuard/WireGuard-windows/blob/master/installer/WireGuard.wxs" target="_blank" rel="noopener"
 &gt;installer source code&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;OwO &amp;hellip; Hwat&amp;rsquo;s this?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-xml" data-lang="xml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;&amp;lt;!--
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt; Launch WireGuard.exe after setup complete
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt; --&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;CustomAction&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Id=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;LaunchApplication&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;HideTarget=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;yes&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Impersonate=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;no&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Execute=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;deferred&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;FileKey=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;WireGuard.exe&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;ExeCommand=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Return=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;asyncNoWait&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;InstallExecuteSequence&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;Custom&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Action=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;LaunchApplication&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Before=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;InstallFinalize&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;(&amp;amp;amp;WireGuardFeature = 3) AND NOT DO_NOT_LAUNCH&lt;span style="color:#f92672"&gt;&amp;lt;/Custom&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;/InstallExecuteSequence&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It appears that we can pass through an environment variable to stop the installer from launching the GUI after install!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ps1" data-lang="ps1"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; .\WireGuard-amd64-&lt;span style="color:#ae81ff"&gt;0.1&lt;/span&gt;.0.msi /q DO_NOT_LAUNCH=True
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Aaaand success&amp;hellip; now I&amp;rsquo;ve got WireGuard and WinTun installed, no user interaction, so far completely silent. Next I gotta create a keypair. There aren&amp;rsquo;t any relevant command-line arguments that I can pass to wireguard.exe, so I went on a hunt for a keypair generator.&lt;/p&gt;
&lt;p&gt;&lt;img alt="A list of the few parameters for wireguard.exe - /installmanagerservice, /installtunnelservice, and similar uninstallers. No keygen etc." class="gallery-image" data-flex-basis="488px" data-flex-grow="203" height="304" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://www.ericlight.com/post/wireguard_windows/wireguard_exe_options.png" width="619"&gt;&lt;/p&gt;
&lt;p&gt;I spent an hour or so scratching around various options to find a keypair generator that looked trustworthy. I honestly couldn&amp;rsquo;t find one&amp;hellip; even the one posted on the &lt;a class="link" href="https://github.com/WireGuard/WireGuard-tools/tree/master/contrib/keygen-html" target="_blank" rel="noopener"
 &gt;WireGuard GitHub&lt;/a&gt; includes a caveat from Jason.&lt;/p&gt;
&lt;p&gt;Until I decided to have a closer look at the installer source code&amp;hellip; the very same code I was looking at when I discovered the DO_NOT_LAUNCH property above.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-xml" data-lang="xml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;Component&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Directory=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;System64Folder&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Win64=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;yes&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Id=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Wg64Executable&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Guid=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;d9b494ec-0959-442c-89ad-6aa175acfd03&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;File&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Source=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;..\$(var.WIREGUARD_PLATFORM)\wg.exe&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Id=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Wg64Executable&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;/Component&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So &lt;code&gt;C:\Program Files\WireGuard\WireGuard.exe&lt;/code&gt; appears to be just a shell that calls out to &lt;code&gt;C:\Windows\System32\wg.exe&lt;/code&gt;. Oh my god that knowledge would have saved me &lt;strong&gt;hours&lt;/strong&gt;!!&lt;/p&gt;
&lt;p&gt;So&amp;hellip; here&amp;rsquo;s how to generate a WireGuard keypair, in Windows, without the GUI. Since system32 is in the path, you can run this from anywhere. The below will create WireGuard.priv and WireGuard.pub in your AppData folder:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PS C:\&amp;gt; wg genkey | tee $ENV:APPDATA\WireGuard.priv | wg pubkey &amp;gt; $ENV:APPDATA\WireGuard.pub
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PS C:\&amp;gt; cat $ENV:APPDATA\WireGuard.*
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uIGDK+LMDZANniFxrofIpu/hUyezuwCM7qSDVVO+1Gw=
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;85MxGcWutHJsjFggiZ+J4/vsNYDVEa8zYk53DQZCwyE=
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;AWESOME.&lt;/em&gt;&lt;/strong&gt; Next step is to zoink that into a handy-dandy config file. (More accurately, next step is to delete that private key that I&amp;rsquo;ve now posted to the internets)&lt;/p&gt;
&lt;p&gt;Right, so it &lt;em&gt;looks&lt;/em&gt; like I can&amp;rsquo;t just create a text-based wg0.conf file like I do in Linux. When I do, I get this error:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PS C:\Users&amp;gt; wg setconf wg0 .\wg0.conf
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Line unrecognized: ` ■[&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Configuration parsing error
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I thought this might be the file encoding, so I tried it in ANSI etc, but then I learned that Wireguard for Windows stores it&amp;rsquo;s config files in &lt;code&gt;C:\Windows\System32\config\systemprofile\AppData\Local\WireGuard\Configurations\&lt;/code&gt; &amp;hellip; and they&amp;rsquo;re not in plain text. They&amp;rsquo;re stored with the Windows Data Protection API (DPAPI), so perhaps that&amp;rsquo;s what wireguard.exe is expecting?&lt;/p&gt;
&lt;p&gt;Either way, I&amp;rsquo;ve been playing with this for quite a long time now, so I&amp;rsquo;m off to take a break for the night or so. Once I figure out how to create a WireGuard config file for an interface I&amp;rsquo;ll post a new article. Hope you enjoyed reading so far!&lt;/p&gt;</description></item><item><title>New things I didn't know about WireGuard</title><link>https://www.ericlight.com/post/wg3.html</link><pubDate>Thu, 27 Dec 2018 00:00:00 +1300</pubDate><guid>https://www.ericlight.com/post/wg3.html</guid><description>&lt;p&gt;This is part of my &lt;a class="link" href="https://www.ericlight.com/post/wg0.html" &gt;brief&lt;/a&gt; &lt;a class="link" href="https://www.ericlight.com/post/wg1.html" &gt;series&lt;/a&gt; &lt;a class="link" href="https://www.ericlight.com/post/wg2.html" &gt;on&lt;/a&gt; &lt;a class="link" href="https://wireguard.com/" target="_blank" rel="noopener"
 &gt;WireGuard&lt;/a&gt;. I&amp;rsquo;m pretty enamoured with WireGuard and the way it works, and I&amp;rsquo;ve been using it pretty seamlessly for over a year now. I&amp;rsquo;ve learned a couple things that weren&amp;rsquo;t immediately obvious though, so I&amp;rsquo;m documenting them here.&lt;/p&gt;
&lt;h2 id="easy-provisioning"&gt;Easy Provisioning
&lt;/h2&gt;&lt;p&gt;Samuel Holland mentioned an interesting trinket, in his post at &lt;a class="link" href="https://lists.zx2c4.com/pipermail/WireGuard/2018-December/003703.html" target="_blank" rel="noopener"
 &gt;https://lists.zx2c4.com/pipermail/WireGuard/2018-December/003703.html&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;[&amp;hellip;] WireGuard will ignore a peer whose public key matches the interface&amp;rsquo;s private key. So you can distribute a single list of peers everywhere.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You can combine this with &lt;code&gt;wg addconf&lt;/code&gt; like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Each peer has its own &lt;code&gt;/etc/WireGuard/wg0.conf&lt;/code&gt; file, which only contains it&amp;rsquo;s &lt;code&gt;[Interface]&lt;/code&gt; section&lt;/li&gt;
&lt;li&gt;Each peer also has a shared &lt;code&gt;/etc/WireGuard/peers.conf&lt;/code&gt; file, which contains all the peers&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;wg0.conf&lt;/code&gt; file also has a PostUp hook, calling &lt;code&gt;wg addconf /etc/WireGuard/peers.conf&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It&amp;rsquo;s up to you to decide how you want to share the peers.conf, be it via a proper orchestration platform, something much more pedestrian like Dropbox, or something kinda wild like Ceph. I dunno, but it&amp;rsquo;s pretty great that you can just wildly fling a peer section around, without worrying whether it&amp;rsquo;s the same as the interface.&lt;/p&gt;
&lt;h2 id="setting-private-key-from-a-file"&gt;Setting Private Key from a file
&lt;/h2&gt;&lt;p&gt;Another piece of learning, courtesy of Samuel Holland, at &lt;a class="link" href="https://lists.zx2c4.com/pipermail/WireGuard/2018-December/003702.html" target="_blank" rel="noopener"
 &gt;https://lists.zx2c4.com/pipermail/WireGuard/2018-December/003702.html&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can read in a file as the Private Key by doing something like:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;PostUp = wg set %i private-key /etc/WireGuard/wg0.key&lt;/code&gt;&lt;/p&gt;</description></item><item><title>WireGuard - Part Three (Troubleshooting)</title><link>https://www.ericlight.com/post/wg2.html</link><pubDate>Mon, 12 Jun 2017 00:00:00 +1200</pubDate><guid>https://www.ericlight.com/post/wg2.html</guid><description>&lt;p&gt;This is part of my &lt;a class="link" href="https://www.ericlight.com/post/wg0.html" &gt;brief&lt;/a&gt; &lt;a class="link" href="https://www.ericlight.com/post/wg1.html" &gt;series&lt;/a&gt; on &lt;a class="link" href="https://wireguard.com/" target="_blank" rel="noopener"
 &gt;WireGuard&lt;/a&gt;. I&amp;rsquo;m pretty enamoured with WireGuard and the way it works, but there were a couple slightly curly bits that I needed to get my head around. This troubleshooting guide is a rough dump of the issues I had, and how I fixed them.&lt;/p&gt;
&lt;h2 id="gotten-stuck"&gt;Gotten Stuck?
&lt;/h2&gt;&lt;p&gt;At this stage, there are actually a few ways that this can go wrong, even though we haven&amp;rsquo;t done much. Think through all the bits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Installed WireGuard at both ends&lt;/li&gt;
&lt;li&gt;Set up your NAT rule on the remote side&lt;/li&gt;
&lt;li&gt;Created a private and public key on each side&lt;/li&gt;
&lt;li&gt;Put each public key in the opposite side&amp;rsquo;s [Peer] config&lt;/li&gt;
&lt;li&gt;Put a suitable IP address on each side&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="troubleshooting"&gt;Troubleshooting
&lt;/h2&gt;&lt;p&gt;There are, actually, a myriad of ways this can fail:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Broken routing on the client PC&lt;/li&gt;
&lt;li&gt;Broken NAT on the remote router&lt;/li&gt;
&lt;li&gt;Broken routing on the remote PC&lt;/li&gt;
&lt;li&gt;Broken wg0 configuration on one side&lt;/li&gt;
&lt;li&gt;Lack of TCP forwarding on the remote computer&lt;/li&gt;
&lt;li&gt;Lack of Proxy ARP on the remote computer&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you can&amp;rsquo;t ping the remote server yet, don&amp;rsquo;t panic. Run tcpdump to find out what you&amp;rsquo;re missing.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On the remote server: &lt;code&gt;tcpdump -i wg0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;On your local machine: &lt;code&gt;ping -c1 10.20.40.1&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That will tell you whether your packets are reaching the remote server, or if they&amp;rsquo;re not getting through the tunnel.&lt;/p&gt;
&lt;p&gt;If they&amp;rsquo;re not making it through the tunnel at all, you&amp;rsquo;ll probably be seeing error messages in the ping. For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;PING 10.20.10.1 (10.20.10.1) 56(84) bytes of data.
From 10.20.40.2 icmp_seq=1 Destination Host Unreachable
ping: sendmsg: Required key not available
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That&amp;rsquo;s the error message I got when I set AllowedIPs too strictly. Because I was trying to ping something that was &lt;strong&gt;routable&lt;/strong&gt;, but wasn&amp;rsquo;t within the AllowedIPs range, there was no applicable key for the packet.&lt;/p&gt;
&lt;h2 id="thanks"&gt;Thanks
&lt;/h2&gt;&lt;p&gt;Huge gratitude to &lt;a class="link" href="https://www.zx2c4.com/" target="_blank" rel="noopener"
 &gt;Jason Donenfeld&lt;/a&gt; (aka zx2c4) for spending his time not only reading this post, but also for sending me some fantastic feedback! I&amp;rsquo;d made some bungles in my original post on this topic, and he vastly helped my understanding.&lt;/p&gt;
&lt;p&gt;Also, huge gratitude to another Jason (&lt;a class="link" href="https://keybase.io/rendition" target="_blank" rel="noopener"
 &gt;@rendition&lt;/a&gt;) who has helped me develop from a junior network admin into a &amp;hellip; &amp;lsquo;moderate&amp;rsquo; network admin. I&amp;rsquo;ve learned more in the last year than I ever thought possible. He&amp;rsquo;s taught me nearly everything I know about managed networking, reviewed this post for me, and is actually the guy who introduced me to WireGuard originally!&lt;/p&gt;</description></item><item><title>WireGuard - Part Two (VPN routing)</title><link>https://www.ericlight.com/post/wg1.html</link><pubDate>Sun, 11 Jun 2017 00:00:00 +1200</pubDate><guid>https://www.ericlight.com/post/wg1.html</guid><description>&lt;p&gt;This is a continuation of my brief series on the new &lt;a class="link" href="https://wireguard.com/" target="_blank" rel="noopener"
 &gt;WireGuard&lt;/a&gt; VPN. &lt;a class="link" href="https://www.ericlight.com/post/wg0.html" &gt;Part One&lt;/a&gt; was about the simple building-blocks to get WireGuard working between two endpoints. Now that we&amp;rsquo;ve got a couple machines able to ping each other by IP address, we can carry on a bit deeper into the inter-LAN routing stuff.&lt;/p&gt;
&lt;p&gt;Extending on from the IP addresses in Part One, instead of JUST connecting to the remote machine, I want to actually have access to everything &lt;em&gt;on the whole 10.20.0.0/16 network&lt;/em&gt;; even the non-WireGuard devices. I want it to be like I&amp;rsquo;m there on-site. The idea here is roughly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Remote machine:&lt;/strong&gt; wg0: 10.20.40.1 (behind public IP 163.172.161.0)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local machine:&lt;/strong&gt; wg0: 10.20.40.2 (with eth0 on 192.168.88.207)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Machines on remote LAN:&lt;/strong&gt; 10.20.0.0/16&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Remote LAN Watchguard range:&lt;/strong&gt; 10.20.40.0/16 &amp;ndash; note this is within the remote 10.20.0.0/16 range&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;From my local machine, with minimal interaction, I want to be able to ping something like 10.20.&lt;strong&gt;10.30&lt;/strong&gt;, and get a response.&lt;/p&gt;
&lt;p&gt;Happily, now that the two endpoints are talking with each other, there&amp;rsquo;s really not much that has to happen to get things working the way I want.&lt;/p&gt;
&lt;h2 id="remote-config"&gt;Remote Config
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Many Linux distros disable IPv4 packet forwarding by default. But in this case, we very much want this enabled. Edit your &lt;code&gt;/etc/sysctl.conf&lt;/code&gt; file, and look for the line: &lt;code&gt;net.ipv4.ip_forward&lt;/code&gt;, and set the value to 1. You may need to add this line manually, or uncomment it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You&amp;rsquo;ll also need to enable ProxyARP. This is another kernel setting that&amp;rsquo;s usually disabled, so edit &lt;code&gt;/etc/sysctl.conf&lt;/code&gt;, and add the following line: &lt;code&gt;net.ipv4.conf.all.proxy_arp = 1&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Reload your kernel settings. A reboot will do the trick, or you could just run &lt;code&gt;sudo sysctl -p /etc/sysctl.conf&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="starting-wireguard-on-boot"&gt;Starting WireGuard on Boot
&lt;/h2&gt;&lt;p&gt;There are a variety options to do this, and if you&amp;rsquo;re a seasoned sysadmin you probably already have a favourite way.&lt;/p&gt;
&lt;p&gt;One option is to add &lt;code&gt;post-up wg-quick up wg0&lt;/code&gt; to the tail of your eth0 block (or appropriate interface) in /etc/network/interfaces.&lt;/p&gt;
&lt;p&gt;A second option (for systemd users) is to simply run &lt;code&gt;systemctl enable wg-quick@wg0&lt;/code&gt;. This will tell systemd to bring the wg0 interface up once a network connection is established.&lt;/p&gt;
&lt;p&gt;I only do this on the remote machine, because I don&amp;rsquo;t want my local machine to be forever spinning up it&amp;rsquo;s WireGuard connection; however I always want the remote machine listening for my packets. That said, there&amp;rsquo;s probably no reason to avoid this; I just haven&amp;rsquo;t done it yet.&lt;/p&gt;
&lt;h2 id="local-config"&gt;Local Config
&lt;/h2&gt;&lt;p&gt;Here&amp;rsquo;s the really cool bit. Since your remote machine is now set up to perform IPv4 forwaring and ProxyARP, the only thing you need to change on the local side is a single number. Or rather, a couple numbers.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In your &lt;code&gt;/etc/WireGuard/wg0.conf&lt;/code&gt; file, just expand the network range of your interface to include the entire remote LAN:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; [Interface]
 ...
 Address = 10.20.40.2/16

 [Peer]
 ...
 AllowedIPs = 10.20.0.0/16
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now reload your WireGuard config, either by rebooting, or running &lt;code&gt;sudo wg-quick down wg0 &amp;amp;&amp;amp; sudo wg-quick up wg0&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;rsquo;s all! When you make the above changes, wg-quick will modify your routing table so that &lt;strong&gt;any IP within 10.20.x.y&lt;/strong&gt; will be sent over the wg0 interface. The remote host will dutifully forward the packet out into the rest of the network, and ProxyARP will take care of the rest:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ ping -c1 10.20.10.31
PING 10.20.10.31 (10.20.10.31) 56(84) bytes of data.
64 bytes from 10.20.10.31: icmp_seq=1 ttl=63 time=91.8 ms
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id="troubleshooting"&gt;Troubleshooting
&lt;/h2&gt;&lt;p&gt;Okay so by now there&amp;rsquo;s a really good chance that you&amp;rsquo;ve bumped into trouble. I&amp;rsquo;ve started on a basic &lt;a class="link" href="https://www.ericlight.com/post/wg2.html" &gt;WireGuard troubleshooting guide&lt;/a&gt;, but it only covers the issues that I bumped into. If you&amp;rsquo;re still stuck after reading through that, ask a question on the WireGuard Mailing List, or reach out via IRC (#WireGuard on Freenode) - this is all on &lt;a class="link" href="https://www.wireguard.com/#contact-the-team" target="_blank" rel="noopener"
 &gt;the WireGuard website&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="wrap-up"&gt;Wrap-up
&lt;/h2&gt;&lt;p&gt;That should be all! When you reboot the remote server (I specify reboot, because you want to test that your solution can survive an outage at the remote site), you should be able to ping other things in the remote LAN without any additional interaction. I still manually run &lt;code&gt;wg-quick up wg0&lt;/code&gt; on my local laptop, because I don&amp;rsquo;t want to be connected remotely &lt;em&gt;all&lt;/em&gt; the time.&lt;/p&gt;
&lt;h2 id="thanks"&gt;Thanks
&lt;/h2&gt;&lt;p&gt;Huge gratitude to &lt;a class="link" href="https://www.zx2c4.com/" target="_blank" rel="noopener"
 &gt;Jason Donenfeld&lt;/a&gt; (aka zx2c4) for spending his time not only reading this post, but also for sending me some fantastic feedback! I&amp;rsquo;d made some bungles in my original post on this topic, and he vastly helped my understanding.&lt;/p&gt;
&lt;p&gt;If you do end up using WireGuard, &lt;em&gt;go forth and &lt;a class="link" href="https://www.wireguard.com/#donations" target="_blank" rel="noopener"
 &gt;donate&lt;/a&gt;&lt;/em&gt;! Seriously, &lt;strong&gt;at very least&lt;/strong&gt;, send Jason the cost of a local cup of coffee or a beer for his efforts.&lt;/p&gt;
&lt;p&gt;Also, huge gratitude to another Jason (&lt;a class="link" href="https://keybase.io/rendition" target="_blank" rel="noopener"
 &gt;@rendition&lt;/a&gt;) who has helped me develop from a junior network admin into a &amp;hellip; &amp;lsquo;moderate&amp;rsquo; network admin. I&amp;rsquo;ve learned more in the last year than I ever thought possible. He&amp;rsquo;s taught me nearly everything I know about managed networking, reviewed this post for me, and is actually the guy who introduced me to WireGuard originally!&lt;/p&gt;</description></item><item><title>WireGuard - Part One (Installation)</title><link>https://www.ericlight.com/post/wg0.html</link><pubDate>Sat, 03 Jun 2017 00:00:00 +1200</pubDate><guid>https://www.ericlight.com/post/wg0.html</guid><description>&lt;p&gt;&lt;a class="link" href="https://wireguard.com/" target="_blank" rel="noopener"
 &gt;WireGuard&lt;/a&gt; is the most excellent VPN stack around. It&amp;rsquo;s &lt;em&gt;really&lt;/em&gt; fast, the concept of Cryptokey Routing is awesome, and I love the speed and simplicity benefits that come from opionionated cryptography. The protocol is so simple - expressed in a mere 4k lines of code - that it&amp;rsquo;s auditable by anyone.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;But.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;With my initial naive approach, I found myself using HTTPS, over ports forwarded over SSH tunnels, connected over WireGuard. Although it was straightforward to get WireGuard working between two endpoints, I ended up in nested-crypto hell.&lt;/p&gt;
&lt;p&gt;So, this brief series is about making WireGuard work as a VPN onto a different site. We&amp;rsquo;ll start by making it work between two endpoints, and &lt;a class="link" href="https://www.ericlight.com/post/wg1.html" &gt;we&amp;rsquo;ll go forward from there&lt;/a&gt;. My end goal is to have access to all the resources on a remote site, just by running &lt;code&gt;wg-quick up wg0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The endpoints I&amp;rsquo;m going to set up are at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Remote machine:&lt;/strong&gt; wg0: 10.20.40.1 (behind public IP 163.172.161.0)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local machine:&lt;/strong&gt; wg0: 10.20.40.2&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="nat-setup"&gt;NAT Setup
&lt;/h2&gt;&lt;p&gt;Chances are, your remote endpoint is behind a firewall of some sort. Pick a high port, and configure your firewall to forward UDP packets on that port through to your remote WireGuard endpoint. You don&amp;rsquo;t need to do this on your local side, because reply traffic from the remote side will generally be handled by the stateful session part of your firewall.&lt;/p&gt;
&lt;p&gt;Many routers and firewalls offer port address translation (also known as PAT) as part of port forwarding or NAT. This is when a packet hits the firewall on (say) port 57432, and the firewall puts it on the LAN to port 22, for example. You don&amp;rsquo;t want this. I think it&amp;rsquo;s possible with WireGuard, but it adds complexity without benefit.&lt;/p&gt;
&lt;h2 id="config---remote-site"&gt;Config - Remote Site
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class="link" href="https://www.wireguard.com/install/" target="_blank" rel="noopener"
 &gt;Install WireGuard&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Generate your keys. The following will create a public key and a stub config in /etc/WireGuard/:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; cd /etc/WireGuard
 umask 077
 printf &amp;quot;[Interface]\nPrivateKey = &amp;quot; &amp;gt; wg0.conf
 wg genkey | tee -a wg0.conf | wg pubkey &amp;gt; publickey
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Edit your config to match:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; [Interface]
 PrivateKey = WhAt3v3R= (this is the private key generated on this machine)
 ListenPort = 12345 (this is the UDP port you've forwarded from your firewall)
 Address = 10.20.40.1/24 (this will be the IP given to the wg0 interface)

 [Peer]
 PublicKey = (leave this blank for now; you'll paste in your local public key here soon)
 AllowedIPs = 10.20.40.0/24 (this is the range of WireGuard IP addresses that this Peer's key can be used from)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;That should be all you need to configure on the remote side for now. Save your wg0.conf file, and bring the interface up:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; wg-quick up wg0
 ping -c1 10.20.40.1
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You should see a bunch of actions performed by wg-quick, and a reply packet from your ping. Now onto the local side.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="config---local-machine"&gt;Config - Local Machine
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Install WireGuard and generate your keys, as per the first two steps above.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Edit your configuration again:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; [Interface]
 PrivateKey = WhAt3v3R+PaRt-tw0= (this is the private key generated on this machine)
 ListenPort = 12345 (this is the UDP port again; I don't think they have to be the same)
 Address = 10.20.40.2/24 (note - different IP address, but in the same range)

 [Peer]
 PublicKey = ?????????? (copy the public key from the REMOTE server here)
 Endpoint = 163.172.161.0:12345 (enter the PUBLIC IP address of the remote site, plus the forwarded port)
 AllowedIPs = 10.20.40.0/24 (specifying that packets using this key must come from within 10.20.40.x)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now that you&amp;rsquo;ve got a local public key, take a second to paste it into the Peer public key section on the remote server.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you&amp;rsquo;re finished you should be able to bring the interface up and ping it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; wg-quick up wg0
 ping -c1 10.20.40.2
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&amp;hellip; and you should even be able to ping the remote server as well:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; ping -c1 10.20.40.1
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="gotten-stuck"&gt;Gotten Stuck?
&lt;/h2&gt;&lt;p&gt;At this stage, there are actually a few ways that this can go wrong, even though we haven&amp;rsquo;t done much. Here&amp;rsquo;s a quick summary of everything we&amp;rsquo;ve done:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Installed WireGuard at both ends&lt;/li&gt;
&lt;li&gt;Set up your NAT rule on the remote side&lt;/li&gt;
&lt;li&gt;Created a private and public key on each side&lt;/li&gt;
&lt;li&gt;Put each public key in the opposite side&amp;rsquo;s [Peer] config&lt;/li&gt;
&lt;li&gt;Put a suitable IP address on each side&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you&amp;rsquo;ve nailed each of those and you&amp;rsquo;re still having trouble, you can have a quick look at the brief Troubleshooting guide I&amp;rsquo;ve put together as &lt;a class="link" href="https://www.ericlight.com/post/wg2.html" &gt;Part Three&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="onto-part-two"&gt;Onto Part Two
&lt;/h2&gt;&lt;p&gt;That should be all you need to get WireGuard working between two machines on two different sites. So far we haven&amp;rsquo;t done anything either interesting or uncommon - this is all the basic stuff you&amp;rsquo;ll find on the &lt;a class="link" href="https://www.wireguard.com/quickstart/" target="_blank" rel="noopener"
 &gt;WireGuard Quick Start&lt;/a&gt; page, although expressed slightly differently. &lt;a class="link" href="https://www.ericlight.com/post/wg1.html" &gt;The next article&lt;/a&gt; will be a bit more about intra-site routing.&lt;/p&gt;
&lt;h2 id="thanks"&gt;Thanks
&lt;/h2&gt;&lt;p&gt;Huge gratitude to &lt;a class="link" href="https://www.zx2c4.com/" target="_blank" rel="noopener"
 &gt;Jason Donenfeld&lt;/a&gt; (aka zx2c4) for spending his time not only reading this post, but also for sending me some fantastic feedback! I&amp;rsquo;d made some bungles in my original post on this topic, and he vastly helped my understanding.&lt;/p&gt;
&lt;p&gt;If you do end up using WireGuard, &lt;em&gt;go forth and &lt;a class="link" href="https://www.wireguard.com/#donations" target="_blank" rel="noopener"
 &gt;donate&lt;/a&gt;&lt;/em&gt;! Seriously, &lt;strong&gt;at very least&lt;/strong&gt;, send Jason the cost of a local cup of coffee or a beer for his efforts.&lt;/p&gt;
&lt;p&gt;Also, huge gratitude to another Jason (&lt;a class="link" href="https://keybase.io/rendition" target="_blank" rel="noopener"
 &gt;@rendition&lt;/a&gt;) who has helped me develop from a junior network admin into a &amp;hellip; &amp;lsquo;moderate&amp;rsquo; network admin. I&amp;rsquo;ve learned more in the last year than I ever thought possible. He&amp;rsquo;s taught me nearly everything I know about managed networking, reviewed this post for me, and is actually the guy who introduced me to WireGuard originally!&lt;/p&gt;</description></item></channel></rss>