<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>pudar.net</title>
    <link>https://pudar.net/</link>
    <description>Recent content on pudar.net</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <lastBuildDate>Mon, 25 Mar 2024 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="https://pudar.net/index.xml" rel="self" type="application/rss+xml" />
    
    
    
    <item>
      <title>Modernizing This Site II</title>
      <link>https://pudar.net/modernizing-this-site-ii/</link>
      <pubDate>Mon, 25 Mar 2024 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/modernizing-this-site-ii/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re returning here, you may notice all the previous links have been broken and the site looks pretty different.
This is because I have switched from my old SSG Pelican to Hugo. I&amp;rsquo;m using
the &lt;a href=&#34;https://github.com/LukasJoswiak/etch&#34;&gt;etch&lt;/a&gt; theme, which I like a lot.&lt;/p&gt;
&lt;p&gt;If this was a professional project, I would have ensured all the URLs tracked by Google and friends would resolve to
the correct places, but since this is just my personal blog I don&amp;rsquo;t really care.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m still hosting the site on S3 with CloudFront as CDN, and at some point I also put CloudFlare in front of
CloudFront. This can cause some goofy difficult-to-debug double caching weirdness, but overall has been working well.
It&amp;rsquo;s also been costing me exactly $0 to host over the last three years.&lt;/p&gt;
&lt;p&gt;Before this most recent round of upgrades, I was deploying to S3 using the &lt;code&gt;sync&lt;/code&gt; command from my local machine.
This was not ideal for a whole bunch of reasons, including the need to remember how to use makefiles, so a big
priority was to use GitHub Actions for my CI/CD pipeline. I&amp;rsquo;ll include the pipeline here for reference - there&amp;rsquo;s a
pretty cool option to the S3 command which will automatically invalidate the CloudFront cache.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;Build Hugo site and sync to S3&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;on&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# Runs on pushes targeting the default branch&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;push&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;branches&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;master&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# Allows you to run this workflow manually from the Actions tab&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;workflow_dispatch&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;permissions&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;contents&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;read&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;pages&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;write&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;id-token&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;write&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;concurrency&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;group&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;deploy&amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;cancel-in-progress&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kc&#34;&gt;false&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# Default to bash&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;defaults&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;run&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;shell&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;bash&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;jobs&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# Build job&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;build_deploy&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;environment&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;production&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;runs-on&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;ubuntu-latest&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;env&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;HUGO_VERSION&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;m&#34;&gt;0.120.4&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;steps&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;- &lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;Install Hugo CLI&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;run&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;sd&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;sd&#34;&gt;          wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;sd&#34;&gt;          &amp;amp;&amp;amp; sudo dpkg -i ${{ runner.temp }}/hugo.deb&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;          
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;- &lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;Checkout&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;uses&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;actions/checkout@v4&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;with&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;submodules&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;recursive&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;lfs&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;true&amp;#39;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;- &lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;Build with Hugo&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;env&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# For maximum backward compatibility with Hugo modules&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;HUGO_ENVIRONMENT&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;production&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;HUGO_ENV&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;production&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;run&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;sd&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;sd&#34;&gt;          hugo&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;          
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;- &lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;Set up S3cmd cli tool&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;uses&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;s3-actions/s3cmd@v1.5.0&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;with&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;provider&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;aws&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;region&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;us-east-1&amp;#39;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;access_key&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;${{ secrets.S3_ACCESS_KEY }}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;secret_key&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;${{ secrets.S3_SECRET_KEY }}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;- &lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;Sync site to S3&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;run&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;sd&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;sd&#34;&gt;          s3cmd sync --reduced-redundancy --delete-removed --cf-invalidate --cf-invalidate-default-index public/*  {bucket url here}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;          
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This new CI/CD pipeline is pretty great - I can just add a new .md file to my list of posts, commit it, and push it,
and my pipeline will automatically run and deploy the result.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re going to do this yourself, make sure to create an IAM user specifically for this GitHub Action that has
the least privileges possible. In this case, I only gave it permissions to modify S3 and CloudFront.&lt;/p&gt;
&lt;p&gt;One weird issue I ran into was that the theme was not being applied even though it worked when testing locally. I
opened up dev tools, and saw that the stylesheet was being referenced correctly in the HTML files. I double checked
that the stylesheet was actually being downloaded by looking at the Network tab. This really stumped me for a while,
until I noticed the &lt;code&gt;Content-Type&lt;/code&gt; header on the response was set to &lt;code&gt;text/plain&lt;/code&gt;. I dug into the S3 bucket settings
and found that each object can have a custom &lt;code&gt;Content-Type&lt;/code&gt; set, and my stylesheet had &lt;code&gt;text/plain&lt;/code&gt; set there
somehow, probably by the &lt;code&gt;sync&lt;/code&gt; command. Using the GUI, I manually set the content type to &lt;code&gt;text/css&lt;/code&gt;, and this
corrected the issue and seemed to persist after subsequent deployments. Pretty interesting the browser will only
apply the CSS you&amp;rsquo;re asking to apply if the &lt;code&gt;Content-Type&lt;/code&gt; is set properly on the server side!&lt;/p&gt;
&lt;p&gt;Anyways, this seems to be a much nicer experience overall, so there&amp;rsquo;s a good chance I&amp;rsquo;ll be posting here a bit more
often.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Canon EOS M3 Woes</title>
      <link>https://pudar.net/canon-eos-m3-woes/</link>
      <pubDate>Sun, 24 Mar 2024 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/canon-eos-m3-woes/</guid>
      <description>&lt;p&gt;I haven&amp;rsquo;t posted anything here for a couple of years, but I have been posting some videos to
&lt;a href=&#34;https://www.youtube.com/@JimPudar&#34;&gt;my YouTube channel&lt;/a&gt;. I started out recording using my dad&amp;rsquo;s Canon EOS-1D X with an
external mic plugged in to the camera, but eventually wanted to use a 32-bit recorder to avoid clipping when using loud
power tools. I also wanted to be able to use a lav mic, and someday get a second camera, so I ended up getting a couple
Tentacle Sync Es and a Tentacle Track E.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;DQ3U9660.jpg&#34; alt=&#34;Tentacle Sync and Track Devices&#34;&gt;&lt;/p&gt;
&lt;p&gt;The Tentacle Sync E is a really slick device - it can sync timecode over bluetooth, and has a 3.5mm jack which outputs
the timecode on the left channel and a scratch mic on the right channel. The idea is that you can plug this into
the mic input of any normal DSLR, and when you process the video files later you can convert the left audio channel into
a proper timecode track. With this, you can do cool stuff like multicam editing or use the sync bin very easily in
Davinci Resolve.&lt;/p&gt;
&lt;p&gt;I used the 1D X with a Sync E and recorded audio to the Track E for several videos, and found the process really easy
and foolproof. Well, as long as I didn&amp;rsquo;t forget to press record on the Track E.&lt;/p&gt;
&lt;p&gt;Another camera I inherited from my dad is a Canon EOS M3. This is a small mirrorless camera. I was hoping to
run Magic Lantern on this, but it turns out the M3 is more like a PowerShot than an actual EOS, so this wasn&amp;rsquo;t a
possibility. (CHDK is an option, but doesn&amp;rsquo;t actually do anything I want.)&lt;/p&gt;
&lt;p&gt;I did a few test videos with it, and really enjoyed the focus peaking, as well as the articulating screen. I didn&amp;rsquo;t
bother testing the entire Tentacle workflow with it since I&amp;rsquo;d had absolutely no issues in the past, and went ahead
and ordered a second EOS M3 off Ebay for around $200.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;DQ3U9663.jpg&#34; alt=&#34;Two Canon EOS M3 cameras with Tentacle Sync E&#34;&gt;&lt;/p&gt;
&lt;p&gt;With two cameras, I could easily switch between a wide angle and a macro shot - I was even doing some real multicam
shooting! I filmed two full projects - a CNC electronics cabinet rebuild and a drill press restoration - before
starting to edit them.&lt;/p&gt;
&lt;p&gt;To my horror, my videos shot on the EOS M3s would not sync up with the audio properly!&lt;/p&gt;
&lt;p&gt;I first realised that while the 1D X shot in 29.97 DF, the EOS M3s use 29.97 NDF. Strike one. You need to tell the
Tentacles which frame rate to use, and I filmed both projects with them set to 29.97 DF.&lt;/p&gt;
&lt;p&gt;I then found that even when playing just the right channel, which should contain the scratch audio, I could hear the
timecode signal. Strike two!&lt;/p&gt;
&lt;p&gt;I opened up some of the video files&amp;rsquo; audio tracks in Audacity to figure out what was happening.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s what a good recording of a Tentacle Sync E looks like, made by the EOS-1D X recording in PCM WAV at 48000 Hz.
The timecode signal on the left channel is absolutely perfect - there&amp;rsquo;s no chance even the most naive algorithm could
misread this. The right channel contains the scratch audio track as expected.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;timecode-d1-x.png&#34; alt=&#34;Tentacle Sync E output waveform recorded by Canon EOS-1D X&#34;&gt;&lt;/p&gt;
&lt;p&gt;Now, here&amp;rsquo;s what my recordings from the EOS M3 look like. The M3 records lossy AAC, ostensibly in stereo. You can
see how bad the timecode signal looks on the left channel, and you can also see the timecode signal, sort of leaking
out of phase into the right channel.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;timecode-m3.png&#34; alt=&#34;Tentacle Sync E output waveform recorded by Canon EOS M3&#34;&gt;&lt;/p&gt;
&lt;p&gt;I found some places where there were a lot of loud noises on the scratch track, and sure enough, they were leaking
into the left channel as well. No wonder Davinci Resolve was getting confused about how to read the timecode!&lt;/p&gt;
&lt;p&gt;In order to see what was happening here, I used a function generator to feed a 400 Hz sine signal at 50 mV into the
left channel of the M3 and recorded some video. Here&amp;rsquo;s what the resultant stereo recording looks like. If the camera
was recording stereo properly, the right channel would be completely silent, but we see a dramatic amount of leakage.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;sine-m3.png&#34; alt=&#34;400 Hz sine wave with leakage into other channel&#34;&gt;&lt;/p&gt;
&lt;p&gt;I tried this with both of my EOS M3s and got identical results. I did some sine sweeps throughout the audible spectrum,
and found that the leakage was much higher in amplitude and had a greater phase shift at lower frequencies.
Thankfully, if I fed the same sine signal into both left and right channels, I got a good signal recorded onto
both channels. There&amp;rsquo;s no way to make the Tentacle Sync E output timecode on both channels in software, so I decided
to make some custom cables.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;DQ3U9665.jpg&#34; alt=&#34;Custom 3.5mm patch cables&#34;&gt;&lt;/p&gt;
&lt;p&gt;These cables connect the left channel from the input side to both the left and right channels on the output side.
It&amp;rsquo;s pretty disappointing to lose scratch audio recording, as this has come in handy for me several times, but
having a reliable multicam workflow with timecode is more important to me.&lt;/p&gt;
&lt;p&gt;Hopefully this has been helpful or interesting to you - I certainly would not have purchased a second EOS M3 had I
known its shortcomings in the audio department.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Heathkit IP-32 Restoration</title>
      <link>https://pudar.net/heathkit-ip-32-restoration/</link>
      <pubDate>Wed, 31 Mar 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/heathkit-ip-32-restoration/</guid>
      <description>&lt;p&gt;I wanted a high voltage power supply for experimenting with tube circuits, so I decided to find an old one on Ebay to
restore. I found a listing from the California Historical Radio Society for a Heathkit IP-32 power supply described as
&amp;ldquo;repaired and tested&amp;rdquo;. More on that later, but first a bit of information about the supply:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;B+ output 0 to +400V at 100 mA&lt;/li&gt;
&lt;li&gt;C- output 0 to -100V at 1 mA&lt;/li&gt;
&lt;li&gt;Filament output 6.3V AC at 4A&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The filament output is an isolated winding and the B+ / C- outputs are floating. This means they can either have one end
tied to the chassis or they can be combined in series or parallel with another power supply to increase the available
voltage or current.&lt;/p&gt;
&lt;h2 id=&#34;repaired-and-tested&#34;&gt;Repaired and Tested&lt;/h2&gt;
&lt;p&gt;When I purchased the device on Ebay, I was expecting to do some electrical work on it, but I figured my job would be
easier given that the device was &amp;ldquo;repaired and tested&amp;rdquo;. Having a working device would mean that I wouldn&amp;rsquo;t need to track
down any wiring errors. Since this was originally a kit, it&amp;rsquo;s a roll of the dice whether or not whoever put it together
took any care in what they were doing.&lt;/p&gt;
&lt;p&gt;It arrived, and externally it looked very nice.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;1a.jpg&#34; alt=&#34;The IP-32&#34;&gt;&lt;/p&gt;
&lt;p&gt;I immediately clipped off the line cord and opened it up. (Warning: tube devices can kill you. Don&amp;rsquo;t open up or plug in
a device like this if you don&amp;rsquo;t understand the risks.)&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;2a.jpg&#34; alt=&#34;Underside of IP-32&#34;&gt;&lt;/p&gt;
&lt;p&gt;This certainly doesn&amp;rsquo;t look like it was &amp;ldquo;repaired&amp;rdquo;! I spoke with Philip from CHRS about the erroneous listing, and he
was very apologetic. Apparently they are implementing a new QC process to avoid similar issues in the future.&lt;/p&gt;
&lt;p&gt;You can see in this photo all the original electrolytic capacitors as well as the original paper and foil capacitors.
These will all be electrically leaky (i.e. developed parallel resistance), so trying to operate the device in this state
would be very bad for the tubes.&lt;/p&gt;
&lt;p&gt;As for &amp;ldquo;working&amp;rdquo;, you can see if you look closely that a solder joint is completely snapped off from one of the selenium
diodes! The C- output would have absolutely zero chance of working in this condition.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;4a.jpg&#34; alt=&#34;Broken solder connection&#34;&gt;&lt;/p&gt;
&lt;p&gt;As if that wasn&amp;rsquo;t bad enough, check out how close this lead from the filament transformer is to the chassis! Whoever was
in this thing last did a &amp;ldquo;J-hook&amp;rdquo; to connect the line he cut, and didn&amp;rsquo;t bother to insulate the connection. Since this
is an isolated 6.3V winding, it&amp;rsquo;s unlikely contact with the chassis would have caused a lethal shock, but it&amp;rsquo;s still
concerning - seeing this made me decide to go over every connection in the device to make sure there weren&amp;rsquo;t any other
safety issues.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;3a.jpg&#34; alt=&#34;J-hooked bare wire 1 mm from chassis&#34;&gt;&lt;/p&gt;
&lt;p&gt;To make a long story short, I ended up re-routing most of the AC lines to try and reduce hum, I replaced every capacitor
with high quality modern components, and I replaced the ancient silicon diodes and broken selenium diodes with modern
replacements.&lt;/p&gt;
&lt;p&gt;The selenium diodes are pretty cool, I hadn&amp;rsquo;t seen something like this before. They look like capacitors on a signature
tracer. I&amp;rsquo;m not sure what happened inside to turn them into capacitors.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;5a.jpg&#34; alt=&#34;Broken selenium diodes&#34;&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the finial result of the chassis restoration, before I attached a new line cord. I&amp;rsquo;m very pleased with the
results.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;6a.jpg&#34; alt=&#34;Finished chassis&#34;&gt;&lt;/p&gt;
&lt;p&gt;I had some minor issues with the power switch - the standby mode didn&amp;rsquo;t work properly. I was able to open it up with
some pliers and clean / bend the contacts, and got it working again.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the obligatory tube shot (I replaced the metal 6L6 with some modern glass 6L6EH ones just for aesthetics - the
metals ones still work fine).&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;7a.jpg&#34; alt=&#34;Tubes lit up&#34;&gt;&lt;/p&gt;
&lt;p&gt;The power supply works extremely well - I get only a 1V drop when placing a 100 mA load at 400V. The analog voltmeter is
a little off - it reads 380V when the actual voltage is 400V - but I use a DMM anyways so this doesn&amp;rsquo;t bother me. The
milliammeter works perfectly.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;8a.jpg&#34; alt=&#34;Power supply with DMM hooked to terminals&#34;&gt;&lt;/p&gt;
&lt;p&gt;This was an extremely fun restoration, and I&amp;rsquo;m looking forward to using it while experimenting with tube circuits on the
breadboard.&lt;/p&gt;
&lt;p&gt;If you want to learn how to do this kind of stuff yourself, I can&amp;rsquo;t
recommend &lt;a href=&#34;https://www.patreon.com/MrCarlsonsLab&#34;&gt;Mr. Carlson&amp;rsquo;s Lab&lt;/a&gt; highly enough. He also has
a &lt;a href=&#34;https://www.youtube.com/watch?v=JroiDZgReak&#34;&gt;video of his restoration&lt;/a&gt; of an IP-32 on YouTube.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Modernizing This Site</title>
      <link>https://pudar.net/modernizing-this-site/</link>
      <pubDate>Tue, 16 Feb 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/modernizing-this-site/</guid>
      <description>&lt;p&gt;This is a quick post on how I&amp;rsquo;m updating this site. Currently, it&amp;rsquo;s hosted on an
old Supermicro CSE-745 server sucking up the &amp;ldquo;free&amp;rdquo; electricity in my parents&#39;
basement. They have a gigabit fiber connection, but the site is definitely not
as fast to load as it could be if you aren&amp;rsquo;t nearby. I&amp;rsquo;m going to move the site
to AWS using CloudFront and an S3 bucket. This should be a bit faster and far
more reliable.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;supermicro-server.jpg&#34; alt=&#34;Supermicro CSE-745&#34;&gt;&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve also made &lt;a href=&#34;https://github.com/jimpudar/blog&#34;&gt;the repository for this blog&lt;/a&gt;
public on GitHub so you can see the changes as commits.&lt;/p&gt;
&lt;h1 id=&#34;setting-up-cloudfront-and-s3&#34;&gt;Setting up CloudFront and S3&lt;/h1&gt;
&lt;p&gt;I created a private S3 bucket in the US East (N. Virginia) region and uploaded
the static site generated by Pelican to the bucket. I can use the
&lt;a href=&#34;https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html&#34;&gt;sync&lt;/a&gt; command to
easily keep the S3 bucket up to date with the latest generated files.&lt;/p&gt;
&lt;p&gt;Next, I created a new CloudFront distribution using my S3 bucket&amp;rsquo;s REST API
domain name as the origin. I set the &lt;code&gt;index.html&lt;/code&gt; file as the default. Since the
S3 bucket itself is still private, I had CloudFront create an Origin Access
Identity and automatically update the IAM permissions on the bucket. This whole
process was crazy easy - I love AWS!&lt;/p&gt;
&lt;p&gt;At this point, you can go to
&lt;a href=&#34;d3daredapnpa6l.cloudfront.net&#34;&gt;d3daredapnpa6l.cloudfront.net&lt;/a&gt; and see the site
distributed by CloudFront. Neat! Of course the fonts don&amp;rsquo;t work properly because
&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS&#34;&gt;CORS&lt;/a&gt; is disabled and
Pelican has generated all the links relative to &lt;a href=&#34;pudar.net&#34;&gt;pudar.net&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Next, I want to be able to access the site from my domain name
&lt;a href=&#34;pudar.net&#34;&gt;pudar.net&lt;/a&gt;. My registrar is currently
&lt;a href=&#34;www.namecheap.com&#34;&gt;Namecheap&lt;/a&gt;, although I&amp;rsquo;m eventually going to transfer the
domain over to AWS.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve enforced HTTPS in CloudFront, so before I can add a CNAME record, I need to
create an SSL certificate for &lt;a href=&#34;pudar.net&#34;&gt;pudar.net&lt;/a&gt; and add the domain name to
the Alternate Domain Names list in the CloudFront distribution. The SSL
certificate is free to create in AWS using Certificate Manager.&lt;/p&gt;
&lt;p&gt;Finally, in the Namecheap DNS console I replaced the A + DynamicDNS record
pointing to my parents&amp;rsquo; house with a CNAME record to
&lt;a href=&#34;d3daredapnpa6l.cloudfront.net&#34;&gt;d3daredapnpa6l.cloudfront.net&lt;/a&gt;. Now,
&lt;a href=&#34;pudar.net&#34;&gt;pudar.net&lt;/a&gt; is officially hosted on AWS, and I can disable the Nginx
service on the server at my parents&amp;rsquo; house.&lt;/p&gt;
&lt;h2 id=&#34;considerations-for-cloudfront&#34;&gt;Considerations for Cloudfront&lt;/h2&gt;
&lt;p&gt;CloudFront is a cache, so if you need to update your site, you need to
invalidate the S3 objects that have been updated. For example, when I add a new
post to the site, the &lt;code&gt;index.html&lt;/code&gt; changes to reflect the new post. That means I
can either wait 24 hours before the update will start being reflected on the
CloudFront distribution, or I can manually invalidate the changed objects. You
can invalidate 1000 paths per month, and after that each path is half a cent to
invalidate. See &lt;a href=&#34;https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-serving-outdated-content-s3/&#34;&gt;Why is CloudFront serving outdated content from Amazon
S3?&lt;/a&gt;
for more information.&lt;/p&gt;
&lt;h2 id=&#34;infrastructure-as-code&#34;&gt;Infrastructure as Code&lt;/h2&gt;
&lt;p&gt;The next step here is to model the entire set of infrastructure components using
CloudFormation so that the entire stack can be easily created from scratch. I&amp;rsquo;ll
detail this process in another blog post.&lt;/p&gt;
&lt;h1 id=&#34;face-lift&#34;&gt;Face Lift&lt;/h1&gt;
&lt;p&gt;Additionally, I&amp;rsquo;ve decided to move from
&lt;a href=&#34;https://github.com/getpelican/pelican&#34;&gt;Pelican&lt;/a&gt; to &lt;a href=&#34;https://jekyllrb.com/&#34;&gt;Jekyll&lt;/a&gt;
mostly for the better themes available. I&amp;rsquo;ll outline this process in the next post.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Adventures in Rolling Your Own Router: Part VII</title>
      <link>https://pudar.net/adventures-in-rolling-your-own-router-part-vii/</link>
      <pubDate>Sun, 24 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/adventures-in-rolling-your-own-router-part-vii/</guid>
      <description>&lt;!-- markdownlint-disable line-length no-trailing-punctuation --&gt;
&lt;p&gt;In my &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-vi/&#34;&gt;previous post&lt;/a&gt;, I set up an Ansible
playbook to automate the configuration of my Debian router / firewall. In this
post, I&amp;rsquo;ll update the playbook to include the installation of Pi-hole for DNS
and DHCP.&lt;/p&gt;
&lt;h1 id=&#34;pi-hole-installer&#34;&gt;Pi-hole Installer&lt;/h1&gt;
&lt;p&gt;At the time of writing this post, Pi-hole is at commit
&lt;a href=&#34;https://github.com/pi-hole/pi-hole/blob/cbfb58f7a283c2a3e7aad95a834a0287175ccb24/automated%20install/basic-install.sh&#34;&gt;cbfb58f7&lt;/a&gt;.
I&amp;rsquo;ll link to line numbers at this commit, but be aware the installer script
will change over time.&lt;/p&gt;
&lt;p&gt;The Pi-hole installer is meant to be piped directly from &lt;code&gt;curl&lt;/code&gt; to &lt;code&gt;bash&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;curl -sSL https://install.pi-hole.net | bash
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The installer then runs through a set of interactive prompts using
&lt;a href=&#34;https://linux.die.net/man/1/whiptail&#34;&gt;whiptail&lt;/a&gt;, which allow you to choose an
interface, set a static IP, enable or disable the web UI, etc.&lt;/p&gt;
&lt;p&gt;The most concerning thing (for this particular router) the installer does is
&lt;a href=&#34;https://github.com/pi-hole/pi-hole/blob/cbfb58f7a283c2a3e7aad95a834a0287175ccb24/automated%20install/basic-install.sh#L354&#34;&gt;install
&lt;code&gt;dhcpcd5&lt;/code&gt;&lt;/a&gt;
which could potentially conflict with &lt;code&gt;systemd-networkd&lt;/code&gt;. It also will attempt
to set a static IP address on the interface you choose using a &lt;a href=&#34;https://github.com/pi-hole/pi-hole/blob/cbfb58f7a283c2a3e7aad95a834a0287175ccb24/automated%20install/basic-install.sh#L973&#34;&gt;variety of
methods&lt;/a&gt;,
none of which are &lt;code&gt;systemd-networkd&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Luckily for us, we can bypass the canned interface probing and the
modification of network configuration using a &amp;ldquo;secret&amp;rdquo; argument.
If we pass the &lt;a href=&#34;https://github.com/pi-hole/pi-hole/blob/cbfb58f7a283c2a3e7aad95a834a0287175ccb24/automated%20install/basic-install.sh#L123&#34;&gt;&amp;ndash;unattended&lt;/a&gt;
argument to the installer, the &lt;a href=&#34;https://github.com/pi-hole/pi-hole/blob/cbfb58f7a283c2a3e7aad95a834a0287175ccb24/automated%20install/basic-install.sh#L2680&#34;&gt;conditional in the main
function&lt;/a&gt;
lets us bypass all the stuff we don&amp;rsquo;t want.&lt;/p&gt;
&lt;p&gt;The only catch is that we need to set up &lt;a href=&#34;https://github.com/pi-hole/pi-hole/blob/cbfb58f7a283c2a3e7aad95a834a0287175ccb24/automated%20install/basic-install.sh#L52&#34;&gt;a file which contains
variables&lt;/a&gt;
so that Pi-hole can configure itself. These variables would normally be
determined by the interactive portion of the installer.&lt;/p&gt;
&lt;h1 id=&#34;installing-pi-hole-with-ansible&#34;&gt;Installing Pi-hole with Ansible&lt;/h1&gt;
&lt;p&gt;The first step in automating the installation is codifying the variable file.
This will be yet another template. The password hash is a dummy value; I&amp;rsquo;ll
reset the password before use.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;% cat templates/pihole.setupvars.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;BLOCKING_ENABLED=true
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP_ACTIVE=true
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP_START={{ dhcp_range_start }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP_END={{ dhcp_range_end }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP_ROUTER={{ dhcp_router }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP_IPv6=
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP_rapid_commit=
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;PIHOLE_DOMAIN={{ local_domain_name }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP_LEASETIME=24
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;WEBPASSWORD=ea54268507ae0dac3da1d3057dbc5e870c6223caff753da02032bbc8f82c76b8
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;PIHOLE_INTERFACE={{ internal_ifname }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;IPV4_ADDRESS={{ ipv4_address_with_netmask }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;IPV6_ADDRESS=
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;PIHOLE_DNS_1=9.9.9.9
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;PIHOLE_DNS_2=149.112.112.112
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;QUERY_LOGGING=true
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;INSTALL_WEB_SERVER=true
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;INSTALL_WEB_INTERFACE=true
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;LIGHTTPD_ENABLED=true
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;CACHE_SIZE=10000
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I have a couple of extra lines of configuration for &lt;code&gt;dnsmasq&lt;/code&gt;, so I will add
one additional template file for those.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;% cat templates/dnsmasq.extras.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;local=/{{ local_domain_name }}/
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;expand-hosts
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;read-ethers
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, we can add some tasks to the playbook to install these template files.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Ensure Pi-hole configuration directory exists
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.file:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        path: /etc/pihole
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: directory
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        mode: &amp;#39;0755&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Configure Pi-hole installation variables
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.template:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        src: templates/pihole.setupvars.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        dest: /etc/pihole/setupVars.conf
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        mode: &amp;#39;0644&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      vars:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        internal_ifname: &amp;#34;intern0&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ipv4_address_with_netmask: &amp;#34;{{ internal_ip }}/{{ internal_netmask }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        local_domain_name: &amp;#34;{{ internal_domain }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        dhcp_range_start: &amp;#34;{{ dhcp_start }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        dhcp_range_end: &amp;#34;{{ dhcp_end}}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        dhcp_router: &amp;#34;{{ internal_ip }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Ensure dnsmasq configuration directory exists
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.file:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        path: /etc/dnsmasq.d
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: directory
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        mode: &amp;#39;0755&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Add extra dnsmasq configuration
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.template:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        src: templates/dnsmasq.extras.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        dest: /etc/dnsmasq.d/10-extra.conf
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        mode: &amp;#39;0644&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      vars:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        local_domain_name: &amp;#34;{{ internal_domain }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, we need to download the Pi-hole installer. I&amp;rsquo;ve decided to just grab the
latest version of the installer rather than pin a particular commit. I&amp;rsquo;m
hoping that the &lt;code&gt;setupVars.conf&lt;/code&gt; format won&amp;rsquo;t change anytime soon. Because the
installer script is available over HTTPS, I need to install the
&lt;code&gt;ca-certificates&lt;/code&gt; package before I can download the installer script with the
&lt;code&gt;get_url&lt;/code&gt; module.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Install CA certs
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.apt:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        name: ca-certificates
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: latest
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Download Pi-hole installer
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      get_url:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        url: https://install.pi-hole.net
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        dest: /etc/pihole/basic-install.sh
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        mode: &amp;#39;0700&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Finally, I can install Pi-hole. I will also disable and mask the &lt;code&gt;dhcpcd&lt;/code&gt;
service that Pi-hole installed for me as we don&amp;rsquo;t want this to ever be
inadvertently enabled.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Install Pi-hole
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      command: /etc/pihole/basic-install.sh --unattended
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Completely disable dhcpcd.service
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.systemd:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        name: dhcpcd.service
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: stopped
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        enabled: no
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        masked: yes
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Two additional &lt;code&gt;nftables&lt;/code&gt; rules need to be added to allow the use of DHCP and
HTTP from the LAN interface.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # allow DHCP from the LAN
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        iifname {{ internal_ifname }} udp dport { 67,68 } accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # allow HTTP from the LAN for Pi-hole admin console
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        iifname {{ internal_ifname }} tcp dport http accept
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;ll need to supply my &lt;code&gt;/etc/ethers&lt;/code&gt; and &lt;code&gt;/etc/hosts&lt;/code&gt; files, but besides that
the router and it&amp;rsquo;s IaC are complete!&lt;/p&gt;
&lt;p&gt;For reference, you can find the entire playbook &lt;a href=&#34;https://github.com/jimpudar/my-router&#34;&gt;on
GitHub&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Adventures in Rolling Your Own Router: Part VI</title>
      <link>https://pudar.net/adventures-in-rolling-your-own-router-part-vi/</link>
      <pubDate>Sat, 23 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/adventures-in-rolling-your-own-router-part-vi/</guid>
      <description>&lt;!-- markdownlint-disable line-length no-trailing-punctuation --&gt;
&lt;p&gt;In my &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-v/&#34;&gt;previous post&lt;/a&gt;, I set up an &lt;code&gt;nftables&lt;/code&gt;
firewall. In this post, I&amp;rsquo;ll use &lt;a href=&#34;https://www.ansible.com&#34;&gt;Ansible&lt;/a&gt; to
automate the configuration steps we have already performed.&lt;/p&gt;
&lt;h1 id=&#34;the-purpose-of-infrastructure-as-code&#34;&gt;The Purpose of Infrastructure as Code&lt;/h1&gt;
&lt;p&gt;So far, everything we have done has been manual steps in &lt;code&gt;vim&lt;/code&gt; and the CLI.
This works fine, but is tedious and error prone. I&amp;rsquo;m a big proponent of
&lt;a href=&#34;https://en.wikipedia.org/wiki/Infrastructure_as_code&#34;&gt;Infrastructure as Code
(IaC)&lt;/a&gt;. It has countless
advantages in a corporate environment, and I&amp;rsquo;ve grown so accustomed to it that
it seems to make sense even for my personal network.&lt;/p&gt;
&lt;p&gt;Later, I&amp;rsquo;ll be installing &lt;a href=&#34;https://pi-hole.net/&#34;&gt;Pi-hole&lt;/a&gt; and after reviewing
the installer, it looks like it does a lot of stuff I might not want. By
defining the router using IaC up to that point, I&amp;rsquo;ll easily be able to get
back to that state if the Pi-hole installer does something I didn&amp;rsquo;t intend to
happen. If I didn&amp;rsquo;t care to have the IaC definition at the end of the process,
I could also accomplish this using VM snapshots. The immediate advantages of
having the IaC definition is that I&amp;rsquo;ll be able to set up the router on real
hardware far more quickly (no downtime = happy family) and if I ever want to
switch to new hardware I&amp;rsquo;ll be able to do so quickly and easily.&lt;/p&gt;
&lt;h1 id=&#34;setting-up-ansible&#34;&gt;Setting up Ansible&lt;/h1&gt;
&lt;p&gt;I&amp;rsquo;ve only used Ansible a few times, but it was always very straightforward.
The &lt;a href=&#34;https://docs.ansible.com/ansible/latest/index.html&#34;&gt;documentation&lt;/a&gt;, like
most documentation from Red Hat, is fantastic.&lt;/p&gt;
&lt;p&gt;I started by adding my virtual &lt;code&gt;debrouter&lt;/code&gt; to my &lt;code&gt;/etc/ethers&lt;/code&gt; and
&lt;code&gt;/etc/hosts&lt;/code&gt; files on my existing DNS server. I also created an
&lt;code&gt;/etc/ansible/hosts&lt;/code&gt; file on my Mac and added &lt;code&gt;debrouter&lt;/code&gt; to the file. Then, I
generated a new RSA key pair on my Mac and installed the public key in the
&lt;code&gt;~/.ssh/authorized_keys&lt;/code&gt; file on &lt;code&gt;debrouter&lt;/code&gt;. Finally, I set up &lt;code&gt;NOPASSWD&lt;/code&gt; for
the &lt;code&gt;sudo&lt;/code&gt; group, and I am now able to use Ansible to ping &lt;code&gt;debrouter&lt;/code&gt; with
&lt;code&gt;sudo&lt;/code&gt; privileges:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ansible all -m ping -u jmp --become
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;debrouter.crbj.io | SUCCESS =&amp;gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &amp;#34;ansible_facts&amp;#34;: {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &amp;#34;discovered_interpreter_python&amp;#34;: &amp;#34;/usr/bin/python3&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    },
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &amp;#34;changed&amp;#34;: false,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &amp;#34;ping&amp;#34;: &amp;#34;pong&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id=&#34;building-a-playbook&#34;&gt;Building a Playbook&lt;/h1&gt;
&lt;p&gt;Now, I can go back in time to last week and start translating the manual steps
I took into an Ansible playbook. I&amp;rsquo;ll start a new file called &lt;code&gt;playbook.yml&lt;/code&gt;.
I&amp;rsquo;ll also fire up a new Debian 10 VM called debrouter2 we can use for testing
the playbook.&lt;/p&gt;
&lt;p&gt;The first step is to determine the MAC address of each interface so I can give
them customized names &lt;code&gt;extern0&lt;/code&gt; and &lt;code&gt;intern0&lt;/code&gt;. We can do this using
&lt;a href=&#34;https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html#vars-and-facts&#34;&gt;facts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s assume that on first boot only one of the two interfaces will be
connected to Ethernet and have gotten an IPv4 address via DHCP. This interface
will be our &lt;code&gt;extern0&lt;/code&gt; interface, and we should be able to find it using the
&lt;code&gt;default_ipv4&lt;/code&gt; entry in the &lt;code&gt;ansible_facts&lt;/code&gt; object.&lt;/p&gt;
&lt;p&gt;In real life, my router hardware actually has three interfaces, so I may end
up just supplying the interface names manually.&lt;/p&gt;
&lt;p&gt;Note that I&amp;rsquo;m using &lt;code&gt;set_fact&lt;/code&gt; instead of &lt;code&gt;vars&lt;/code&gt; because I only want these
filters to be evaluated once.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;- name: Router Setup
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  hosts: debrouter2.crbj.io
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  pre_tasks:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - set_fact:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ifs: &amp;#34;{{ ansible_facts.interfaces | reject(&amp;#39;equalto&amp;#39;, &amp;#39;lo&amp;#39;) }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - set_fact:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      external_if: &amp;#34;{{ ansible_facts.default_ipv4.interface }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - set_fact:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      internal_if: &amp;#34;{{ ifs | reject(&amp;#39;equalto&amp;#39;, external_if) | first }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - set_fact:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      external_if_macaddress: &amp;#34;{{ ansible_facts[external_if].macaddress }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - set_fact:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      internal_if_macaddress: &amp;#34;{{ ansible_facts[internal_if].macaddress }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  tasks:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - name: Print external interface MAC address
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ansible.builtin.debug:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      var: external_if_macaddress
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - name: Print internal interface MAC address
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ansible.builtin.debug:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      var: internal_if_macaddress
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, we need templates for our &lt;code&gt;.link&lt;/code&gt; files.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;% cat templates/link.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Match]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;MACAddress={{ macaddress }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Link]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name={{ ifname }}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can use the &lt;code&gt;template&lt;/code&gt; module to automatically place the link files on
the router.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - name: Set external interface name
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ansible.builtin.template:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      src: templates/link.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      dest: /etc/systemd/network/10-extern0.link
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      mode: &amp;#39;0644&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    vars:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      macaddress: &amp;#34;{{ external_if_macaddress }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ifname: &amp;#34;extern0&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - name: Set internal interface name
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ansible.builtin.template:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      src: templates/link.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      dest: /etc/systemd/network/20-intern0.link
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      mode: &amp;#39;0644&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    vars:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      macaddress: &amp;#34;{{ internal_if_macaddress }}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ifname: &amp;#34;intern0&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, we add some templates for our &lt;code&gt;.network&lt;/code&gt; files.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;% cat templates/dhcp.network.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Match]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name={{ ifname }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Network]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP=ipv4
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;% cat templates/static.network.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Match]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name={{ ifname }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Network]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Address={{ address_with_netmask }}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;IPForward=true
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The templates are again fed to the &lt;code&gt;template&lt;/code&gt; module.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - name: Set external network configuration
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ansible.builtin.template:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      src: templates/dhcp.network.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      dest: /etc/systemd/network/external.network
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      mode: &amp;#39;0644&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    vars:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ifname: &amp;#34;extern0&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  - name: Set internal network configuration
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ansible.builtin.template:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      src: templates/static.network.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      dest: /etc/systemd/network/internal.network
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      mode: &amp;#39;0644&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    vars:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ifname: &amp;#34;intern0&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      address_with_netmask: &amp;#34;192.168.100.1/24&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, we can use the &lt;code&gt;systemd&lt;/code&gt; module to disable &lt;code&gt;networking.service&lt;/code&gt; and
enable &lt;code&gt;systemd-networkd&lt;/code&gt;. I&amp;rsquo;m going a step further here and actually masking
&lt;code&gt;networking.service&lt;/code&gt; so it&amp;rsquo;s not possible to accidentally enable it later.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Completely disable the default networking.service
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.systemd:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        name: networking.service
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: stopped
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        enabled: no
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        masked: yes
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Enable systemd-networkd.service
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.systemd:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        name: systemd-networkd.service
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: started
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        enabled: yes
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        masked: no
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We also need to restart the host at this point. Check out the final playbook
&lt;a href=&#34;https://github.com/jimpudar/my-router&#34;&gt;on GitHub&lt;/a&gt; to see how this is done.&lt;/p&gt;
&lt;p&gt;Now we need to install &lt;code&gt;nftables&lt;/code&gt; and remove &lt;code&gt;iptables&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Update apt cache
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.apt:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        update_cache: yes
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Remove iptables
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.apt:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        name: iptables
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        purge: yes
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: absent
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Install nftables
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.apt:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        name: nftables
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: latest
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Enable nftables.service
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.systemd:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        name: nftables.service
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        state: started
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        enabled: yes
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        masked: no
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Finally, we can install the firewall rules using another call to the
&lt;code&gt;template&lt;/code&gt; module.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    - name: Set up nftables rules
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      ansible.builtin.template:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        src: templates/nftables.conf.j2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        dest: /etc/nftables.conf
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        owner: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        group: root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        mode: &amp;#39;0644&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      vars:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        internal_ifname: &amp;#34;intern0&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        external_ifname: &amp;#34;extern0&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        lan_network: &amp;#34;192.168.100.0/24&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At this point, we should have a working router. In the &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-vii/&#34;&gt;next
post&lt;/a&gt;, I&amp;rsquo;ll attempt to install Pi-hole without
messing up anything we have done so far.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Adventures in Rolling Your Own Router: Part V</title>
      <link>https://pudar.net/adventures-in-rolling-your-own-router-part-v/</link>
      <pubDate>Fri, 22 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/adventures-in-rolling-your-own-router-part-v/</guid>
      <description>&lt;!-- markdownlint-disable line-length no-trailing-punctuation --&gt;
&lt;p&gt;In my &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-iv/&#34;&gt;previous post&lt;/a&gt;, I set up NAT using
&lt;code&gt;nftables&lt;/code&gt;. In this post, I&amp;rsquo;ll use &lt;code&gt;nftables&lt;/code&gt; to set up a firewall.&lt;/p&gt;
&lt;p&gt;In my current router, I have disabled IPv6 entirely, so no IPv6 packets can
enter or leave my network. I do want to start experimenting with IPv6, so I
will not want to take this strategy for the new firewall.&lt;/p&gt;
&lt;p&gt;Looking again at the &lt;code&gt;netfilter&lt;/code&gt; diagram, we can see we are mostly interested
in the &lt;code&gt;forward&lt;/code&gt; and &lt;code&gt;input&lt;/code&gt; chains of the &lt;code&gt;filter&lt;/code&gt; table. The former will
allow us to filter packets destined for the LAN, and the latter packets
destined for the router itself.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;netfilter-diagram.jpg&#34; alt=&#34;Netfilter diagram&#34;&gt;&lt;/p&gt;
&lt;p&gt;Instead of building the rules using the &lt;code&gt;nft&lt;/code&gt; CLI, we can just modify
&lt;code&gt;/etc/nftables.conf&lt;/code&gt;. I&amp;rsquo;ve added comments in the file to explain what each
rule is for.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ cat /etc/nftables.conf
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;#!/usr/sbin/nft -f
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;flush ruleset
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;table ip filter {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    # applies to packets which are traveling through this machine
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    chain forward {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        type filter hook forward priority 0; policy drop;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # allow packets leaving the network
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        oifname extern0 accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # allow replies
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        iifname extern0 ct state related,established accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    chain input {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        type filter hook input priority 0; policy drop;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # drop invalid packets early
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ct state invalid drop
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # accept replies
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ct state related,established accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # open loopback interface
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        iif lo accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # accept ICMP and IGMP
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ip protocol icmp accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ip protocol igmp accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # allow SSH from all interfaces
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        tcp dport ssh accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # allow Mosh from all interfaces
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        udp dport { 60000-61000 } accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # allow DNS queries from the LAN
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        iifname intern0 tcp dport 53 accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        iifname intern0 udp dport 53 accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # allow traceroute
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        udp dport { 33434-33524 } accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;table ip6 filter {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    chain forward {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        type filter hook forward priority 0; policy drop;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # for now, we will not forward IPv6 traffic.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    chain input {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        type filter hook forward priority 0; policy drop;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # drop invalid packets early
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ct state invalid drop
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # accept replies
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ct state related,established accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # accept ICMPv6
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ip6 nexthdr icmpv6 accept
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;table ip nat {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    chain postrouting {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        type nat hook postrouting priority 100; policy accept;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        # perform NAT for packets coming from the LAN and going to the Internet
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ip saddr 192.168.77.0/24 oifname extern0 masquerade
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, I can &lt;code&gt;mosh&lt;/code&gt; to and &lt;code&gt;ping6&lt;/code&gt; the router from the external interface:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@archimedes ~ % mosh 192.168.10.17
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@192.168.10.17&amp;#39;s password:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@archimedes ~ % ping6 -I en0 fe80::5054:ff:fec7:caa6
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;PING6(56=40+8+8 bytes) fe80::874:cee0:e328:8115%en0 --&amp;gt; fe80::5054:ff:fec7:caa6
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;16 bytes from fe80::5054:ff:fec7:caa6%en0, icmp_seq=0 hlim=64 time=0.820 ms
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;16 bytes from fe80::5054:ff:fec7:caa6%en0, icmp_seq=1 hlim=64 time=0.504 ms
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;16 bytes from fe80::5054:ff:fec7:caa6%en0, icmp_seq=2 hlim=64 time=0.544 ms
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;16 bytes from fe80::5054:ff:fec7:caa6%en0, icmp_seq=3 hlim=64 time=0.442 ms
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-vi/&#34;&gt;next post&lt;/a&gt;, I&amp;rsquo;ll install PiHole for DNS
and DHCP service.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Adventures in Rolling Your Own Router: Part IV</title>
      <link>https://pudar.net/adventures-in-rolling-your-own-router-part-iv/</link>
      <pubDate>Tue, 19 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/adventures-in-rolling-your-own-router-part-iv/</guid>
      <description>&lt;!-- markdownlint-disable line-length no-trailing-punctuation --&gt;
&lt;p&gt;In my &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-iii/&#34;&gt;previous post&lt;/a&gt;, I created a virtual
router, LAN, and client in order to test out my plan for the Debian router. In
this post, I&amp;rsquo;ll set up NAT using &lt;code&gt;nftables&lt;/code&gt;.&lt;/p&gt;
&lt;h1 id=&#34;installing-nftables&#34;&gt;Installing nftables&lt;/h1&gt;
&lt;p&gt;As I discovered in the last post, Debian Buster apparently doesn&amp;rsquo;t come with
&lt;code&gt;nftables&lt;/code&gt; installed, but instead has an &lt;code&gt;iptables-nft&lt;/code&gt; shim layer on top of
the &lt;code&gt;nf_tables&lt;/code&gt; kernel subsystem that accepts regular &lt;code&gt;iptables&lt;/code&gt; rule syntax.
It also comes with &lt;code&gt;iptables-legacy&lt;/code&gt; that you can use the &lt;code&gt;alternatives&lt;/code&gt;
system to switch to. The details of this are all laid out in the
&lt;a href=&#34;https://wiki.debian.org/nftables&#34;&gt;wiki&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To get started with &lt;code&gt;nftables&lt;/code&gt; we just need to start and enable it:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo apt install nftables
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo systemctl enable nftables
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id=&#34;replacing-iptables-legacy-rules&#34;&gt;Replacing iptables-legacy Rules&lt;/h1&gt;
&lt;p&gt;Since setting &lt;code&gt;IPMasquerade=true&lt;/code&gt; in &lt;code&gt;/etc/systemd/network/internal.network&lt;/code&gt;
caused &lt;code&gt;systemd-networkd&lt;/code&gt; to create &lt;code&gt;iptables-legacy&lt;/code&gt; rules, we need to make
a change to that file.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ cat /etc/systemd/network/internal.network
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Match]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name=intern0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Network]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Address=192.168.77.1/24
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;IPForward=ipv4
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Currently systemd-networkd uses iptables-legacy.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Masquerade is manually configured with nftables.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# IPMasquerade=true
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After a reboot, the &lt;code&gt;iptables-legacy&lt;/code&gt; rules are gone.&lt;/p&gt;
&lt;p&gt;Now, we need to manually set up masquerading using &lt;code&gt;nftables&lt;/code&gt; directly. There
are some instructions on the &lt;a href=&#34;https://wiki.nftables.org/wiki-nftables/index.php/Performing_Network_Address_Translation_(NAT)&#34;&gt;nftables
wiki&lt;/a&gt;,
but in general documentation for &lt;code&gt;nftables&lt;/code&gt; is still sparse. If you&amp;rsquo;re looking
for a good primer on &lt;code&gt;nftables&lt;/code&gt;, check out &lt;a href=&#34;https://www.youtube.com/watch?v=ouqDHX6HwOo&#34;&gt;this
video&lt;/a&gt; from the Open Source
Summit.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;nftables&lt;/code&gt; controls &lt;code&gt;netfilter&lt;/code&gt;. In this regard, it&amp;rsquo;s similar to &lt;code&gt;iptables&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;netfilter-diagram.jpg&#34; alt=&#34;Netfilter diagram&#34;&gt;&lt;/p&gt;
&lt;p&gt;Unlike &lt;code&gt;iptables&lt;/code&gt;, &lt;code&gt;nftables&lt;/code&gt; does not come with all the &lt;code&gt;netfilter&lt;/code&gt; default
tables and chains set up. This is for performance reasons - if you don&amp;rsquo;t need
them, they don&amp;rsquo;t get executed. However, this means we need to create the
tables and chains that we do need.&lt;/p&gt;
&lt;p&gt;Since &lt;code&gt;masquerade&lt;/code&gt; is applied in the &lt;code&gt;postrouting&lt;/code&gt; chain of the &lt;code&gt;nat&lt;/code&gt; table,
we first need to create the &lt;code&gt;nat&lt;/code&gt; table.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo nft add table nat
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It looks like this automatically creates this table in the &lt;code&gt;ip&lt;/code&gt; family which
means chains in this table will apply only to IPV4. This is good, because we
don&amp;rsquo;t need NAT for IPv6.&lt;/p&gt;
&lt;p&gt;Next, we need to create the &lt;code&gt;postrouting&lt;/code&gt; chain.
&lt;a href=&#34;https://github.com/LukasJoswiak/etch&#34;&gt;https://github.com/LukasJoswiak/etch&lt;/a&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo nft &amp;#39;add chain nat postrouting { type nat hook postrouting priority 100 ; }&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Finally, we can add a rule to the chain to enable &lt;code&gt;masquerade&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We specify that only packets originating in the LAN and being sent out on the
external interface should have &lt;code&gt;masquerade&lt;/code&gt; applied.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo nft add rule nat postrouting ip saddr 192.168.77.0/24 oifname extern0 masquerade
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s all it takes! We can now ping servers on the Internet from &lt;code&gt;debclient&lt;/code&gt;
again.&lt;/p&gt;
&lt;h1 id=&#34;persistence-of-nftables-ruleset&#34;&gt;Persistence of nftables Ruleset&lt;/h1&gt;
&lt;p&gt;We want these rules to survive the next reboot, so we can add them to
&lt;code&gt;/etc/nftables.conf&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;#!/usr/sbin/nft -f
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;flush ruleset
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;table ip nat {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    chain postrouting {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        type nat hook postrouting priority 100; policy accept;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ip saddr 192.168.77.0/24 oifname extern0 masquerade;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-v/&#34;&gt;next post&lt;/a&gt;, we will create a simple
firewall using &lt;code&gt;nftables&lt;/code&gt;.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Adventures in Rolling Your Own Router: Part III</title>
      <link>https://pudar.net/adventures-in-rolling-your-own-router-part-iii/</link>
      <pubDate>Mon, 18 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/adventures-in-rolling-your-own-router-part-iii/</guid>
      <description>&lt;!-- markdownlint-disable line-length no-trailing-punctuation --&gt;
&lt;p&gt;In my &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-ii/&#34;&gt;previous post&lt;/a&gt;, I described my plan for
the new router. In this post, I&amp;rsquo;ll create a virtual router, LAN, and client in
order to test out my plan for the Debian router.&lt;/p&gt;
&lt;p&gt;This is easy to accomplish using Cockpit on RHEL, but you can do this on any
Linux distribution.&lt;/p&gt;
&lt;h1 id=&#34;debian-installation&#34;&gt;Debian Installation&lt;/h1&gt;
&lt;p&gt;I downloaded the net installer for Debian 10.7 &amp;ldquo;buster&amp;rdquo; and created the first
VM called &lt;code&gt;debrouter&lt;/code&gt; with two network interfaces. The first interface is
bridged with my RHEL server&amp;rsquo;s Ethernet interface and will get its own IP
address via DHCP on my real LAN in the &lt;code&gt;192.168.10.0/24&lt;/code&gt; block. The second
network interface is connected to the virtual LAN &lt;code&gt;privatelan&lt;/code&gt;. These will be
the WAN and LAN ports respectively.&lt;/p&gt;
&lt;p&gt;At the software selection page, I have disabled all but the SSH server. The
fewer packages installed, the better!&lt;/p&gt;
&lt;p&gt;After the installation is complete, we can ssh into the new VM.&lt;/p&gt;
&lt;h1 id=&#34;set-up-sudo&#34;&gt;Set Up sudo&lt;/h1&gt;
&lt;p&gt;Since we didn&amp;rsquo;t install anything, we unsurprisingly don&amp;rsquo;t have &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:/etc/network$ su -
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Password:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@debrouter:~# apt install sudo
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@debrouter:~# usermod -aG sudo jmp
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now after logging out and logging back in again, &lt;code&gt;jmp&lt;/code&gt; can use &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;
&lt;h1 id=&#34;network-interface-configuration&#34;&gt;Network Interface Configuration&lt;/h1&gt;
&lt;p&gt;We will first set up some configuration for &lt;code&gt;systemd-networkd&lt;/code&gt;, then we will
disable the default &lt;code&gt;networking&lt;/code&gt; service.&lt;/p&gt;
&lt;h2 id=&#34;rename-network-interfaces&#34;&gt;Rename Network Interfaces&lt;/h2&gt;
&lt;p&gt;I like to give logical persistent names for each network interface. We can do
this using
&lt;a href=&#34;https://manpages.debian.org/buster/udev/systemd.link.5.en.html&#34;&gt;&lt;code&gt;systemd.link&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;First, we need to get the MAC addresses of each interface:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ ip link
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;1: lo: &amp;lt;LOOPBACK,UP,LOWER_UP&amp;gt; mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;2: ens33: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    link/ether 00:0c:29:5e:8e:fa brd ff:ff:ff:ff:ff:ff
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;3: ens34: &amp;lt;BROADCAST,MULTICAST&amp;gt; mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    link/ether 00:0c:29:5e:8e:04 brd ff:ff:ff:ff:ff:ff
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, we can create a &lt;code&gt;.link&lt;/code&gt; file for each interface with our desired names:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ cat /etc/systemd/network/10-extern0.link /etc/systemd/network/20-intern0.link
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Match]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;MACAddress=00:0c:29:5e:8e:fa
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Link]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name=extern0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Match]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;MACAddress=00:0c:29:5e:8e:04
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Link]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name=intern0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;configure-network-interfaces&#34;&gt;Configure Network Interfaces&lt;/h2&gt;
&lt;p&gt;Finally we can define our
&lt;a href=&#34;https://www.freedesktop.org/software/systemd/man/systemd.network.html&#34;&gt;&lt;code&gt;.network&lt;/code&gt;&lt;/a&gt;
files:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ cat /etc/systemd/network/external.network
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Match]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name=extern0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Network]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;DHCP=ipv4
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ cat /etc/systemd/network/internal.network
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Match]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name=intern0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[Network]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Address=192.168.77.1/24
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;IPMasquerade=true
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;disable-networking-and-enable-systemd-networkd&#34;&gt;Disable networking and Enable systemd-networkd&lt;/h2&gt;
&lt;p&gt;By default, Debian uses the &lt;code&gt;/etc/network/interfaces&lt;/code&gt; configuration file
and the systemd unit &lt;code&gt;networking.service&lt;/code&gt; to configure the network interfaces
on boot.&lt;/p&gt;
&lt;p&gt;Since we want &lt;code&gt;systemd-networkd&lt;/code&gt; to control this instead, we need to rename
the configuration file and &lt;a href=&#34;https://wiki.debian.org/SystemdNetworkd#Setting_up_Systemd-Networkd&#34;&gt;disable the
service&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note: the Debian docs don&amp;rsquo;t suggest disabling the service, but I haven&amp;rsquo;t had
any issues doing so.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo mv /etc/network/interfaces /etc/network/interfaces.save
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo systemctl disable networking
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Be careful not to &lt;em&gt;stop&lt;/em&gt; the service yet, or else our interface will go down
and we will lose the SSH session.&lt;/p&gt;
&lt;p&gt;Now, we can enable &lt;code&gt;systemd-networkd.service&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo systemctl enable systemd-networkd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;finishing-up&#34;&gt;Finishing Up&lt;/h2&gt;
&lt;p&gt;Now we can reboot and see our network interfaces are configured correctly! Our
&lt;code&gt;extern0&lt;/code&gt; interface got a dynamic address &lt;code&gt;192.168.10.18&lt;/code&gt; (on my real LAN) and
the &lt;code&gt;intern0&lt;/code&gt; interface has the static address &lt;code&gt;192.168.77.1&lt;/code&gt; as requested.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ ip ad
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;1: lo: &amp;lt;LOOPBACK,UP,LOWER_UP&amp;gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    inet 127.0.0.1/8 scope host lo
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;       valid_lft forever preferred_lft forever
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    inet6 ::1/128 scope host
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;       valid_lft forever preferred_lft forever
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;2: extern0: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    link/ether 52:54:00:c7:ca:a6 brd ff:ff:ff:ff:ff:ff
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    inet 192.168.10.18/24 brd 192.168.10.255 scope global dynamic extern0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;       valid_lft 3567sec preferred_lft 3567sec
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    inet6 fe80::5054:ff:fec7:caa6/64 scope link
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;       valid_lft forever preferred_lft forever
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;3: intern0: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    link/ether 52:54:00:e3:bb:78 brd ff:ff:ff:ff:ff:ff
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    inet 192.168.77.1/24 brd 192.168.77.255 scope global intern0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;       valid_lft forever preferred_lft forever
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    inet6 fe80::5054:ff:fee3:bb78/64 scope link
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;       valid_lft forever preferred_lft forever
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id=&#34;where-is-nftables&#34;&gt;Where is nftables?&lt;/h1&gt;
&lt;p&gt;At this point, because we added &lt;code&gt;IPMasquerade=true&lt;/code&gt; in our LAN network file,
we should have some &lt;code&gt;nftables&lt;/code&gt; rules automatically added. However, to my
suprise, &lt;code&gt;nftables&lt;/code&gt; is not installed by default in Debian 10. Furthermore,
some &lt;code&gt;iptables-legacy&lt;/code&gt; rules get created instead!&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ su -
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Password:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@debrouter:~# nft
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-bash: nft: command not found
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@debrouter:~# iptables-legacy-save
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Generated by iptables-save v1.8.2 on Mon Jan 18 00:18:25 2021
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;*nat
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:PREROUTING ACCEPT [61:10854]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:INPUT ACCEPT [57:9808]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:OUTPUT ACCEPT [6:447]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:POSTROUTING ACCEPT [6:447]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A POSTROUTING -s 192.168.77.0/24 -j MASQUERADE
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;COMMIT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Completed on Mon Jan 18 00:18:25 2021
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Looks like the version of &lt;code&gt;systemd&lt;/code&gt; which ships with Debian buster is out of
date. Let&amp;rsquo;s install the latest &lt;code&gt;systemd&lt;/code&gt; from &lt;code&gt;buster-backports&lt;/code&gt;&amp;hellip;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo sh -c &amp;#39;echo &amp;#34;deb http://deb.debian.org/debian buster-backports main&amp;#34; &amp;gt;&amp;gt;/etc/apt/sources.list&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo apt -t buster-backports install systemd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Reboot, aaaand&amp;hellip; nope. No dice. Looking in the &lt;a href=&#34;https://github.com/systemd/systemd/commit/715a70e7218710d6a6c033e9157bf97fdf5d8ede&#34;&gt;commit
history&lt;/a&gt;,
it seems like the &lt;code&gt;nftables&lt;/code&gt; backend hasn&amp;rsquo;t even been released yet.&lt;/p&gt;
&lt;p&gt;For the time being, let&amp;rsquo;s continue with the legacy rules, but we will need to
replace these later on when we install &lt;code&gt;nftables&lt;/code&gt;.&lt;/p&gt;
&lt;h1 id=&#34;testing-with-a-client&#34;&gt;Testing With A Client&lt;/h1&gt;
&lt;p&gt;At this point, a client should be able to connect to the internal network with
a static IP and connect to the Internet through our virtual router.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll now set up another Debian VM called &lt;code&gt;debclient&lt;/code&gt;, this time with only one
interface connected to the &lt;code&gt;privatelan&lt;/code&gt; network.&lt;/p&gt;
&lt;p&gt;During the installation process, automatic network configuration fails
(expectedly, because there is no DHCP server) so we can manually set up a
static IP of &lt;code&gt;192.168.77.2&lt;/code&gt;, netmask &lt;code&gt;255.255.255.0&lt;/code&gt;, and gateway
&lt;code&gt;192.168.77.1&lt;/code&gt;. Since we don&amp;rsquo;t have a nameserver set up yet, I&amp;rsquo;m using
Google&amp;rsquo;s DNS &lt;code&gt;8.8.8.8&lt;/code&gt; since it&amp;rsquo;s easy to remember.&lt;/p&gt;
&lt;p&gt;After the installation is complete, I set up &lt;code&gt;tcpdump&lt;/code&gt; to listen for ICMP
packets on both of the router&amp;rsquo;s interfaces and then pinged Google&amp;rsquo;s DNS server
from the client.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;jmp@debrouter:~$ sudo tcpdump -i any icmp
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;00:40:17.258834 IP 192.168.77.2 &amp;gt; dns.google: ICMP echo request, id 434, seq 1, length 64
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;00:40:17.258872 IP debrouter.crbj.io &amp;gt; dns.google: ICMP echo request, id 434, seq 1, length 64
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;00:40:17.276588 IP dns.google &amp;gt; debrouter.crbj.io: ICMP echo reply, id 434, seq 1, length 64
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;00:40:17.276607 IP dns.google &amp;gt; 192.168.77.2: ICMP echo reply, id 434, seq 1, length 64
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Looks like it&amp;rsquo;s routing packets!&lt;/p&gt;
&lt;p&gt;In the &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-iv/&#34;&gt;next post&lt;/a&gt;, I&amp;rsquo;ll investigate what&amp;rsquo;s
going on with &lt;code&gt;nftables&lt;/code&gt; and remove these &lt;code&gt;iptables-legacy&lt;/code&gt; rules.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Adventures in Rolling Your Own Router: Part II</title>
      <link>https://pudar.net/adventures-in-rolling-your-own-router-part-ii/</link>
      <pubDate>Sun, 17 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/adventures-in-rolling-your-own-router-part-ii/</guid>
      <description>&lt;p&gt;In my &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-i/&#34;&gt;previous post&lt;/a&gt;, I described my current
home-brewed router. In this post, I&amp;rsquo;ll describe my plan for the new router.&lt;/p&gt;
&lt;!-- markdownlint-disable no-trailing-punctuation --&gt;
&lt;h1 id=&#34;what-os&#34;&gt;What OS?&lt;/h1&gt;
&lt;!-- markdownlint-enable no-trailing-punctuation --&gt;
&lt;p&gt;While PiHole &lt;a href=&#34;https://aur.archlinux.org/packages/pi-hole-ftl/&#34;&gt;can&lt;/a&gt; be
installed directly on Arch Linux or be run in a Docker container, I feel it is
safer to use an officially supported OS. My choices are Debian, Ubuntu,
Fedora, or CentOS.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t want to use Ubuntu because even in &lt;code&gt;ubuntu-server&lt;/code&gt; there are more
bells and whistles than I need.&lt;/p&gt;
&lt;p&gt;Fedora is out, because I am interested in long term stability. CentOS would be
a good option if it wasn&amp;rsquo;t
&lt;a href=&#34;https://wiki.centos.org/Manuals/ReleaseNotes/CentOSStream&#34;&gt;EOL&lt;/a&gt; at the end of
2021.&lt;/p&gt;
&lt;p&gt;This leaves Debian, an OS which I do not have much experience with.&lt;/p&gt;
&lt;!-- markdownlint-disable no-trailing-punctuation --&gt;
&lt;h1 id=&#34;what-should-it-do-and-how&#34;&gt;What Should it Do, and How?&lt;/h1&gt;
&lt;!-- markdownlint-enable no-trailing-punctuation --&gt;
&lt;h2 id=&#34;nat-routing&#34;&gt;NAT Routing&lt;/h2&gt;
&lt;p&gt;The router needs to not only forward packets between clients on the LAN and
the Internet, it also needs to perform Network Address Translation because in
my network only the router itself has a public IP address.&lt;/p&gt;
&lt;p&gt;NAT can be enabled with &lt;code&gt;systemd.network&lt;/code&gt; using the &lt;code&gt;IPMasquerade&lt;/code&gt; flag.&lt;/p&gt;
&lt;p&gt;Based on the &lt;a href=&#34;https://www.freedesktop.org/software/systemd/man/systemd.network.html&#34;&gt;man
page&lt;/a&gt;,
just enabling &lt;code&gt;IPMasquerade&lt;/code&gt; on the LAN interface &lt;em&gt;should&lt;/em&gt; be enough to also
enable packet forwarding (&lt;code&gt;IPForward&lt;/code&gt;). We will see if that&amp;rsquo;s really the case.&lt;/p&gt;
&lt;p&gt;Since we want to use &lt;code&gt;nftables&lt;/code&gt; instead of &lt;code&gt;iptables&lt;/code&gt; on this system,
&lt;code&gt;systemd&lt;/code&gt; &lt;a href=&#34;https://github.com/systemd/systemd/issues/13307&#34;&gt;&lt;em&gt;should&lt;/em&gt;&lt;/a&gt; be
modifying &lt;code&gt;nftables&lt;/code&gt; rather than using legacy &lt;code&gt;iptables&lt;/code&gt;. See also
&lt;a href=&#34;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=934584&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;pihole-dns&#34;&gt;PiHole DNS&lt;/h2&gt;
&lt;p&gt;I want &lt;a href=&#34;https://pi-hole.net&#34;&gt;PiHole&lt;/a&gt; to run on the router. This is basically
&lt;a href=&#34;https://linux.die.net/man/8/dnsmasq&#34;&gt;&lt;code&gt;dnsmasq&lt;/code&gt;&lt;/a&gt; with some filter lists and a
fancy GUI.&lt;/p&gt;
&lt;p&gt;PiHole is supported on Debian, so we should be able to just install it using
the installer script. However, the &lt;a href=&#34;https://docs.pi-hole.net/main/prerequisites/#ip-addressing&#34;&gt;installation instructions
mention&lt;/a&gt; that it
will install &lt;code&gt;dhcpcd5&lt;/code&gt; and modify &lt;code&gt;/etc/dhcpcd.conf&lt;/code&gt; to assign a static IP
address. We don&amp;rsquo;t want this because we will be using &lt;code&gt;systemd.networkd&lt;/code&gt; for
interface management.&lt;/p&gt;
&lt;p&gt;This means that I will potentially need to modify the installer script to skip
this.&lt;/p&gt;
&lt;h2 id=&#34;dhcp-server&#34;&gt;DHCP Server&lt;/h2&gt;
&lt;p&gt;The router should also run a DHCP server, optionally providing &amp;ldquo;static IPs&amp;rdquo; to
known clients based on MAC address.&lt;/p&gt;
&lt;p&gt;Since PiHole contains &lt;code&gt;dnsmasq&lt;/code&gt;, we can just enable the DHCP server built in
to &lt;code&gt;pihole-FTL.service&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;firewall&#34;&gt;Firewall&lt;/h2&gt;
&lt;p&gt;All incoming traffic except SSH and &lt;a href=&#34;https://mosh.org&#34;&gt;Mosh&lt;/a&gt; should be
blocked. We need &lt;a href=&#34;https://en.wikipedia.org/wiki/Stateful_firewall&#34;&gt;connection
tracking&lt;/a&gt; to allow clients to
communicate with Internet hosts.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve never used &lt;a href=&#34;https://wiki.debian.org/nftables&#34;&gt;&lt;code&gt;nftables&lt;/code&gt;&lt;/a&gt;, but since this
is the &lt;a href=&#34;https://lwn.net/Articles/747551/&#34;&gt;immediate future&lt;/a&gt; I&amp;rsquo;ll take this as
an opportunity to learn.&lt;/p&gt;
&lt;p&gt;In the &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-iii/&#34;&gt;next post&lt;/a&gt;, I&amp;rsquo;ll set up some VMs and
try setting this up before doing it on my physical network.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Adventures in Rolling Your Own Router: Part I</title>
      <link>https://pudar.net/adventures-in-rolling-your-own-router-part-i/</link>
      <pubDate>Sat, 16 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/adventures-in-rolling-your-own-router-part-i/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve been rolling my own router / firewall solution for several years now. I
started out using OpenBSD, but even though I loved &lt;code&gt;pf&lt;/code&gt; I eventually switched
over to Arch Linux. Throughout all these years, I&amp;rsquo;ve been using PiHole
installed on a Raspberry Pi 3 for DNS based ad-blocking.&lt;/p&gt;
&lt;p&gt;My Arch based router is getting a little crufty, and my documentation is
sparse (thanks, past me!), so I have decided now is a good time to start from
scratch, documenting the entire process from start to finish.&lt;/p&gt;
&lt;p&gt;The goal is to end up with a router / firewall running PiHole for DNS/DHCP and
using native systemd services wherever possible. I would also like the total
power drawn by my router / switch / access point to be reduced.&lt;/p&gt;
&lt;p&gt;In this first post, I&amp;rsquo;ll describe my current system.&lt;/p&gt;
&lt;h1 id=&#34;hardware&#34;&gt;Hardware&lt;/h1&gt;
&lt;p&gt;I&amp;rsquo;ll list everything plugged into my &lt;a href=&#34;https://www.apc.com/shop/us/en/products/APC-Power-Saving-Back-UPS-Pro-1500/P-BR1500G&#34;&gt;APC
UPS&lt;/a&gt;.
The power draw of all these components will determine how long my WiFi stays
online during a power outage.&lt;/p&gt;
&lt;p&gt;The current power draw of all the components is about 34W. This gives me about
two and a half hours of runtime.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;router-front.jpg&#34; alt=&#34;Thermal Image of Components&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;router&#34;&gt;Router&lt;/h2&gt;
&lt;h3 id=&#34;power-supply&#34;&gt;Power Supply&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&#34;https://www.amazon.com/gp/product/B073GY89G5&#34;&gt;Seasonic PSU&lt;/a&gt; I&amp;rsquo;m currently
using replaced the older &lt;a href=&#34;https://www.amazon.com/gp/product/B009VV56TO&#34;&gt;fanless Seasonic
PSU&lt;/a&gt; when the latter developed
some coil whine. The former does have a fan, but it hasn&amp;rsquo;t needed to run since
I got it.&lt;/p&gt;
&lt;h3 id=&#34;motherboard&#34;&gt;Motherboard&lt;/h3&gt;
&lt;p&gt;The motherboard is an &lt;a href=&#34;https://www.newegg.com/msi-am1i/p/N82E16813130759&#34;&gt;MSI AM1 Mini
ITX&lt;/a&gt;. I bought it on Newegg
for $24.99. Apparently the price has since jumped to $297.00 - this board is
probably worth less than &lt;em&gt;I&lt;/em&gt; paid for it, so I don&amp;rsquo;t know why the price jumped
so much.&lt;/p&gt;
&lt;h3 id=&#34;processor&#34;&gt;Processor&lt;/h3&gt;
&lt;p&gt;It has an &lt;a href=&#34;https://www.newegg.com/amd-athlon-5150/p/N82E16819113365?Item=9SIA1N83U90953&amp;amp;Tpk=9SIA1N83U90953&#34;&gt;Athlon 5150 Kabini Quad-Core 1.6
GHz&lt;/a&gt;
processor which has a TDP of 25W. The
&lt;a href=&#34;https://www.amazon.com/gp/product/B00U8PUNH2&#34;&gt;heatsink&lt;/a&gt; I use is massive
overkill for this.&lt;/p&gt;
&lt;h3 id=&#34;network-interfaces&#34;&gt;Network Interfaces&lt;/h3&gt;
&lt;p&gt;To provide dual Ethernet ports, I used an &lt;a href=&#34;https://www.amazon.com/gp/product/B000BMZHX2&#34;&gt;Intel
PRO/1000&lt;/a&gt;. Aside from running
hot, I&amp;rsquo;ve been extremely happy with this card.&lt;/p&gt;
&lt;h3 id=&#34;ram&#34;&gt;RAM&lt;/h3&gt;
&lt;p&gt;I reused 8G of RAM from an old machine.&lt;/p&gt;
&lt;h3 id=&#34;disk&#34;&gt;Disk&lt;/h3&gt;
&lt;p&gt;I reused a 128G SSD from an old machine.&lt;/p&gt;
&lt;h3 id=&#34;case&#34;&gt;Case&lt;/h3&gt;
&lt;p&gt;I picked the &lt;a href=&#34;https://www.amazon.com/gp/product/B00ID2FBU6&#34;&gt;Cooler Master Elite
130&lt;/a&gt; Mini-Itx case for its small
form factor.&lt;/p&gt;
&lt;h3 id=&#34;fans&#34;&gt;Fans&lt;/h3&gt;
&lt;p&gt;Although this build &lt;em&gt;can&lt;/em&gt; run completely fanless without much problem, I use
two &lt;a href=&#34;https://noctua.at/en/products/fan&#34;&gt;Noctua&lt;/a&gt; fans to keep everything cool.
There is one 120mm fan at the front blowing air over the CPU heatsink and
through the PSU and one 80mm fan pointed directly at the heatsink on the
network card.&lt;/p&gt;
&lt;p&gt;I am a loyal Noctua fan-boy (groan) because they make quietest fans I&amp;rsquo;ve ever
used. I&amp;rsquo;ve never had one fail on me, and the sickly brown color scheme has
been transformed in my mind from a downside to a badge of honor.&lt;/p&gt;
&lt;h2 id=&#34;switch&#34;&gt;Switch&lt;/h2&gt;
&lt;p&gt;Based on the heat output, this &lt;a href=&#34;https://www.amazon.com/gp/product/B00OLUMLPM&#34;&gt;Buffalo 16 Port Smart
Switch&lt;/a&gt; is using a lot of power.
I&amp;rsquo;m only using 8 ports, so I will be able to replace this with a smaller 8
port switch that should hopefully reduce power consumption. Since I&amp;rsquo;m getting
rid of the Raspberry Pi, I&amp;rsquo;ll still have one port left free in case I need to
plug in anything else.&lt;/p&gt;
&lt;h2 id=&#34;access-point&#34;&gt;Access Point&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;https://www.amazon.com/gp/product/B017MD6CHM&#34;&gt;UAP-AC-LITE&lt;/a&gt; provides good
signal throughout our entire house. It&amp;rsquo;s plugged in to a &lt;a href=&#34;https://www.amazon.com/gp/product/B01DW99IPS&#34;&gt;24W PoE
injector&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;modem&#34;&gt;Modem&lt;/h2&gt;
&lt;p&gt;I own, rather than rent, an &lt;a href=&#34;https://www.surfboard.com/products/cable-modems/sb6141/&#34;&gt;Arris
Surfboard&lt;/a&gt;. I only
pay for a 100 Mbps connection, so this device is plenty fast. My only
complaint is that it runs extremely hot.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;router-back.jpg&#34; alt=&#34;Thermal Image of Components&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;raspberry-pi&#34;&gt;Raspberry Pi&lt;/h2&gt;
&lt;p&gt;A slightly older &lt;a href=&#34;https://www.raspberrypi.org/products/raspberry-pi-3-model-b/&#34;&gt;Raspberry
Pi&lt;/a&gt; runs
&lt;a href=&#34;https://pi-hole.net/&#34;&gt;PiHole&lt;/a&gt;. It&amp;rsquo;s plugged in to a high quality USB power
adapter.&lt;/p&gt;
&lt;h2 id=&#34;phillips-hue-hub&#34;&gt;Phillips Hue Hub&lt;/h2&gt;
&lt;p&gt;If our home network goes down, so does our ability to control our Phillips Hue
lights. That&amp;rsquo;s really annoying, so I also have the &lt;a href=&#34;https://www.amazon.com/Philips-Hue-Stand-Alone-Bridge/dp/B016H0QZ7I&#34;&gt;Phillips Hue
Hub&lt;/a&gt;
plugged in to the UPS.&lt;/p&gt;
&lt;h1 id=&#34;software&#34;&gt;Software&lt;/h1&gt;
&lt;h2 id=&#34;arch-linux&#34;&gt;Arch Linux&lt;/h2&gt;
&lt;p&gt;I chose Arch Linux for my router because it is the distribution I&amp;rsquo;m most
comfortable with. I also like that it&amp;rsquo;s a rolling release because I know I&amp;rsquo;m
always getting all the latest updates.&lt;/p&gt;
&lt;p&gt;Most of my setup comes from the Arch Wiki pages
&lt;a href=&#34;https://wiki.archlinux.org/index.php/router&#34;&gt;Router&lt;/a&gt; and &lt;a href=&#34;https://wiki.archlinux.org/index.php/Simple_stateful_firewall&#34;&gt;Simple Stateful
Firewall&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The working parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Persistent interface names from &lt;code&gt;systemd-networkd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Network interface configuration with &lt;code&gt;netctl&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Packet forwarding enabled with systemd&lt;/li&gt;
&lt;li&gt;NAT with &lt;code&gt;netfilter&lt;/code&gt; (manually created &lt;code&gt;iptables&lt;/code&gt; rules)&lt;/li&gt;
&lt;li&gt;No DNS / DHCP servers&lt;/li&gt;
&lt;li&gt;Stateful firewall with &lt;code&gt;netfilter&lt;/code&gt; (&lt;code&gt;iptables&lt;/code&gt; rules)&lt;/li&gt;
&lt;li&gt;Persistent &lt;code&gt;iptables&lt;/code&gt; rules autoloaded with systemd unit &lt;code&gt;iptables.service&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Open ports for SSH and &lt;a href=&#34;https://mosh.org/&#34;&gt;Mosh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;No password auth. Password protected asymmetric key authentication&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The not so great things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;netctl&lt;/code&gt; instead of &lt;code&gt;systemd-networkd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Manual NAT / masquerade instead of using &lt;code&gt;systemd-networkd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;iptables&lt;/code&gt; is very difficult for me to understand&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My &lt;code&gt;iptables&lt;/code&gt; rules:&lt;/p&gt;
&lt;p&gt;(Note: I seem to have port 53 open for UDP and TCP on both the internal and
external interfaces. I think this is an error, as my DNS server should only be
accessible from inside the LAN. I also shouldn&amp;rsquo;t have UDP port 67 open to the
external interface. This is what I meant by &amp;ldquo;crufty&amp;rdquo;&amp;hellip;)&lt;/p&gt;
&lt;!-- markdownlint-disable line-length --&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Generated by iptables-save v1.8.6 on Sat Jan 16 16:01:36 2021
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;*nat
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:PREROUTING ACCEPT [69954:7342094]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:INPUT ACCEPT [2535:152263]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:OUTPUT ACCEPT [5496:362059]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:POSTROUTING ACCEPT [0:0]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A POSTROUTING -o extern0 -j MASQUERADE
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A POSTROUTING -s 192.168.10.0/24 -o extern0 -j MASQUERADE
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;COMMIT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Completed on Sat Jan 16 16:01:36 2021
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Generated by iptables-save v1.8.6 on Sat Jan 16 16:01:36 2021
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;*filter
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:INPUT DROP [0:0]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:FORWARD DROP [0:0]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:OUTPUT ACCEPT [60076:6351430]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:TCP - [0:0]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:UDP - [0:0]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:fw-interfaces - [0:0]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:fw-open - [0:0]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -i lo -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -m conntrack --ctstate INVALID -j DROP
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -p icmp -m icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -p udp -m conntrack --ctstate NEW -j UDP
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j TCP
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -p udp -j REJECT --reject-with icmp-port-unreachable
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -p tcp -j REJECT --reject-with tcp-reset
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A INPUT -j REJECT --reject-with icmp-port-unreachable
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A FORWARD -j fw-interfaces
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A FORWARD -j fw-open
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A FORWARD -j REJECT --reject-with icmp-host-unreachable
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A TCP -p tcp -m tcp --dport 22 -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A TCP -p tcp -m tcp --dport 53 -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A UDP -p udp -m multiport --dports 60000:61000 -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A UDP -p udp -m udp --dport 53 -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A UDP -p udp -m udp --dport 67 -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A fw-interfaces -i intern0 -j ACCEPT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;COMMIT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Completed on Sat Jan 16 16:01:36 2021
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Generated by iptables-save v1.8.6 on Sat Jan 16 16:01:36 2021
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;*raw
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:PREROUTING ACCEPT [6386246:7485406871]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;:OUTPUT ACCEPT [60076:6351430]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-A PREROUTING -m rpfilter --invert -j DROP
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;COMMIT
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Completed on Sat Jan 16 16:01:36 2021
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;!-- markdownlint-enable line-length --&gt;
&lt;h2 id=&#34;pihole&#34;&gt;PiHole&lt;/h2&gt;
&lt;p&gt;PiHole acts as the DNS and DHCP server. PiHole is some extra stuff on top of
&lt;code&gt;dnsmasq&lt;/code&gt;. Instead of &lt;code&gt;dnsmasq.service&lt;/code&gt;, &lt;code&gt;pihole-FTL.service&lt;/code&gt; is enabled.&lt;/p&gt;
&lt;p&gt;Configuration includes the following &lt;code&gt;dnsmasq&lt;/code&gt; entries:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;addn-hosts=/etc/pihole/local.list
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;addn-hosts=/etc/pihole/custom.list
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;localise-queries
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;no-resolv
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cache-size=10000
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;log-queries
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;log-facility=/var/log/pihole.log
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;local-ttl=2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;log-async
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;server=208.67.222.222
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;server=208.67.220.220
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;interface=eth0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;server=/use-application-dns.net/
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;dhcp-authoritative
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;dhcp-range=192.168.10.2,192.168.10.254,1h
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;dhcp-option=option:router,192.168.10.1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;dhcp-leasefile=/etc/pihole/dhcp.leases
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;domain=crbj.io
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;local=/crbj.io/
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;expand-hosts
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;read-ethers
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This treats any DNS lookups under the domain &lt;code&gt;crbj.io&lt;/code&gt; as local queries that
should not be forwarded, and ensures that a host like &lt;code&gt;pihole&lt;/code&gt; also gets
expanded to &lt;code&gt;pihole.crbj.io&lt;/code&gt;. Furthermore, the &lt;code&gt;/etc/ethers&lt;/code&gt; file is also read
to find the MAC address -&amp;gt; hostname mapping.&lt;/p&gt;
&lt;p&gt;By ensuring that every host on my network is listed in the &lt;code&gt;/etc/ethers&lt;/code&gt; file
and that there is a corresponding entry for each host in the &lt;code&gt;/etc/hosts&lt;/code&gt;
file, every host gets a persistently mapped IP address when it requests a DHCP
lease. It&amp;rsquo;s possible to accomplish the same thing using &lt;code&gt;dhcp-host&lt;/code&gt; entries in
the &lt;code&gt;dnsmasq&lt;/code&gt; config files, but I like using &lt;code&gt;/etc/hosts&lt;/code&gt; and &lt;code&gt;/etc/ethers&lt;/code&gt;
better for aesthetics.&lt;/p&gt;
&lt;p&gt;Furthermore, because the PiHole is also the DNS server, I get the added
benefit of being able to do DNS lookups of any host from any other host on the
network without having to modify any of the clients&amp;rsquo; &lt;code&gt;/etc/hosts&lt;/code&gt; files.&lt;/p&gt;
&lt;p&gt;In my &lt;a href=&#34;https://pudar.net/adventures-in-rolling-your-own-router-part-ii/&#34;&gt;next post&lt;/a&gt;, I&amp;rsquo;ll describe my plan for
the new router.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Big Green Egg Table: Design 1</title>
      <link>https://pudar.net/big-green-egg-table-design-1/</link>
      <pubDate>Wed, 15 Apr 2020 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/big-green-egg-table-design-1/</guid>
      <description>&lt;p&gt;After our Good Friday Fish Fry / Bridal Shower was canceled due to the
COVID-19 shelter-in-place guidelines, Melissa and I were recently gifted an
&lt;a href=&#34;https://biggreenegg.com/xlarge-big-green-egg/&#34;&gt;XL Big Green Egg&lt;/a&gt; by all my
aunts and uncles on my mom&amp;rsquo;s side. A couple of guys from &lt;a href=&#34;https://www.big-georges.com/&#34;&gt;Big
George&amp;rsquo;s&lt;/a&gt; delivered the Egg and set it up on our
deck without coming into contact with us. It&amp;rsquo;s a very beautiful cooker that
weighs just over 200 lbs. To bring it up to comfortable cooking height, it
arrived with an &lt;a href=&#34;https://biggreenegg.com/product/egg-nest/&#34;&gt;EGG Nest&lt;/a&gt;, a
fabricated metal pedestal on casters.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;IMGP4164.jpg&#34; alt=&#34;The XL Big Green Egg&#34;&gt;&lt;/p&gt;
&lt;p&gt;I have a few problems with the Nest:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The fragile Egg can easily be tipped over&lt;/li&gt;
&lt;li&gt;The wooden deck below the Egg has no protection from heat&lt;/li&gt;
&lt;li&gt;There are no work surfaces next to the grill and no storage for accessories&lt;/li&gt;
&lt;li&gt;The casters are not great&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;IMGP4165.jpg&#34; alt=&#34;The EGG Nest locking caster&#34;&gt;&lt;/p&gt;
&lt;p&gt;Being a hobbyist woodworker, I naturally want to build my own replacement for
the EGG Nest. In this post I will examine some of the existing designs
floating around on the Internet before creating my own set of plans which meet
my criteria.&lt;/p&gt;
&lt;h2 id=&#34;commercial-nest-alternatives&#34;&gt;Commercial Nest Alternatives&lt;/h2&gt;
&lt;p&gt;There are lots of commercial alternatives to the EGG Nest, such as as the
&lt;a href=&#34;https://biggreenegg.com/product/modular-nests/&#34;&gt;Modular Nest EGG Frame&lt;/a&gt; or
the &lt;a href=&#34;https://biggreenegg.com/product/new-76-in-custom-cooking-island/&#34;&gt;76 inch Custom Cooking
Island&lt;/a&gt;.
However, these are in my opinion far too expensive.&lt;/p&gt;
&lt;p&gt;Also available from Big Green Egg is the &lt;a href=&#34;https://biggreenegg.com/product/solid-acacia-hardwood-tables/&#34;&gt;Acacia Hardwood
Table&lt;/a&gt; which is
what my dad has been using for fifteen years with his egg.&lt;/p&gt;
&lt;p&gt;Wooden tables are also available from third party manufacturers such as
&lt;a href=&#34;https://www.jjgeorgestore.com/long-table-for-xl-big-green-egg/&#34;&gt;JJGeorge&lt;/a&gt; and
&lt;a href=&#34;http://jsdesignsshop.com/outdoor-furniture/&#34;&gt;J S Designs Shop&lt;/a&gt; which are of a
similar design to the original BGE table.&lt;/p&gt;
&lt;h2 id=&#34;diy-tables&#34;&gt;DIY Tables&lt;/h2&gt;
&lt;p&gt;There are countless examples of DIY wooden tables for the Big Green Egg on the
Internet. For example, the top Google search result for &lt;code&gt;diy big green egg table&lt;/code&gt; will lead you to &lt;a href=&#34;https://www.searedandsmoked.com/&#34;&gt;Seared and Smoked&lt;/a&gt;
which has a &lt;a href=&#34;https://www.youtube.com/watch?v=1R0Obf1DM4w&#34;&gt;video&lt;/a&gt; and
&lt;a href=&#34;https://www.searedandsmoked.com/diy-big-green-egg-table/&#34;&gt;plans&lt;/a&gt; for their
design.&lt;/p&gt;
&lt;p&gt;Some other random examples I&amp;rsquo;ve found:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://youtu.be/VTpsrRHx3Cc?t=1338&#34;&gt;Andys Werkstatt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=_vsBq4gG6fI&#34;&gt;Bellman Woodworking And Designs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=sAxnpDejTlQ&#34;&gt;BigMeat Sunday&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=yWkRu6MH_QQ&#34;&gt;Dogwood Nation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=HvKA4ikJ4KI&#34;&gt;Luke Marazzi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://myoutdoorplans.com/furniture/large-big-green-egg-table-plans/&#34;&gt;My Outdoor Plans&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=2gLcmVipINY&#34;&gt;Seared and Smoked&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=bQOkBJ17U5E&#34;&gt;Smoke &amp;amp; Hammer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://eggheadforum.com/discussion/1217026/bge-table-build-question&#34;&gt;unoriginalusername&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All these examples so far share a common design decision: they don&amp;rsquo;t use any
joinery. Instead of designing the structures using wood joints which have been
proven to last for hundreds of years, they rely purely on the strength of the
fasteners used to screw the wood together.&lt;/p&gt;
&lt;p&gt;The commercially designed tables likely are made in this manner to make them
easy to ship and assemble. If large diameter bolts are used to fix the Egg
platform to the legs, the table will likely be solid and last quite a long
time. However, if you use regular screws to simply screw the platform to the
legs as seen in most DIY plans available online, you will be relying on the
shear strength of the screws.&lt;/p&gt;
&lt;p&gt;A common wood screw is very good at squeezing two boards together along its
axis. The withdrawl or pullout force of a screw is relatively high. However,
screws are not very good at resisting shear forces perpendicular to their
axis. You can read more about the differences between shear and pullout
strength at &lt;a href=&#34;https://www.builderonline.com/building/dear-builders-engineer-nails-or-screws_o&#34;&gt;Builder
Online&lt;/a&gt;
or simply use a search engine with keywords &lt;code&gt;shear strength of screws&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To make matters worse, even the best metal hardware will deteriorate over time
due to the elements. I can&amp;rsquo;t think of a worse way to wake up in fifteen years
than the sound of ceramic crashing to the ground due to failed wood screws!&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t get me wrong - I don&amp;rsquo;t intend to call anybody out or suggest that these
tables won&amp;rsquo;t be up to their intended task. On the contrary, most of these
tables will likely hold up fine for many years. However, using different
woodworking techniques we can create furniture which lasts for centuries, not
decades.&lt;/p&gt;
&lt;h2 id=&#34;well-designed-tables&#34;&gt;Well-designed Tables&lt;/h2&gt;
&lt;p&gt;I have been able to find some examples of DIYers who have used some proper
joinery. The commonality here is that the weight of the cooker is supported by
wood, not by fasteners. In all these designs the smoker would still be well
supported if the fasteners were removed and the structures were not subjected
to any racking forces.&lt;/p&gt;
&lt;h3 id=&#34;mortise-and-tenon-joints&#34;&gt;Mortise and Tenon Joints&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&#34;https://en.wikipedia.org/wiki/Mortise_and_tenon&#34;&gt;Mortise and Tenon&lt;/a&gt; joint
is the mack daddy of frame construction. A hole, or mortise, is cut in one
piece and a matching insert, or tenon, is cut in the end of the piece to be
joined to it. The tenon is inserted into the mortise and fixed using glue,
&lt;a href=&#34;https://www.popularwoodworking.com/projects/wedged-mortise-and-tenon/&#34;&gt;wedges&lt;/a&gt;,
or
&lt;a href=&#34;https://www.popularwoodworking.com/techniques/drawboring-resurrected/&#34;&gt;drawboring&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=HE0uTzmLquU&#34;&gt;Carter Rosenbloom&lt;/a&gt; has put
together a beautiful Big Green Egg table built with mortise and tenon joints.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.lumberjocks.com/projects/80911&#34;&gt;DustyMark&lt;/a&gt; also has some end
result photos of his mahogany table which was assembled with mortise and tenon
joints.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://eggheadforum.com/discussion/1146191/custom-built-table-for-large-bge-ipe-wood&#34;&gt;mteele&lt;/a&gt;
on the EGGhead forum also posted some PDF plans and photos of his gorgeous Ipe
wood table using M&amp;amp;T joints. I&amp;rsquo;d be a little concerned with the breadboard
ends; depending on how they were glued up the table top could eventually split
due to the wood movement of the long table pieces.&lt;/p&gt;
&lt;h3 id=&#34;lap-joints&#34;&gt;Lap Joints&lt;/h3&gt;
&lt;p&gt;A &lt;a href=&#34;https://en.wikipedia.org/wiki/Lap_joint&#34;&gt;Lap Joint&lt;/a&gt; is another great joint
for use in frame construction. In a lap joint, material is removed from one or
both pieces where they cross or overlap. This joint ensures a lot of
long-grain surface area meets for a very strong glue up. It doesn&amp;rsquo;t have the
same resistance to glue failure as a mortise and tenon joint, but with modern
glues like Titebond III this really isn&amp;rsquo;t a problem.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.instructables.com/id/Inexpensive-Strong-Green-Egg-Table/&#34;&gt;jessemckee&lt;/a&gt;
of Instructables has written some free plans for a very nice and simple table
using lap joints. I think he really nailed it with this project!&lt;/p&gt;
&lt;p&gt;In my next post, I&amp;rsquo;ll explore some of my own design criteria and work out some
initial plans.&lt;/p&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Integrate Magit With JetBrains</title>
      <link>https://pudar.net/integrate-magit-with-jetbrains/</link>
      <pubDate>Wed, 15 Apr 2020 00:00:00 +0000</pubDate>
      
      <guid>https://pudar.net/integrate-magit-with-jetbrains/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m a huge fan of &lt;a href=&#34;https://magit.vc/&#34;&gt;Magit&lt;/a&gt;. I honestly can&amp;rsquo;t imagine doing
software development without it. However, I&amp;rsquo;ve recently moved from Emacs to
JetBrains products like PyCharm, WebStorm, and IntelliJ to take advantage of
some of their more advanced features. In my opinion, Magit is light years
ahead of the JetBrains version control client.&lt;/p&gt;
&lt;p&gt;I wanted a good way to integrate my existing Magit workflow into my new
JetBrains workflow. I started off with some hints from
&lt;a href=&#34;https://www.jetbrains.com/help/idea/using-emacs-as-an-external-editor.html#&#34;&gt;JetBrains&lt;/a&gt;
and some more from Atlassian&amp;rsquo;s &lt;a href=&#34;https://www.jetbrains.com/help/idea/using-emacs-as-an-external-editor.html#&#34;&gt;Developer
Blog&lt;/a&gt;
and came up with something that works for me.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;magit-external-tool-screenshot.png&#34; alt=&#34;Screenshot of External Tool dialog&#34;&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Program:            /usr/local/bin/emacsclient
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Arguments:          -n -e &amp;#34;(progn (x-focus-frame nil) (magit-status))&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Working directory:  $FileDir$
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Ensure Emacs is always running (it already is, right?) and that you have
started a server. I make sure this happens by default by adding
&lt;code&gt;(server-start)&lt;/code&gt; to my Emacs config file.&lt;/p&gt;
&lt;p&gt;Now, you can call &lt;code&gt;emacsclient&lt;/code&gt; to pass commands to your running server.&lt;/p&gt;
&lt;p&gt;In this External Tool configuration, we are calling &lt;code&gt;(x-focus-frame nil)&lt;/code&gt; to
bring your Emacs frame to the foreground. This works on macOS Catalina, but
you might need to try &lt;code&gt;(raise-frame)&lt;/code&gt; if you are on a different OS.&lt;/p&gt;
&lt;p&gt;Finally, calling &lt;code&gt;(magit-status)&lt;/code&gt; will bring up the Magit status page.&lt;/p&gt;
&lt;p&gt;Make sure the &amp;ldquo;Open console for tool output&amp;rdquo; is unchecked to avoid cluttering
your JetBrains workspace.&lt;/p&gt;
&lt;p&gt;Finally, you can assign the External Tool to a keyboard shortcut or assign it
an abbreviation in Preferences &amp;gt; Keymap.&lt;/p&gt;
&lt;p&gt;For more ideas, see &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Invoking-emacsclient.html&#34;&gt;Invoking
&lt;code&gt;emacsclient&lt;/code&gt;&lt;/a&gt;
and &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html&#34;&gt;&lt;code&gt;emacsclient&lt;/code&gt;
Options&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    
    
    
    
    
  </channel>
</rss>
