<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>HomeLAB on Zet’s playground</title>
    <link>https://blog.zet.tw/en/categories/homelab/</link>
    <description>Recent content in HomeLAB on Zet’s playground</description>
    <image>
      <title>Zet’s playground</title>
      <url>https://blog.zet.tw/img/blog-cover.png</url>
      <link>https://blog.zet.tw/img/blog-cover.png</link>
    </image>
    <generator>Hugo -- 0.139.0</generator>
    <language>en</language>
    <lastBuildDate>Sat, 26 Nov 2022 00:00:00 +0800</lastBuildDate>
    <atom:link href="https://blog.zet.tw/en/categories/homelab/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Setting up a KMS Server</title>
      <link>https://blog.zet.tw/en/posts/2022-11-26-kms/</link>
      <pubDate>Sat, 26 Nov 2022 00:00:00 +0800</pubDate>
      <guid>https://blog.zet.tw/en/posts/2022-11-26-kms/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Do not use this in production; it is for testing purposes only.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Schools usually run a KMS Server as an activation method for volume licensing of Windows and Office. Here are a few open-source projects you can use for testing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/Wind4/vlmcsd&#34;&gt;vlmcsd&lt;/a&gt; - written in C (it includes a Docker deployment method)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/Py-KMS-Organization/py-kms&#34;&gt;Py-KMS-Organization/py-kms&lt;/a&gt; - written in Python&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Py-KMS-Organization/py-kms is a fork of &lt;a href=&#34;https://github.com/SystemRage/py-kms&#34;&gt;SystemRage/py-kms&lt;/a&gt; that is still being actively maintained.&lt;/p&gt;
&lt;p&gt;You can also spin it up easily with docker:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<blockquote>
<p>Do not use this in production; it is for testing purposes only.</p>
</blockquote>
<p>Schools usually run a KMS Server as an activation method for volume licensing of Windows and Office. Here are a few open-source projects you can use for testing:</p>
<ul>
<li><a href="https://github.com/Wind4/vlmcsd">vlmcsd</a> - written in C (it includes a Docker deployment method)</li>
<li><a href="https://github.com/Py-KMS-Organization/py-kms">Py-KMS-Organization/py-kms</a> - written in Python</li>
</ul>
<p>Py-KMS-Organization/py-kms is a fork of <a href="https://github.com/SystemRage/py-kms">SystemRage/py-kms</a> that is still being actively maintained.</p>
<p>You can also spin it up easily with docker:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>docker run -d --name py-kms --restart always -p 1688:1688 ghcr.io/py-kms-organization/py-kms
</span></span></code></pre></div><p>Use the <a href="https://py-kms.readthedocs.io/en/latest/Keys.html">GVLK Keys list</a> together with the KMS server to activate Windows and Office. For a detailed walkthrough see <a href="https://py-kms.readthedocs.io/en/latest/Usage.html#activation-procedure">py-kms: Activation Procedure</a>.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Using Cloudflare Tunnel for NAT traversal, with Gitea as an example</title>
      <link>https://blog.zet.tw/en/posts/2022-11-07-cloudflare-tunnels-gitea/</link>
      <pubDate>Mon, 07 Nov 2022 00:00:00 +0800</pubDate>
      <guid>https://blog.zet.tw/en/posts/2022-11-07-cloudflare-tunnels-gitea/</guid>
      <description>&lt;p&gt;Often you run many services on your LAN, and when you need to reach them from outside you usually do it with port forwarding. Here I use Cloudflare Tunnel instead — no port forwarding on the router is needed, and you can add two-factor authentication via Email OTP, which improves both convenience and security.&lt;/p&gt;
&lt;p&gt;It works for a NAS, a Git server, a Virtual Machine Manager, and more on your LAN.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Often you run many services on your LAN, and when you need to reach them from outside you usually do it with port forwarding. Here I use Cloudflare Tunnel instead — no port forwarding on the router is needed, and you can add two-factor authentication via Email OTP, which improves both convenience and security.</p>
<p>It works for a NAS, a Git server, a Virtual Machine Manager, and more on your LAN.</p>
<h1 id="gitea">Gitea</h1>
<p>Gitea is much lighter than GitLab. Using mirroring to back up projects on GitHub that might disappear at any time is very handy.</p>
<p>For installing with docker, see <a href="https://docs.gitea.io/en-us/install-with-docker/">https://docs.gitea.io/en-us/install-with-docker/</a>.</p>
<p>Here are some config options I personally use:</p>
<ul>
<li>Let gitea search code easily</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>[indexer]
</span></span><span style="display:flex;"><span>REPO_INDEXER_ENABLED = true
</span></span></code></pre></div><ul>
<li>Customize the URL and listen port shown on the page. For the landing page, if the visitor isn&rsquo;t logged in you can point them straight to the login page on open, instead of Gitea&rsquo;s home page.</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>[server]
</span></span><span style="display:flex;"><span>PROTOCOL         = https
</span></span><span style="display:flex;"><span>DOMAIN           = git.test.tw
</span></span><span style="display:flex;"><span>SSH_DOMAIN       = git-ssh.test.tw
</span></span><span style="display:flex;"><span>SSH_LISTEN_PORT  = 11022
</span></span><span style="display:flex;"><span>HTTP_PORT        = 3000
</span></span><span style="display:flex;"><span>ROOT_URL         = https://git.test.tw
</span></span><span style="display:flex;"><span>ENABLE_GZIP      = true
</span></span><span style="display:flex;"><span>LANDING_PAGE     = login
</span></span></code></pre></div><ul>
<li>Remove the footer info, version and load time from the page</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>[other]
</span></span><span style="display:flex;"><span>SHOW_FOOTER_BRANDING = false
</span></span><span style="display:flex;"><span>SHOW_FOOTER_VERSION = false
</span></span><span style="display:flex;"><span>SHOW_FOOTER_TEMPLATE_LOAD_TIME = false
</span></span></code></pre></div><p>For detailed settings see the
<a href="https://docs.gitea.io/en-us/config-cheat-sheet/">Gitea Configuration Cheat Sheet </a> and customize as you like.</p>
<h1 id="setup-cloudflare-tunnel">Setup Cloudflare Tunnel</h1>
<h2 id="run-cloudflared-service">Run Cloudflared Service</h2>
<p>First you need a domain hosted on Cloudflare. Find Zero Trust in the sidebar.</p>
<p><img loading="lazy" src="/img/cloudflare-tunnel/cloudflare-dashboard.png" alt=""  />
</p>
<p>Once opened, find Tunnel.</p>
<p><img loading="lazy" src="/img/cloudflare-tunnel/add-tunnels.png" alt=""  />
</p>
<p>After naming it, you can choose the platform on which to run the tunnel service. I like running it on docker — just paste the command, and you can add <code>--restart=always</code> and <code>-d</code> flags as you prefer.</p>
<p><img loading="lazy" src="/img/cloudflare-tunnel/docker-tunnel.png" alt=""  />
</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>docker run --restart<span style="color:#f92672">=</span>always -d cloudflare/cloudflared:latest tunnel --no-autoupdate run --token <span style="color:#f92672">[</span>your_token_here<span style="color:#f92672">]</span>
</span></span></code></pre></div><p>For synology, you can specify the command in the advanced settings — just paste in the string after the image.</p>
<p><img loading="lazy" src="/img/cloudflare-tunnel/synology-cmd.png" alt=""  />
</p>
<p>If it succeeds, you should see the Status on the Tunnels page turn a green <strong>ACTIVE</strong>.</p>
<h2 id="add-tunnel">Add Tunnel</h2>
<p>Fill in the subdomain and pick which service to forward below. There are many protocols to choose from, e.g. https, http, ssh, RDP; the URL after it takes the internal host and port.</p>
<blockquote>
<p>If you want to <code>git ssh clone</code>, choose SSH as the protocol and follow it with ip:port.</p>
</blockquote>
<blockquote>
<p>Note: if you have a private HTTPS certificate, you can select No TLS Verify so Cloudflare Tunnel can connect smoothly.</p>
</blockquote>
<p><img loading="lazy" src="/img/cloudflare-tunnel/add-tunnel.png" alt=""  />
</p>
<p>Once added successfully, you should see a CNAME automatically added to the domain&rsquo;s DNS.</p>
<p><img loading="lazy" src="/img/cloudflare-tunnel/check-cname.png" alt=""  />
</p>
<p>At this point just try connecting and it should work.</p>
<h2 id="auth">Auth</h2>
<blockquote>
<p>Some services may be inconvenient with Auth attached, so adjust as you see fit. I haven&rsquo;t tested Gitea&rsquo;s web with it — you can experiment; I&rsquo;m not sure whether https clone will have issues.</p>
</blockquote>
<p>With the setup above, http/https services are now reachable from outside. If you want to add another layer of protection, you can use the Access - Application feature: add a <code>Self-hosted</code> Application and set the subdomain.</p>
<p><img loading="lazy" src="/img/cloudflare-tunnel/applications.png" alt=""  />
</p>
<p>Then add a policy. Under <code>Configure rules</code> you can add the rules you want within this application&rsquo;s scope (subdomain). Choosing email will prompt you for an OTP on the verification page before you can log in; there are also IP range, Country and Token methods — lots of ways to freely combine rules.</p>
<p><img loading="lazy" src="/img/cloudflare-tunnel/policy.png" alt=""  />
</p>
<p>Finally, when you access it, you should see the page asking for email authentication.</p>
<p><img loading="lazy" src="/img/cloudflare-tunnel/access.png" alt=""  />
</p>
<h2 id="git-ssh">Git ssh</h2>
<p>After the tunnel setup, going into Gitea you should see a clean clone address:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>via https
</span></span><span style="display:flex;"><span>https://git.test.tw/mirror/Windows-Exploit-Suggester.git
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>via ssh
</span></span><span style="display:flex;"><span>git@git-ssh.test.tw:mirror/Windows-Exploit-Suggester.git
</span></span></code></pre></div><p>No more ugly IPs or port numbers.</p>
<p>Note that because SSH is being forwarded, you need some extra config in your local ssh config. On the client machine, install <code>cloudflared</code>, which you can install easily with homebrew or scoop.</p>
<p>Edit <code>~/.ssh/config</code> in your home directory and add a <code>ProxyCommand</code> that chains to <code>cloudflared</code>; then ssh clone will work normally:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>Host git.test.com
</span></span><span style="display:flex;"><span>  ProxyCommand cloudflared access ssh --hostname %h
</span></span></code></pre></div><p>If you hit snags along the way, you can also refer to Cloudflare&rsquo;s official docs
<a href="https://developers.cloudflare.com/cloudflare-one/tutorials/gitlab/">Zero Trust GitLab SSH &amp; HTTP
</a></p>
<h1 id="in-the-end">In The End</h1>
<p>Cloudflare Tunnel can forward many internal services without opening port forwarding — a great thing. Paired with the Zero Trust concept to protect your assets, important services on your home NAS can be both protected and conveniently accessible.</p>
<p>There are tons more ways to use it, such as opening a web terminal to access an internal SSH service. See the YouTube video <a href="https://www.youtube.com/watch?v=Z6b3l1z0N7w">HOW TO: Remote access a Raspberry Pi using a Cloudflare tunnel (node-red and ssh).</a></p>
]]></content:encoded>
    </item>
    <item>
      <title>Auto-updating docker containers - watchtower</title>
      <link>https://blog.zet.tw/en/posts/2022-11-06-watchtower/</link>
      <pubDate>Sun, 06 Nov 2022 00:00:00 +0800</pubDate>
      <guid>https://blog.zet.tw/en/posts/2022-11-06-watchtower/</guid>
      <description>&lt;p&gt;I run a bunch of docker containers on Synology and on a few servers, and use watchtower to update their images automatically.&lt;/p&gt;
&lt;p&gt;First set the timezone to Taipei:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sudo timedatectl set-timezone Asia/Taipei
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add the cleanup and schedule flags:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;docker run -d --restart&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;always &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;--name watchtower &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;-v /var/run/docker.sock:/var/run/docker.sock &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;-v /etc/localtime:/etc/localtime:ro &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;containrrr/watchtower &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;--cleanup &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;--schedule &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;0 0 4 * * *&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;More flags can be found here: &lt;a href=&#34;https://containrrr.dev/watchtower/arguments/&#34;&gt;https://containrrr.dev/watchtower/arguments/&lt;/a&gt;&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I run a bunch of docker containers on Synology and on a few servers, and use watchtower to update their images automatically.</p>
<p>First set the timezone to Taipei:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo timedatectl set-timezone Asia/Taipei
</span></span></code></pre></div><p>Add the cleanup and schedule flags:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>docker run -d --restart<span style="color:#f92672">=</span>always <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>--name watchtower <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>-v /var/run/docker.sock:/var/run/docker.sock <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>-v /etc/localtime:/etc/localtime:ro <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>containrrr/watchtower <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>--cleanup <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>--schedule <span style="color:#e6db74">&#34;0 0 4 * * *&#34;</span>
</span></span></code></pre></div><p>More flags can be found here: <a href="https://containrrr.dev/watchtower/arguments/">https://containrrr.dev/watchtower/arguments/</a></p>
]]></content:encoded>
    </item>
    <item>
      <title>Ad-blocking powerhouse - AdGuard</title>
      <link>https://blog.zet.tw/en/posts/2022-10-16-adguard/</link>
      <pubDate>Sun, 16 Oct 2022 00:00:00 +0800</pubDate>
      <guid>https://blog.zet.tw/en/posts/2022-10-16-adguard/</guid>
      <description>&lt;p&gt;I often pick up second-hand hardware junk to build things with, so I&amp;rsquo;ll keep a &lt;a href=&#34;https://blog.zet.tw/en/categories/homelab/&#34;&gt;HomeLAB&lt;/a&gt; series to document it.&lt;/p&gt;
&lt;h1 id=&#34;installation&#34;&gt;Installation&lt;/h1&gt;
&lt;p&gt;On Unix-like systems you can install it in one line:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also refer to the &lt;a href=&#34;https://github.com/AdguardTeam/AdGuardHome&#34;&gt;official github&lt;/a&gt; and the &lt;a href=&#34;https://github.com/AdguardTeam/AdGuardHome/wiki&#34;&gt;wiki&lt;/a&gt;; it can be installed on docker, a Raspberry Pi, and more.&lt;/p&gt;
&lt;p&gt;Here, since I run an LXC on proxmox and it has its own IP, I just install it as a regular machine.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I often pick up second-hand hardware junk to build things with, so I&rsquo;ll keep a <a href="/en/categories/homelab/">HomeLAB</a> series to document it.</p>
<h1 id="installation">Installation</h1>
<p>On Unix-like systems you can install it in one line:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v
</span></span></code></pre></div><p>You can also refer to the <a href="https://github.com/AdguardTeam/AdGuardHome">official github</a> and the <a href="https://github.com/AdguardTeam/AdGuardHome/wiki">wiki</a>; it can be installed on docker, a Raspberry Pi, and more.</p>
<p>Here, since I run an LXC on proxmox and it has its own IP, I just install it as a regular machine.</p>
<h2 id="address-already-in-use">address already in use</h2>
<p>During installation you may hit the <code>0.0.0.0:53: bind: address already in use</code> error. You can solve it with these steps:</p>
<p>First stop the resolve service:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>systemctl stop systemd-resolved
</span></span></code></pre></div><p>Edit <code>/etc/systemd/resolved.conf</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>[Resolve]
</span></span><span style="display:flex;"><span>DNS=127.0.0.1
</span></span><span style="display:flex;"><span>DNSStubListener=no
</span></span></code></pre></div><p>Re-link it and restart the service:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
</span></span><span style="display:flex;"><span>systemctl restart systemd-resolved
</span></span></code></pre></div><h1 id="dns-settings">DNS settings</h1>
<p>For upstream DNS you can set servers from Google, HiNet, Cloudflare and TWNIC:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-diff" data-lang="diff"><span style="display:flex;"><span>8.8.8.8
</span></span><span style="display:flex;"><span>8.8.4.4
</span></span><span style="display:flex;"><span>168.95.1.1
</span></span><span style="display:flex;"><span>168.95.192.1
</span></span><span style="display:flex;"><span>1.1.1.1
</span></span><span style="display:flex;"><span>1.0.0.1
</span></span><span style="display:flex;"><span>101.101.101.101
</span></span><span style="display:flex;"><span>101.102.103.104
</span></span></code></pre></div><h1 id="blocklists">Blocklists</h1>
<p>You can add your own by referring to <a href="https://firebog.net/;">https://firebog.net/;</a> there are also some built-in ones you can import.</p>
<p><img loading="lazy" src="/img/ADGUARD/blocklist.jpg" alt="blocklist.jpg"  />
</p>
<h1 id="dns-rewrite">DNS rewrite</h1>
<p>If you have services on your LAN, you can use rewrite to set your own domain for easy access.</p>
<p><img loading="lazy" src="/img/ADGUARD/dns-rewrite.jpg" alt=""  />
</p>
<h1 id="config-file">config file</h1>
<p>The whole configuration lives in <code>/opt/AdGuardHome/AdGuardHome.yaml</code>; you can back it up regularly for easier future deployments.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>root@ad-guard:~# ls /opt/AdGuardHome/
</span></span><span style="display:flex;"><span>AdGuardHome  AdGuardHome.sig  AdGuardHome.yaml  CHANGELOG.md  LICENSE.txt  README.md  data
</span></span></code></pre></div><p>A similar service is <a href="https://nextdns.io/">NextDNS</a>, also worth a look.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Setting up a WireGuard VPN on a Raspberry Pi</title>
      <link>https://blog.zet.tw/en/posts/2022-04-03-raspberry-pi-wireguard-vpn/</link>
      <pubDate>Sun, 03 Apr 2022 00:00:00 +0800</pubDate>
      <guid>https://blog.zet.tw/en/posts/2022-04-03-raspberry-pi-wireguard-vpn/</guid>
      <description>&lt;p&gt;I used to run Synology&amp;rsquo;s built-in OpenVPN Server. I had a spare Raspberry Pi lying around and figured I&amp;rsquo;d stand up another VPN server and play with WireGuard at the same time. After trying it out, the speed, configuration and chaining to an internal DNS server all worked without issue, so I&amp;rsquo;ll probably make it my main connection method going forward.&lt;/p&gt;
&lt;h1 id=&#34;raspberry-pi-setting&#34;&gt;Raspberry Pi Setting&lt;/h1&gt;
&lt;p&gt;Flash &lt;code&gt;lite x64&lt;/code&gt; with the official tool and drop in an &lt;code&gt;ssh&lt;/code&gt; file so the SSH server starts automatically:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I used to run Synology&rsquo;s built-in OpenVPN Server. I had a spare Raspberry Pi lying around and figured I&rsquo;d stand up another VPN server and play with WireGuard at the same time. After trying it out, the speed, configuration and chaining to an internal DNS server all worked without issue, so I&rsquo;ll probably make it my main connection method going forward.</p>
<h1 id="raspberry-pi-setting">Raspberry Pi Setting</h1>
<p>Flash <code>lite x64</code> with the official tool and drop in an <code>ssh</code> file so the SSH server starts automatically:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>scoop install raspberry-pi-imager
</span></span></code></pre></div><p>A round of updates:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>sudo apt-get update
</span></span><span style="display:flex;"><span>sudo apt-get dist-upgrade
</span></span><span style="display:flex;"><span>sudo apt-get autoremove
</span></span><span style="display:flex;"><span>sudo apt-get autoclean
</span></span></code></pre></div><p>Use <code>raspi-config</code> to update the <strong>hostname, password</strong> + <strong>expand filesystem</strong> + <strong>time zone</strong>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>sudo raspi-config
</span></span></code></pre></div><p>Update the firmware:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>sudo rpi-update
</span></span></code></pre></div><h1 id="install-pivpn">Install PiVPN</h1>
<p>Install pivpn and choose <strong>WireGuard</strong> as the VPN server. Just fill in the prompts; for DNS you can set a custom IP. I use AdGuard Home for DNS rewrites of my internal services, so I fill in AdGuard&rsquo;s IP.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>curl -L https://install.pivpn.io | bash
</span></span></code></pre></div><p>Here you can check whether the service and the port you configured are up:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>$ sudo wg
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>interface: wg0
</span></span><span style="display:flex;"><span>  public key: ***********
</span></span><span style="display:flex;"><span>  private key: <span style="color:#f92672">(</span>hidden<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  listening port: <span style="color:#ae81ff">5487</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>$ sudo netstat -tunlp
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>udp        <span style="color:#ae81ff">0</span>      <span style="color:#ae81ff">0</span> 0.0.0.0:5487           0.0.0.0:*                           -
</span></span><span style="display:flex;"><span>udp6       <span style="color:#ae81ff">0</span>      <span style="color:#ae81ff">0</span> :::5487                :::*                                -
</span></span></code></pre></div><p>To add a user, just run <code>pivpn -a -n &lt;name&gt;</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-gdscript3" data-lang="gdscript3"><span style="display:flex;"><span><span style="color:#f92672">$</span> pivpn <span style="color:#f92672">-</span>a <span style="color:#f92672">-</span>n test
</span></span><span style="display:flex;"><span>::: Client Keys generated
</span></span><span style="display:flex;"><span>::: Client config generated
</span></span><span style="display:flex;"><span>::: Updated server config
</span></span><span style="display:flex;"><span>::: WireGuard reloaded
</span></span><span style="display:flex;"><span><span style="color:#f92672">======================================================================</span>
</span></span><span style="display:flex;"><span>::: Done<span style="color:#f92672">!</span> test<span style="color:#f92672">.</span>conf successfully created<span style="color:#f92672">!</span>
</span></span><span style="display:flex;"><span>::: test<span style="color:#f92672">.</span>conf was copied to <span style="color:#f92672">/</span>home<span style="color:#f92672">/</span>pi<span style="color:#f92672">/</span>configs <span style="color:#66d9ef">for</span> easy transfer<span style="color:#f92672">.</span>
</span></span><span style="display:flex;"><span>::: Please use this profile only on one device <span style="color:#f92672">and</span> create additional
</span></span><span style="display:flex;"><span>::: profiles <span style="color:#66d9ef">for</span> other devices<span style="color:#f92672">.</span> You can also use pivpn <span style="color:#f92672">-</span>qr
</span></span><span style="display:flex;"><span>::: to generate a QR Code you can scan with the mobile app<span style="color:#f92672">.</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">======================================================================</span>
</span></span></code></pre></div><p>For more commands and usage see the pivpn docs <a href="https://docs.pivpn.io/wireguard/">https://docs.pivpn.io/wireguard/</a>, which cover removing, disabling and listing users, backup and restore, and other settings — for example how to configure it if you also have Pi-hole installed.</p>
<p><code>pivpn -qr</code> shows a QR code in the terminal that you can scan with your phone; on a computer you can just copy the config file under <code>configs</code> and feed it to the computer&rsquo;s client.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span>$ pivpn -qr
</span></span><span style="display:flex;"><span>::  Client list  ::
</span></span><span style="display:flex;"><span>1) test
</span></span><span style="display:flex;"><span>Please enter the Index/Name of the Client to show: 1
</span></span><span style="display:flex;"><span>::: Showing client test below
</span></span><span style="display:flex;"><span>=====================================================================
</span></span></code></pre></div><p>For the WireGuard client, see the official site <a href="https://www.wireguard.com/install/">https://www.wireguard.com/install/</a> to download the right one.</p>
<blockquote>
<p>If you use port forwarding, remember to open the UDP port and configure it.</p>
</blockquote>
<p>Once everything is set up you should see the connected devices:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-fallback" data-lang="fallback"><span style="display:flex;"><span> $ pivpn -c
</span></span><span style="display:flex;"><span>::: Connected Clients List :::
</span></span><span style="display:flex;"><span>Name      Remote IP                 Virtual IP      Bytes Received      Bytes Sent      Last Seen
</span></span><span style="display:flex;"><span>zet       114.136.***.**:35713      10.6.0.2        5.4MiB              36MiB           Apr 03 2022 - 17:57:05
</span></span></code></pre></div><h1 id="misc">Misc</h1>
<p>A few files you may need to modify:</p>
<ul>
<li><code>/etc/wireguard/wg0.conf</code> stores settings like <code>PrivateKey</code> and <code>ListenPort</code>; if you need to change the port or add other settings later, edit it here</li>
<li><code>/etc/pivpn/wireguard/setupVars.conf</code> holds settings such as port, dns and host addr, mainly the extra values used when generating configs and QR codes</li>
</ul>
]]></content:encoded>
    </item>
  </channel>
</rss>
