<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Firewall on Andrew's Memory Blog</title><link>https://andrewmemory.acornwall.net/tags/firewall/</link><description>Recent content in Firewall on Andrew's Memory Blog</description><generator>Hugo -- gohugo.io</generator><image><url>https://andrewmemory.acornwall.net/img/rss_image.png</url><title>Firewall on Andrew's Memory Blog</title><link>https://andrewmemory.acornwall.net/</link></image><language>en</language><managingEditor>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</managingEditor><webMaster>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</webMaster><copyright>Copyright 2009--2025</copyright><lastBuildDate>Sat, 01 Feb 2025 01:28:19 -0700</lastBuildDate><atom:link href="https://andrewmemory.acornwall.net/tags/firewall/index.xml" rel="self" type="application/rss+xml"/><item><title>Fixing buffer bloat on OpenBSD 7.2</title><link>https://andrewmemory.acornwall.net/blog/2025-02-01-fixing-bufferbloat-on-openbsd/</link><pubDate>Sat, 01 Feb 2025 01:28:19 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2025-02-01-fixing-bufferbloat-on-openbsd/</guid><description>&lt;p&gt;I learned a little today about buffer bloat, which is latency introduced when uploading/downloading. After that, I headed straight over to &lt;a href="https:///www.waveform.com/tools/bufferbloat" target="_blank" rel="noreferrer"&gt;WaveForm&amp;rsquo;s buffer bloat test&lt;/a&gt; and got a D.&lt;/p&gt;
&lt;p&gt;Luckily, the WaveForm page pointed me to a solution, which I found at &lt;a href="https://www.pauladamsmith.com/blog/2018/07/fixing-bufferbloat-on-your-home-network-with-openbsd-6.2-or-newer.html" target="_blank" rel="noreferrer"&gt;Paul Smith&amp;rsquo;s blog&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Following Paul&amp;rsquo;s instructions, I added a Queue section to my /etc/pf.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;#---------------------------------#
# Queues
#---------------------------------#
queue outq on $ext_if flows 1024 bandwidth 10M max 10M qlimit 1024 default
queue inq on $lan_if flows 1024 bandwidth 225M max 225M qlimit 1024 default&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;then reloaded the rules:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;doas pfctl -n -f /etc/pf.conf &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; doas pfctl -f /etc/pf.conf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;I didn&amp;rsquo;t get an A, but I did move up to a C, which means I&amp;rsquo;ve at least halved the latency problem. There&amp;rsquo;s a warning in a comment on Paul Smith&amp;rsquo;s page:&lt;/p&gt;
&lt;p&gt;&amp;ldquo;This works well if you have OpenBSD acting as a firewall/NAT appliance only, but doesn&amp;rsquo;t work if you have multiple downstream interfaces, or run any services on the OpenBSD server at all (facing either the LAN &lt;del&gt;or&lt;/del&gt; the internet).&amp;rdquo; The commenter suggests an explict parent queue with the whole LAN bandwidth and subqueues for internet and everything else.&lt;/p&gt;
&lt;p&gt;Anyway, I went to &lt;a href="https://speed.cloudflare.com/" target="_blank" rel="noreferrer"&gt;CloudFlare&amp;rsquo;s speed test&lt;/a&gt; and I&amp;rsquo;m &amp;ldquo;great.&amp;rdquo;&lt;/p&gt;</description></item><item><title>Block Ad Sites and Nasties on OpenBSD 7.4</title><link>https://andrewmemory.acornwall.net/blog/2023-10-22-block-ad-sites-and-nasties-on-openbsd-7-4/</link><pubDate>Sun, 22 Oct 2023 22:03:47 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2023-10-22-block-ad-sites-and-nasties-on-openbsd-7-4/</guid><description>&lt;p&gt;One of the benefits of building your own firewall is that you get to decide what you want to block. I&amp;rsquo;d been using a list from &lt;a href="https://pgl.yoyo.org/adservers" target="_blank" rel="noreferrer"&gt;pgl.yoyo.org/adservers&lt;/a&gt;. There&amp;rsquo;s a utility called &lt;a href="https://www.geoghegan.ca/pfbadhost.html" target="_blank" rel="noreferrer"&gt;Pf-badhost&lt;/a&gt; that blocks evil hosts. I wanted to do a little more: block bad IPs (sorry, Cloudflare, I know you hate that) and have better control over when things get updated.&lt;/p&gt;
&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt="A virus/malware hazard icon"
width="335"
height="334"
src="https://andrewmemory.acornwall.net/blog/2023-10-22-block-ad-sites-and-nasties-on-openbsd-7-4/images/virus_malware_hazard_icon.png"
srcset="https://andrewmemory.acornwall.net/blog/2023-10-22-block-ad-sites-and-nasties-on-openbsd-7-4/images/virus_malware_hazard_icon.png 800w, https://andrewmemory.acornwall.net/blog/2023-10-22-block-ad-sites-and-nasties-on-openbsd-7-4/images/virus_malware_hazard_icon.png 1280w"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="https://andrewmemory.acornwall.net/blog/2023-10-22-block-ad-sites-and-nasties-on-openbsd-7-4/images/virus_malware_hazard_icon.png"&gt;&lt;/figure&gt;
&lt;p&gt;So I ultimately decided to adapt some of Pf-badhost to a few scripts I created. First, a script to get the latest list of bad hostnames from pgl.yoyo.org — grab-bad-hosts.sh:&lt;/p&gt;
&lt;h2 class="relative group"&gt;Grabbing Bad Hostnames
&lt;div id="grabbing-bad-hostnames" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#grabbing-bad-hostnames" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;#! /bin/sh
/usr/local/bin/wget -O ./pgl-adhosts.conf &amp;#39;https://pgl.yoyo.org/adservers/serverlist.php?hostformat=unbound&amp;amp;showintro=1&amp;amp;mimetype=plaintext&amp;#39;
grep -v -f /var/unbound/etc/unbound-whitelist-ads.txt pgl-adhosts.conf &amp;gt; unbound-adhosts.conf
grep -f /var/unbound/etc/unbound-whitelist-ads.txt pgl-adhosts.conf &amp;gt; unbound-adhosts-whitelist.conf
echo &amp;#34;In a root shell, run:&amp;#34;
echo &amp;#34;cat unbound-adhosts.conf &amp;gt; /var/unbound/etc/unbound-adhosts.conf&amp;#34;
echo &amp;#34;cat unbound-adhosts-whitelist.conf &amp;gt; /var/unbound/etc/unbound-adhosts-whitelist.conf&amp;#34;
echo &amp;#34;rcctl restart unbound&amp;#34;
echo &amp;#34;(or run root-update-hosts.sh as root)&amp;#34;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;This builds two files: /var/unbound/etc/unbound-adhosts.conf and /var/unbound/etc/unbound-adhosts-whitelists.conf based on a file I created, /var/unbound/etc/unbound-whitelist-ads.txt, which I had to add to make other users happy. /var/unbound/etc/unbound-whitelist-ads.txt looks like this:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;adservice.google.com[^.]
googleadservices.com[^.]&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;&amp;hellip; and I&amp;rsquo;m going to set up unbound to allow one host to have the whitelisted ads.&lt;/p&gt;
&lt;h2 class="relative group"&gt;Grabbing &lt;strong&gt;B&lt;/strong&gt;ad IPs
&lt;div id="grabbing-bad-ips" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#grabbing-bad-ips" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;I used Pf-badhost as a source of places to grab bad IP addresses from. I ended up with this script, grab-bad-ips.sh:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;#! /bin/sh
/usr/local/bin/wget -O ./banlist_firehol_level1 https://raw.githubusercontent.com/firehol/blocklist-ipsets/master/firehol_level1.netset
/usr/local/bin/wget -O ./banlist_firehol_level2 https://raw.githubusercontent.com/firehol/blocklist-ipsets/master/firehol_level2.netset
/usr/local/bin/wget -O ./banlist_binarydefence https://www.binarydefense.com/banlist.txt
/usr/local/bin/wget -O ./banlist_emergingthreats https://rules.emergingthreats.net/fwrules/emerging-Block-IPs.txt
cat ./banlist_firehol_level1 &amp;gt; pf-badguys.table
printf &amp;#34;\n&amp;#34;&amp;gt;&amp;gt; pf-badguys.table
cat ./banlist_firehol_level2 &amp;gt;&amp;gt; pf-badguys.table
printf &amp;#34;\n&amp;#34;&amp;gt;&amp;gt; pf-badguys.table
cat ./banlist_binarydefence &amp;gt;&amp;gt; pf-badguys.table
printf &amp;#34;\n&amp;#34;&amp;gt;&amp;gt; pf-badguys.table
cat ./banlist_emergingthreats &amp;gt;&amp;gt; pf-badguys.table
printf &amp;#34;\n&amp;#34;&amp;gt;&amp;gt; pf-badguys.table
grep &amp;#39;^[0-9]&amp;#39; pf-badguys.table | sort | uniq &amp;gt; pf-badguys.table.sort.uniq
mv pf-badguys.table.sort.uniq pf-badguys.table
echo &amp;#34;In a root shell, run:&amp;#34;
echo &amp;#34; cat pf-badguys.table &amp;gt; /etc/pf-badguys.table&amp;#34;
echo &amp;#34; pfctl -F Tables -f /etc/pf.conf&amp;#34;
echo &amp;#34;(or run root-update-ips.sh as root)&amp;#34;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;This script creates /etc/pf-badguys.table, which I&amp;rsquo;ll plug into my PF configuration.&lt;/p&gt;
&lt;h2 class="relative group"&gt;Configuring unbound to use the bad hosts lists
&lt;div id="configuring-unbound-to-use-the-bad-hosts-lists" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#configuring-unbound-to-use-the-bad-hosts-lists" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s not hard to have unbound import the bad hosts, which are already formatted to redirect to 127.0.0.1. Here&amp;rsquo;s a sample from /var/unbound/etc/unbound-adhosts.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;local-zone: &amp;#34;1-1ads.com&amp;#34; redirect
local-data: &amp;#34;1-1ads.com A 127.0.0.1&amp;#34;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;unbound-adhosts-whitelist.conf looks the same, but only contains the whitelisted ad servers. After the last local-data:/local-data-ptr: pair for my network, I added the following:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt; # open a hole for ad servers
# 192.168.150.180 is unblocked desktop
access-control-view: 192.168.150.180/32 adview&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;After my access-control: directives, I added:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# Host addresses - spam to block
#
include: /var/unbound/etc/unbound-adhosts.conf
include: /var/unbound/etc/unbound-adhosts-whitelist.conf
include: /var/unbound/etc/unbound-adhosts-local.conf&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;At the end of the unbound.conf file I added:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;view:
name: &amp;#34;adview&amp;#34;
include: /var/unbound/etc/unbound-adhosts.conf
include: /var/unbound/etc/unbound-adhosts-local.conf&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Then a quick:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# unbound-checkconf
# rcctl restart unbound&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;&amp;hellip; and I was blocking ad servers. I could update this in cron, but I prefer to do it manually every week or so.&lt;/p&gt;
&lt;h2 class="relative group"&gt;Configuring PF to block the bad IP addresses
&lt;div id="configuring-pf-to-block-the-bad-ip-addresses" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#configuring-pf-to-block-the-bad-ip-addresses" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;I know there&amp;rsquo;s an argument for not blocking bad IP addresses. After all, there may be legitimate sites that are hosted on the same IP address. But&amp;hellip; so far I&amp;rsquo;ve only run into one. So I&amp;rsquo;m happy to continue blocking them. In my pf.conf, after the &lt;martians&gt; table, I added a &lt;badguys&gt; table:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;table &amp;lt;badguys&amp;gt; persist file &amp;#34;/etc/pf-badguys.table&amp;#34;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Then after the block for martians, I added an equivalent for badguys:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# Block addresses in the badguys table
# We use the &amp;#34;quick&amp;#34; parameter here to make this rule the last.
# Note that badguys might contain martians, but they get handled before
# this rule.
block in quick on $ext_if from &amp;lt;badguys&amp;gt; to any
block return out quick on $ext_if from any to &amp;lt;badguys&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Then &lt;code&gt;pfctl -F Tables -f /etc/pf.conf&lt;/code&gt; to reread the table.&lt;/p&gt;
&lt;p&gt;This post is part of a series on &lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/" &gt;setting up an OpenBSD 7.4 firewall device&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Setting up Wireguard on an OpenBSD 7.4 firewall device</title><link>https://andrewmemory.acornwall.net/blog/2023-10-22-setting-up-wireguard-on-an-openbsd-7-4-firewall-device/</link><pubDate>Sun, 22 Oct 2023 21:09:01 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2023-10-22-setting-up-wireguard-on-an-openbsd-7-4-firewall-device/</guid><description>&lt;p&gt;It took me a little while after I set up my firewall device to set up Wireguard as a VPN. It&amp;rsquo;s probably something I should have done right away — the benefits of being able to log in from home (and block ads) while on the road is really nice.&lt;/p&gt;
&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt="The Wireguard logo"
width="300"
height="300"
src="https://andrewmemory.acornwall.net/blog/2023-10-22-setting-up-wireguard-on-an-openbsd-7-4-firewall-device/images/wireguard_logo-1.png"
srcset="https://andrewmemory.acornwall.net/blog/2023-10-22-setting-up-wireguard-on-an-openbsd-7-4-firewall-device/images/wireguard_logo-1.png 800w, https://andrewmemory.acornwall.net/blog/2023-10-22-setting-up-wireguard-on-an-openbsd-7-4-firewall-device/images/wireguard_logo-1.png 1280w"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="https://andrewmemory.acornwall.net/blog/2023-10-22-setting-up-wireguard-on-an-openbsd-7-4-firewall-device/images/wireguard_logo-1.png"&gt;&lt;/figure&gt;
&lt;p&gt;Wireguard needs a publicly available IP or domain name. I used DuckDNS. I &lt;a href="https://andrewmemory.acornwall.net/blog/2023-05-20-setting-up-duckdns-on-openbsd/" &gt;posted about that&lt;/a&gt; a while back so I won&amp;rsquo;t do it again here, but you&amp;rsquo;ll need to do that first.&lt;/p&gt;
&lt;p&gt;Wireguard is in the kernel in 7.4. Prior releases required you to &lt;code&gt;pkg_add wireguard_tools&lt;/code&gt;, but these days you don&amp;rsquo;t need to.&lt;/p&gt;
&lt;p&gt;The way Wireguard works is that you generate public and private keys. Each device gets its own private key, and you share the public keys. Wireguard has tools to do that. On the OpenBSD firewall side:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# mkdir /etc/wireguard
# chmod 700 /etc/wireguard
# wg genkey &amp;gt; /etc/wireguard/private.key
# chmod 600 /etc/wireguard/private.key
# wg pubkey &amp;lt; private.key &amp;gt; public.key&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Next, you need to generate private and public keys on each of your clients. Then set up /etc/wireguard/wg0.conf to contain the firewall&amp;rsquo;s private key and also the public keys of the client. I decided to do this on a completely different network — 172.16. I assigned individual IP addresses for each device. It&amp;rsquo;s a little more management headache, but makes it easy to delete something if I lose a device. The /etc/wireguard/wg0.conf looks like this:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;[Interface]
PrivateKey = the private key from /etc/wireguard/private.key
ListenPort = 51820
[Peer]
# My first peer - a laptop
PublicKey = the public key from the laptop
AllowedIPs = 172.16.0.2
[Peer]
# My second peer - an Android device running Wireguard from F-Droid
PublicKey = the public key from the device
AllowedIPs = 172.16.0.3
# ... etc...&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Obviously, on each device you have to do the reverse: specify the private key generated on device, and put the firewall&amp;rsquo;s public key in as the peer. Next, you need an /etc/hostname.wg0 to bring the network up:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;inet 172.16.0.1 255.255.255.0 NONE up
!/usr/local/bin/wg setconf wg0 /etc/wireguard/wg0.conf&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Before you can go further, you need to unblock the Wireguard interface in /etc/pf.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;(after the lan_if macro)
vpn_if=&amp;#34;wg0&amp;#34;
vpn_port=&amp;#34;51820&amp;#34;
(at the end after the NAT rules)
#---------------------------------#
# WireGuard
#---------------------------------#
pass in on $vpn_if
pass in inet proto udp from any to any port $vpn_port
pass out on egress inet from ($vpn_if:network) nat-to ($ext_if:0)&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;From there, you can restart pf and reload the new rules and &lt;code&gt;sh /etc/netstart wg0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This post is part of a series on &lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/" &gt;setting up an OpenBSD 7.4 firewall device&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Set up networking for an OpenBSD 7.4 firewall device</title><link>https://andrewmemory.acornwall.net/blog/2023-10-21-set-up-networking-for-an-openbsd-7-4-firewall-device/</link><pubDate>Sat, 21 Oct 2023 17:14:44 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2023-10-21-set-up-networking-for-an-openbsd-7-4-firewall-device/</guid><description>&lt;p&gt;I had a few wrinkles because I&amp;rsquo;d already set up networking, and I didn&amp;rsquo;t want to have to go through and redo all my static IPs. But I wanted to make my network more rational. I had devices on 192.168.150.*/24 and I wanted something bigger, so I decided to go with /20. That gave me a range of 92.168.144.1–192.168.159.254. (I admit I used an &lt;a href="https://www.calculator.net/ip-subnet-calculator.html" target="_blank" rel="noreferrer"&gt;IP subnet calculator&lt;/a&gt; for that.) My ISP gives me IPv4, so I&amp;rsquo;m using that and not worrying about IPv6.&lt;/p&gt;
&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt=""
width="221"
height="172"
src="https://andrewmemory.acornwall.net/blog/2023-10-21-set-up-networking-for-an-openbsd-7-4-firewall-device/images/wafiz14.jpg"
srcset="https://andrewmemory.acornwall.net/blog/2023-10-21-set-up-networking-for-an-openbsd-7-4-firewall-device/images/wafiz14.jpg 800w, https://andrewmemory.acornwall.net/blog/2023-10-21-set-up-networking-for-an-openbsd-7-4-firewall-device/images/wafiz14.jpg 1280w"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="https://andrewmemory.acornwall.net/blog/2023-10-21-set-up-networking-for-an-openbsd-7-4-firewall-device/images/wafiz14.jpg"&gt;&lt;/figure&gt;
&lt;p&gt;First things first: let&amp;rsquo;s make the box forward packets:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# sysctl net.inet.ip.forwarding=1
# echo &amp;#39;net.inet.ip.forwarding=1&amp;#39; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;h2 class="relative group"&gt;Configure Network Adapters
&lt;div id="configure-network-adapters" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#configure-network-adapters" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;I have two Intel NICs. I&amp;rsquo;m connecting igc0 to my cable modem. I&amp;rsquo;m connecting igc1 to a 16-port switch which is my internal network. I&amp;rsquo;ve got another network port that was autodetected, but I&amp;rsquo;m not using it yet, so I&amp;rsquo;ll remove it.&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# echo &amp;#34;inet autoconf&amp;#34; &amp;gt; /etc/hostname.igc0
# echo &amp;#34;inet 192.168.144.1 255.255.240.0 NONE&amp;#34; &amp;gt; /etc/hostname.igc1
# rm /etc/hostname.igc2
# sh /etc/netstart.sh&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;h2 class="relative group"&gt;Setting up the PF packet filter
&lt;div id="setting-up-the-pf-packet-filter" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#setting-up-the-pf-packet-filter" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;Now, set up PF. I got my instructions for this mostly from &lt;a href="https://home.nuug.no/~peter/pf/en/ftpproblem.html" target="_blank" rel="noreferrer"&gt;home.nuug.no/~peter/pf/en/ftpproblem.html&lt;/a&gt;. Here&amp;rsquo;s how I edited /etc/pf.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;#---------------------------------#
# Macros
#---------------------------------#
ext_if=&amp;#34;igc0&amp;#34;
lan_if=&amp;#34;igc1&amp;#34;
ftpproxy=&amp;#34;127.0.0.1&amp;#34;
ftpproxyport=&amp;#34;8021&amp;#34;
#---------------------------------#
# Tables
#---------------------------------#
table &amp;lt;localonly&amp;gt; { \
# Addresses that can talk to the local network but not to the rest of the world
\
# Local printer
192.168.158.1/32 \
}
# This is a table of non-routable private addresses.
table &amp;lt;martians&amp;gt; { 0.0.0.0/8 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 \
172.16.0.0/12 192.0.0.0/24 192.0.2.0/24 224.0.0.0/3 \
192.168.0.0/16 198.18.0.0/15 198.51.100.0/24 \
203.0.113.0/24 }
#---------------------------------#
# Protect and block by default
#---------------------------------#
set skip on lo0
set block-policy drop
# Spoofing protection for all NICs.
block in from no-route
block in quick from urpf-failed
# Block non-routable private addresses.
# We use the &amp;#34;quick&amp;#34; parameter here to make this rule the last.
block in quick on $ext_if from &amp;lt;martians&amp;gt; to any
block return out quick on $ext_if from any to &amp;lt;martians&amp;gt;
# Default blocking all traffic in on all LAN NICs from any computer or device
# attached.
block return in on { $lan_if }
# Default blocking all traffic in on the external NIC from the Internet/ISP,
# we&amp;#39;ll log that too.
block drop in log on $ext_if
# Don&amp;#39;t allow ICMP from outside. Commented out this section.
# Yeah, I know people hate that.
#
#match in on $ext_if inet proto icmp icmp-type {echoreq } tag ICMP_IN
#block drop in on $ext_if proto icmp
#pass in proto icmp tagged ICMP_IN max-pkt-rate 100/10
# We need the router to have access to the Internet, so we&amp;#39;ll default allow
# packets to pass out from our router through the external NIC to the Internet.
pass out inet from $ext_if
#---------------------------------#
# LAN Setup
#---------------------------------#
# Allow any computer or device on the LAN to send data packets in through the NIC.
# This means any computer attached to this network interface can pass in data
# reaching anywhere, i.e. the Internet or any of the computers attached to the
# router.
pass in on $lan_if
# Always block DNS queries not addressed to our DNS server.
block return in quick on $lan_if proto { udp tcp } to ! $lan_if port { 53 853 }
# Block localonly from seeing the internet
block in quick on lan_if from &amp;lt;localonly&amp;gt;
# Allow data packets to pass from the router out through the NIC to the
# computers or devices attached to it on the lan NIC.
# Without this we can&amp;#39;t even ping computers attached to the lan NIC from
# the router itself.
pass out on $lan_if inet keep state
#---------------------------------#
# FTP
#---------------------------------#
# allow ftp clients to work
anchor &amp;#34;ftp-proxy/*&amp;#34;
pass in quick on $lan_if inet proto tcp to port ftp divert-to $ftpproxy port $ftpproxyport
# no ftp servers so don&amp;#39;t pass out
# pass out proto tcp from $ftpproxy to any port ftp
#---------------------------------#
# NAT
#---------------------------------#
pass out on $ext_if inet from $lan_if:network to any nat-to ($ext_if)&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Then you can test things out and restart pf. I think my network connection dropped at this point:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# pfctl -n -f /etc/pf.conf
# pfctl -F all
# pfctl -f /etc/pf.conf&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;h2 class="relative group"&gt;Configure dhcpd
&lt;div id="configure-dhcpd" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#configure-dhcpd" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;Now I need to configure serving IPs from this machine. (My old firewall is still on the network at this point and serving real IPs as well as doing DNS, but I need to get the new firewall enabled.) So time to edit /etc/dhcpd.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# $OpenBSD: dhcpd.conf,v 1.1 1998/08/19 04:25:45 form Exp $
#
# DHCP server options.
# See dhcpd.conf(5) and dhcpd(8) for more information.
#
# This is for 192.168.144.* to 192.168.159.*
subnet 192.168.144.0 netmask 255.255.240.0 {
option domain-name &amp;#34;lan.example.net&amp;#34;;
option domain-name-servers 192.168.144.1;
option routers 192.168.144.1;
########################################
# Dynamic IP addresses
########################################
range 192.168.145.1 192.168.149.254;
########################################
# Fixed IP machines that humans don&amp;#39;t
# (normally) see - WAPs etc.
########################################
host wap {
hardware ethernet dc:9f:44:11:22:33;
fixed-address 192.168.144.13;
}
########################################
# Fixed IP machines that humans see.
########################################
# These are machines I normally ssh
# or telnet to, or run servers on.
#
host fileserver {
hardware ethernet 22:33:44:55:66:77;
fixed-address 192.168.150.171;
option host-name &amp;#34;fileserver&amp;#34;;
}
host weather {
hardware ethernet 88:99:00:AA:BB:CC;
fixed-address 192.168.150.177;
option host-name &amp;#34;weather&amp;#34;;
}
#... etc...
# I&amp;#39;m putting my laptop on a non-150 address for testing purposes.
# That way I can plug it into the server and get a DHCP address that
# should route on to the internet.
host laptop {
hardware ethernet 00:22:44:66:88:ff;
fixed-address 192.168.161.2;
}
} # subnet&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Next, start serving DHCP:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;rcctl enable dhcpd
rcctl start dhcpd&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;At this point I could plug my laptop into the new firewall and get an IP address.&lt;/p&gt;
&lt;h2 class="relative group"&gt;Start Unbound for DNS
&lt;div id="start-unbound-for-dns" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#start-unbound-for-dns" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;On my old firewall I was using bind. That was heavyweight, so I decided to do something different here. Originally I thought I needed NSD and Unbound for DNS (I was looking at some instructions at &lt;a href="https://jamsek.dev/blog/2019/Jul/28/openbsd-dns-server-with-unbound-and-nsd/" target="_blank" rel="noreferrer"&gt;jamsek.dev/blog/2019/Jul/28/openbsd-dns-server-with-unbound-and-nsd/&lt;/a&gt;) but eventually realized I could get away with just unbound.&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# rcctl enable unbound
# rcctl start unbound&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Next, I changed my DNS server so the new firewall was getting it locally instead of going to the old firewall. In /etc/resolv.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;nameserver 127.0.0.1
lookup file bind&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;After that, configure DNSSEC:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# unbound-anchor -a &amp;#34;/var/unbound/db/root.key&amp;#34;
# ftp -S do -o /var/unbound/db/root.hints https://www.internic.net/domain/named.root&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;With root.key downloaded, I could set up my /var/unbound/etc/unbound.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# $OpenBSD: unbound.conf,v 1.21 2020/10/28 11:35:58 sthen Exp $
server:
interface: 192.168.144.1
interface: ::1
# override the default &amp;#34;any&amp;#34; address to send queries; if multiple
# addresses are available, they are used randomly to counter spoofing
access-control: 0.0.0.0/0 refuse
access-control: ::0/0 refuse
access-control: 127.0.0.0/8 allow
access-control: 192.168.144.0/20 allow
access-control: ::1 allow
hide-identity: yes
hide-version: yes
# Perform DNSSEC validation.
#
auto-trust-anchor-file: &amp;#34;/var/unbound/db/root.key&amp;#34;
root-hints: &amp;#34;/var/unbound/db/root.hints&amp;#34;
qname-minimisation: yes
val-log-level: 2
# Synthesize NXDOMAINs from DNSSEC NSEC chains.
# https://tools.ietf.org/html/rfc8198
#
aggressive-nsec: yes
# Serve zones authoritatively from Unbound to resolver clients.
# Not for external service.
#
local-zone: &amp;#34;lan.example.net.&amp;#34; static
#
# Host addresses - infrastructure
#
local-data: &amp;#34;firewall.lan.example.net. IN A 192.168.144.1&amp;#34;
local-data-ptr: &amp;#34;192.168.144.1 firewall.lan.example.net&amp;#34;
#
# Host addresses - named servers
#
local-data: &amp;#34;fileserver.lan.example.net. IN A 192.168.150.171&amp;#34;
local-data-ptr: &amp;#34;192.168.150.171 fileserver.lan.example.net&amp;#34;
local-data: &amp;#34;weather.lan.example.net. IN A 192.168.150.177&amp;#34;
local-data-ptr: &amp;#34;192.168.150.177 weather.lan.example.net&amp;#34;
# ... etc...
remote-control:
control-enable: yes
control-interface: /var/run/unbound.sock&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;With all that set up, I could make sure I didn&amp;rsquo;t have any syntax errors and restart unbound:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# unbound-checkconf
# rcctl restart unbound&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;I think it was at this point that I made the switch from using the old firewall to the new firewall. I changed the new firewall to have the same MAC as the old one (my ISP wanted to see a specific MAC) and then put the new one in place:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# echo &amp;#34;inet autoconf lladdr 11:22:33:44:55:66&amp;#34; &amp;gt; /etc/hostname.igc0
# sh /etc/netstart&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Having two devices with the same MAC is a Bad Thing, and I had a lot of weirdness on my network until I unplugged the old firewall.&lt;/p&gt;
&lt;p&gt;This post is part of a series on &lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/" &gt;setting up an OpenBSD 7.4 firewall device&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Setting up an OpenBSD 7.4 Firewall Device</title><link>https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/</link><pubDate>Sun, 15 Oct 2023 23:59:39 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/</guid><description>&lt;p&gt;My &lt;a href="https://www.pcengines.ch/alix.htm" target="_blank" rel="noreferrer"&gt;PC Engines ALIX&lt;/a&gt; running the (mumble) version of OpenBSD has been a great firewall. But now that it looks like PC Engines is &lt;a href="https://www.pcengines.ch/eol.htm" target="_blank" rel="noreferrer"&gt;wrapping up&lt;/a&gt;, it&amp;rsquo;s time to find something new. For a while I&amp;rsquo;ve suspected that the ALIX is a little underpowered. It&amp;rsquo;s harder to find 4G CF cards these days. Plus I want something with a HDMI port so I can put it on a KVM switch and don&amp;rsquo;t need to worry about serial port speeds.&lt;/p&gt;
&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt="The OpenBSD Puffy logo"
width="300"
height="300"
src="https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/images/puffy-firewall-sticker.png"
srcset="https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/images/puffy-firewall-sticker.png 800w, https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/images/puffy-firewall-sticker.png 1280w"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/images/puffy-firewall-sticker.png"&gt;&lt;/figure&gt;
&lt;p&gt;So&amp;hellip; here&amp;rsquo;s the order of operations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-15-buying-new-hardware-for-an-openbsd-firewall/" &gt;Buy new hardware&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-15-installing-openbsd-7-3-for-a-firewall/" &gt;Get OpenBSD running on the new hardware&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-21-set-up-networking-for-an-openbsd-7-4-firewall-device/" &gt;Reorganize my network while it&amp;rsquo;s running&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-22-block-ad-sites-and-nasties-on-openbsd-7-4/" &gt;Block ad sites and nasties&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-22-setting-up-wireguard-on-an-openbsd-7-4-firewall-device/" &gt;Add a Wireguard VPN&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here goes!&lt;/p&gt;</description></item><item><title>Installing OpenBSD 7.4 for a Firewall</title><link>https://andrewmemory.acornwall.net/blog/2023-10-15-installing-openbsd-7-3-for-a-firewall/</link><pubDate>Sun, 15 Oct 2023 23:45:00 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2023-10-15-installing-openbsd-7-3-for-a-firewall/</guid><description>&lt;p&gt;Installing OpenBSD 7.4 was pretty simple. I followed the &lt;a href="https://www.openbsd.org/faq/faq4.html" target="_blank" rel="noreferrer"&gt;OpenBSD installation guide&lt;/a&gt; and used dd on a Linux box to write install74.img to a USB stick. Don&amp;rsquo;t use the .iso, it doesn&amp;rsquo;t boot. Then I booted off the USB stick. (You don&amp;rsquo;t have to disable UEFI.) I used a standard layout&lt;/p&gt;
&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt="A picture of Puffy, the OpenBSD puffer fish logo"
width="500"
height="500"
src="https://andrewmemory.acornwall.net/blog/2023-10-15-installing-openbsd-7-3-for-a-firewall/images/puffy-firewall-sticker-1.png"
srcset="https://andrewmemory.acornwall.net/blog/2023-10-15-installing-openbsd-7-3-for-a-firewall/images/puffy-firewall-sticker-1.png 800w, https://andrewmemory.acornwall.net/blog/2023-10-15-installing-openbsd-7-3-for-a-firewall/images/puffy-firewall-sticker-1.png 1280w"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="https://andrewmemory.acornwall.net/blog/2023-10-15-installing-openbsd-7-3-for-a-firewall/images/puffy-firewall-sticker-1.png"&gt;&lt;/figure&gt;
&lt;p&gt;At the time I wondered if I should install all the packages or not. I decided that maintenance would be simpler if I just went for everything, so I added all the packages including X. That turned out to be the right decision.&lt;/p&gt;
&lt;p&gt;I used a relatively standard partitioning scheme, although I think I bumped up a few of the sizes. I probably should have bumped up X11R6 more, right now it&amp;rsquo;s at 41%:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;/dev/sd0a 986M /
/dev/sd0l 295G /home
/dev/sd0d 291M /tmp
/dev/sd0f 5.8G /usr
/dev/sd0g 986M /usr/X11R6
/dev/sd0h 19.4G /usr/local
/dev/sd0k 5.8G /usr/obj
/dev/sd0j 2.9G /usr/src
/dev/sd0e 34.4G /var&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;h2 class="relative group"&gt;Set up doas
&lt;div id="set-up-doas" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#set-up-doas" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;After installing, I set up doas &amp;lsquo;cause I like seatbelts:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;$ su
# vi /etc/doas.conf
permit persist andrewmemory as root
permit persist keepenv root as root&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;h2 class="relative group"&gt;Install patches and packages
&lt;div id="install-patches-and-packages" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#install-patches-and-packages" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;After that I installed patches:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;$ doas syspatch
$ doas shutdown -r now&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Next I installed a few useful packages:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;$ doas pkg_add -i emacs mutt firefox wget &lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;I picked the -no_x11 version for emacs, and the normal (not gpge, not sasl, not slang) version for mutt. I&amp;rsquo;m not going to be mailing to the world from this box, just looking at local emails. I also installed Firefox, which turned out to be another good idea. It&amp;rsquo;s a lot easier to search for doc on the firewall box itself than to ssh in.&lt;/p&gt;
&lt;h2 class="relative group"&gt;Set up mfs for /tmp
&lt;div id="set-up-mfs-for-tmp" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#set-up-mfs-for-tmp" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;Finally, I&amp;rsquo;m paranoid about wearing out my SSD, so I set up /tmp to be mfs in /etc/fstab using the useful &lt;a href="https://dataswamp.org/~solene/2018-05-08-mfs-tmp.html" target="_blank" rel="noreferrer"&gt;instructions from Solene Rapenne&lt;/a&gt;:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;$ doas vi /etc/fstab
#f1ea06b71e2dca43.d /tmp ffs rw,nodev,nosuid 1 2
swap /tmp mfs rw,nodev,nosuid,-s=300m 0 0&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;&amp;hellip; and I had to boot to single-user mode to fix up permissions for /tmp:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;$ doas umount /tmp
$ doas chmod 1777 /tmp
$ doas mount /tmp&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Apparently &lt;a href="http://undeadly.org/cgi?action=article&amp;amp;sid=20160812011743" target="_blank" rel="noreferrer"&gt;tmpfs has been removed&lt;/a&gt; because it&amp;rsquo;s not supported, so mfs it is. I&amp;rsquo;ve got plenty of RAM for a /tmp file system, but I have delusions of putting most of /var in its own mfs file system, so I restricted /tmp to 300M.&lt;/p&gt;
&lt;p&gt;Once that was done, I could log into a few other machines on my network to establish fingerprints for them. I also tested X by running startx, and then firefox, and it worked.&lt;/p&gt;
&lt;h2 class="relative group"&gt;There were some noisy beeps
&lt;div id="there-were-some-noisy-beeps" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#there-were-some-noisy-beeps" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;By default, OpenBSD rings the bell when you mistype certain things. That was annoying other people in the house, so I had to shut those up. That took two things. In ~/.login I added:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;/sbin/wsconsctl keyboard.bell.volume=0&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Then, I created ~/.xsession and added:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;/usr/X11R6/bin/xset b off&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;This post is part of a series on &lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/" &gt;setting up an OpenBSD 7.4 firewall device&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Buying new hardware for an OpenBSD firewall</title><link>https://andrewmemory.acornwall.net/blog/2023-10-15-buying-new-hardware-for-an-openbsd-firewall/</link><pubDate>Sun, 15 Oct 2023 23:30:53 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2023-10-15-buying-new-hardware-for-an-openbsd-firewall/</guid><description>&lt;p&gt;I knew going in that I wanted more than two ethernet ports for my OpenBSD firewall device. I had visions of multiple networks and/or a spare port that I could use when I screwed up my pf configuration. I also knew that I wanted HDMI so I could pop the firewall on my KVM switch - I&amp;rsquo;d used serial to the APU2 and that was not always wonderful. The Linux box would sometimes forget about the serial ports when they were plugged in for a while.&lt;/p&gt;
&lt;p&gt;In the end, I got a random Intel N5105 mini-PC with four Intel ethernet ports. The &lt;a href="https://www.amazon.com/gp/product/B0B53MKZBX/" target="_blank" rel="noreferrer"&gt;HUNSN Micro Firewall Appliance, Mini PC, VPN, Router PC, Intel N5105, HUNSN RJ03, AES-NI, 4 x Intel 2.5GbE I226-V LAN, Type-C, TF, M.2 WiFi 6 Slot, Barebone, NO RAM, NO Storage, NO System&lt;/a&gt; was around $250 US. Add a Western Digital NVMe &lt;a href="https://www.amazon.com/gp/product/B09HKG6SDF/" target="_blank" rel="noreferrer"&gt;500G drive&lt;/a&gt; and 16G of &lt;a href="https://www.amazon.com/gp/product/B08C4WV6FT/" target="_blank" rel="noreferrer"&gt;Cruical laptop RAM&lt;/a&gt; and I had something on which I could install a system. It&amp;rsquo;s low-powered enough that I don&amp;rsquo;t mind keeping it running 24/7, and high-powered enough that I&amp;rsquo;m not worried about it being a bottleneck.&lt;/p&gt;
&lt;p&gt;[&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt="The HUNSN Micro Firewall Appliance from the front"
width="359"
height="211"
src="https://andrewmemory.acornwall.net/blog/2023-10-15-buying-new-hardware-for-an-openbsd-firewall/images/hunsn.png"
srcset="https://andrewmemory.acornwall.net/blog/2023-10-15-buying-new-hardware-for-an-openbsd-firewall/images/hunsn.png 800w, https://andrewmemory.acornwall.net/blog/2023-10-15-buying-new-hardware-for-an-openbsd-firewall/images/hunsn.png 1280w"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="https://andrewmemory.acornwall.net/blog/2023-10-15-buying-new-hardware-for-an-openbsd-firewall/images/hunsn.png"&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;I learned afterwards that the I226-V might &lt;a href="https://www.reddit.com/r/openbsd/comments/12g637u/experience_with_problematic_intel_i225_25_gbps/" target="_blank" rel="noreferrer"&gt;potentially have a problem&lt;/a&gt; if you want to do 2.5G ethernet. So far, I haven&amp;rsquo;t experienced any network instability because of that.&lt;/p&gt;
&lt;p&gt;As a belt-and-suspenders kind of thing, I bought a &amp;ldquo;silent&amp;rdquo; USB fan that sits on top of the case, just because the server room can get a little warm.&lt;/p&gt;
&lt;p&gt;This post is part of a series on &lt;a href="https://andrewmemory.acornwall.net/blog/2023-10-15-setting-up-an-openbsd-7-4-firewall-device/" &gt;setting up an OpenBSD 7.4 firewall device&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Tracking and blocking BRW70188B</title><link>https://andrewmemory.acornwall.net/blog/2017-01-02-tracking-and-blocking-brw70188b/</link><pubDate>Mon, 02 Jan 2017 03:00:00 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2017-01-02-tracking-and-blocking-brw70188b/</guid><description>&lt;p&gt;I&amp;rsquo;ve been monitoring wifi traffic on my network. I&amp;rsquo;ve seen a large amount sent up by one device, which was reported as starting with BR70188B (mac address 70:18:8b) with manufacturer HonHaiPr.&lt;/p&gt;
&lt;p&gt;HonHaiPr is Hon Hai Precision Industry, which makes network devices. The one in question (with the name BRW70188Bxxyyzz) was from a Brother MFC-650DW that is on the network.&lt;/p&gt;
&lt;p&gt;Now that I&amp;rsquo;ve identified the printer, what to do about it? It was spewing lots of uploaded data - perhaps just to the clients that printed from it, but I&amp;rsquo;m perhaps a little paranoid. (It seems strange that it&amp;rsquo;s uploading almost as much as gets downloaded to the printer, though.) So I decided to knock it off the Internet to see what happened.&lt;/p&gt;
&lt;p&gt;First, I gave it a static IP address in my dhcpd.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;host mfc650dw {
hardware ethernet 70:18:8B:xx:yy:zz;
fixed-address 192.168.1.253;
option host-name &amp;#34;mfc650dw&amp;#34;;
}&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Next, I updated it in DNS (db and db.rev files) just &amp;lsquo;cause now that it&amp;rsquo;s static it&amp;rsquo;s handy to have a name to deal with.&lt;/p&gt;
&lt;p&gt;Finally, I added a rule to my pf.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;block out log quick from 192.168.1.253/32 to ! 192.168.1/24&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Now if the printer&amp;rsquo;s trying to send data up to the Internet, it&amp;rsquo;s not going to make it through the firewall.&lt;/p&gt;
&lt;p&gt;After I did all this, the printer wouldn&amp;rsquo;t work - Brother apparently stores the IP address but doesn&amp;rsquo;t refresh if it can&amp;rsquo;t find it. So I needed to download the &lt;a href="https://help.brother-usa.com/app/answers/detail/a_id/55914/~/download-the-network-connection-repair-tool---windows" target="_blank" rel="noreferrer"&gt;Brother Network Connection Repair Tool&lt;/a&gt; to tell the Windows printer driver to look for the printer again. Sheesh.&lt;/p&gt;</description></item><item><title>Setting up a static IP for a Raspberry Pi over wifi using OpenBSD dhcpd</title><link>https://andrewmemory.acornwall.net/blog/2015-05-01-setting-up-a-static-ip-for-a-raspberry-pi-over-wifi-using-openbsd-dhcpd/</link><pubDate>Fri, 01 May 2015 00:54:05 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2015-05-01-setting-up-a-static-ip-for-a-raspberry-pi-over-wifi-using-openbsd-dhcpd/</guid><description>&lt;p&gt;Like the rest of the world, I wanted to have a static IP for a Raspberry Pi that was on a wifi network. Like the rest of the world, I couldn&amp;rsquo;t figure out how to do it after three attempts. At that point, like the rest of the world I gave up and decided to make my DHCP server do the work instead of the Pi.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s how I did it:&lt;/p&gt;
&lt;p&gt;1. On the Pi, edit /etc/wpa_supplicant.conf and add:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;network={
    ssid=&amp;#34;My_SSID&amp;#34;
    psk=&amp;#34;My_wifi_password&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;2. Reboot and get an IP address through DHCP.&lt;/p&gt;
&lt;p&gt;3. Confirm that I can see the world with the DHCP address.&lt;/p&gt;
&lt;p&gt;4. ifconfig wlan0 and copy down the hardware Ethernet address for wlan0 (let&amp;rsquo;s pretend it was 00:11:22:33:44:56).&lt;/p&gt;
&lt;p&gt;5. Go to the box running DHCP, and add a stanza inside my shared-network:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;       host myserver {
               hardware ethernet 00:11:22:33:44:56;
               fixed-address 192.168.1.17;
               option host-name &amp;#34;myserver&amp;#34;;
       }&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;6. Kill and restart the DHCP daemon.&lt;/p&gt;
&lt;p&gt;7. Reboot the pi and confirm it&amp;rsquo;s getting the right static IP address now.&lt;/p&gt;</description></item><item><title>Changing MAC address on OpenBSD</title><link>https://andrewmemory.acornwall.net/blog/2012-12-06-changing-mac-address-on-openbsd/</link><pubDate>Thu, 06 Dec 2012 00:49:03 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2012-12-06-changing-mac-address-on-openbsd/</guid><description>&lt;p&gt;A little while ago, I needed to change my MAC address on the OpenBSD firewall I&amp;rsquo;ve got running. (My ISP kept feeding me a bad IP address from an old lease and I wanted a new one.)&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s easy to do this on OpenBSD:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ifconfig vr1 down ifconfig vr1 lladdr 00:11:22:33:44:55 ifconfig vr1 up&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The question is, where&amp;rsquo;s the right place to put this to make it permanent? A few web searches revealed that a bunch of people had modified /etc/netstart by putting the ifconfig vr1 lladdr line somewhere near the beginning. I&amp;rsquo;d rather not sully my pristine /etc scripts with changes if I don&amp;rsquo;t have to.&lt;/p&gt;
&lt;p&gt;Linux has /etc/network/interfaces, and OpenBSD has /etc/hostname.if. I just changed my /etc/hostname.vr1 to:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;dhcp lladdr 00:11:22:33:44:55&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;and I was requesting an IP address using my new MAC address.&lt;/p&gt;</description></item><item><title>Final cleanup for the ALIX firewall</title><link>https://andrewmemory.acornwall.net/blog/2012-07-06-final-cleanup-for-the-alix-firewall/</link><pubDate>Fri, 06 Jul 2012 22:38:45 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2012-07-06-final-cleanup-for-the-alix-firewall/</guid><description>&lt;p&gt;Finally, there are a few things that I either forgot to do or that make life easier.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Setting up localtime&lt;/strong&gt; By defaut, /etc/localtime is set to Alberta, where OpenBSD has its home. I need to set it to somewhere closer.&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;rm /etc/localtime; ln -s /usr/share/zoneinfo/US/Mountain /etc/localtime&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Now date shows the correct time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Blinkenlights&lt;/strong&gt; I wrote a script to make the LEDs move back and forth. I start this at boot. (In an earlier version of the firewall, I edited /etc/rc to turn LEDs on when certain thresholds had been passed in the boot process. But now I don&amp;rsquo;t want to muck up /etc/rc so much.)&lt;/p&gt;
&lt;p&gt;First of all, you need to allow the ports to be written before OpenBSD gets all secure on you. Edit /etc/rc.securelevel and add:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;#
# Place local actions here.
#
echo -n &amp;#39;enabling LED pins&amp;#39;
gpioctl -q /dev/gpio0 6 set out iout
gpioctl -q /dev/gpio0 25 set out iout
gpioctl -q /dev/gpio0 27 set out iout&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;I got these numbers from the Status LEDs section of the &lt;a href="http://www.pcengines.ch/pdf/alix2.pdf" target="_blank" rel="noreferrer"&gt;ALIX manual&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then create /usr/local/bin/cylon:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;#!/bin/ksh -
led3on(){
gpioctl -q /dev/gpio0 6 0
gpioctl -q /dev/gpio0 25 0
gpioctl -q /dev/gpio0 27 1
}
led2on(){
gpioctl -q /dev/gpio0 6 0
gpioctl -q /dev/gpio0 25 1
gpioctl -q /dev/gpio0 27 0
}
led1on(){
gpioctl -q /dev/gpio0 6 1
gpioctl -q /dev/gpio0 25 0
gpioctl -q /dev/gpio0 27 0
}
ledsoff(){
gpioctl -q /dev/gpio0 6 0
gpioctl -q /dev/gpio0 25 0
gpioctl -q /dev/gpio0 27 0
}
while [ true ] ; do
led1on
sleep 1
led2on
sleep 1
led3on
sleep 1
led2on
sleep 1
done&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Finally, start it from /etc/rc.local:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# Add your local startup actions here.
echo -n &amp;#39;cylon&amp;#39;
sh /usr/local/bin/cylon &amp;amp;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;On reboot, yay, blinky! That at least tells you the kernel hasn&amp;rsquo;t crashed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reducing the mail&lt;/strong&gt; Because flashrd is really OpenBSD, it sends mail more suited to a server than a firewall with limited disk.&lt;/p&gt;
&lt;p&gt;First thing I noticed:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;Running security(8):
Checking special files and directories.
Output format is:
filename:
criteria (shouldbe, reallyis)
etc/rc.conf.local:
permissions (0644, 0755)&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;I fixed that with a chmod 0644 /etc/rc.conf.local. So now /usr/libexec/security shows no problems. Good.&lt;/p&gt;
&lt;p&gt;Once that&amp;rsquo;s done, make things complain less:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;crontab -uroot -e&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;and comment out:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;#30 1 * * * /bin/sh /etc/daily
#30 3 * * 6 /bin/sh /etc/weekly&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;This prevents the daily and weekly reports, leaving just the monthly one.&lt;/p&gt;
&lt;p&gt;Next, I noticed that sendmail gets run from root&amp;rsquo;s crontab, so it doesn&amp;rsquo;t need to run at boot:&lt;/p&gt;
&lt;p&gt;/etc/rc.conf:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;sendmail_flags=NO # &amp;#34;-L sm-mta -C/etc/mail/localhost.cf -bd -q30m&amp;#34;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;That should keep the thing running a little longer without running out of disk. Actually, /var/mail is on the MFS, so it will keep it from running out of ramdisk.&lt;/p&gt;
&lt;p&gt;(This post is part of &lt;a href="https://andrewmemory.acornwall.net/blog/2012-06-21-building-an-alix-firewall" &gt;Building an ALIX firewall&lt;/a&gt;)&lt;/p&gt;</description></item><item><title>Setting up BIND on the ALIX firewall</title><link>https://andrewmemory.acornwall.net/blog/2012-06-27-setting-up-bind-on-the-alix-firewall/</link><pubDate>Wed, 27 Jun 2012 23:23:07 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2012-06-27-setting-up-bind-on-the-alix-firewall/</guid><description>&lt;p&gt;Setting up BIND is probably the part that took more thought than any other when building the firewall. This is not because of any particular technical challenges; rather, BIND is managed by a consortium and its doc is&amp;hellip; &lt;a href="http://www.isc.org/files/Bv9.4ARM.pdf" target="_blank" rel="noreferrer"&gt;voluminous&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the end, I went with the default /var/named/etc/named.conf on the assumption that it would do the right thing. According to its comment, it does both &amp;ldquo;recursive and authoritative queries using one cache,&amp;rdquo; which is what I want.&lt;/p&gt;
&lt;p&gt;There are four files that need to change:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;/etc/rc.conf&lt;/li&gt;
&lt;li&gt;/var/named/etc/named.conf&lt;/li&gt;
&lt;li&gt;/var/named/master/mydomain.net&lt;/li&gt;
&lt;li&gt;/var/name/master/mydomain.net.rev&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The last two can be named anything, but I stuck with conventions as I saw them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt; Unlike everything up to now, the BIND files live on /var/. In flashrd, /var gets unpacked at boot time into a RAM disk. So you need to save any changes you make somewhere else. &lt;strong&gt;Do not reboot&lt;/strong&gt; until you&amp;rsquo;ve saved your changes! Ultimately, we&amp;rsquo;ll put these changes in /flash/var.tar so they get re-created when the device reboots.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/etc/rc.conf&lt;/strong&gt; To enable named, change: &lt;code&gt;named_flags=&amp;quot;&amp;quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/var/named/etc/named.conf&lt;/strong&gt; I used the default named.conf, which is really just a copy of named-simple.conf.&lt;/p&gt;
&lt;p&gt;I made one addition in the options section:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt; forwarders { 8.8.8.8; };&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;This tells DNS to look for answers at the Google DNS server if it can&amp;rsquo;t find the answer on the local DNS server. (Actually, I put a few DNS servers that were specific to my ISP, but the Google server will work too.)&lt;/p&gt;
&lt;p&gt;I also made a few changes near the end:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;// Master zones
//
zone &amp;#34;mydomain.net&amp;#34; {
type master;
file &amp;#34;master/mydomain.net&amp;#34;;
};
// Reverse mappings for mydomain.net domain
zone &amp;#34;150.168.192.in-addr.arpa&amp;#34; in {
type master;
file &amp;#34;master/mydomain.net.rev&amp;#34;;
};&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;This tells named to look in /var/named/master/mydomain.net for mappings of mydomain.net, and to look in /var/named/master/mydomain.net.rev for mappings of 192.168.150.*.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/var/named/master/mydomain.net&lt;/strong&gt; Here&amp;rsquo;s my mydomain.net:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;mydomain.net. IN SOA firewall.mydomain.net. myemail.yahoo.com. (
1 ; Serial
10800 ; Refresh after 3 hours
3600 ; Retry after 1 hour
604800 ; Expire after 1 week
86400 ) ; Minimum TTL of 1 day
;
; Name Servers
;
mydomain.net. IN NS firewall.mydomain.net.
;
; Host addresses
;
localhost.mydomain.net. IN A 127.0.0.1
firewall.mydomain.net. IN A 192.168.150.1
firesign.mydomain.net. IN A 192.168.150.170
frantics.mydomain.net. IN A 192.168.150.171
bundolo.mydomain.net. IN A 192.168.150.172&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;The first bit says my domain is called mydomain.net. I&amp;rsquo;ve published my email as &lt;a href="mailto:myemail@yahoo.com" &gt;myemail@yahoo.com&lt;/a&gt; (but note the dot instead of the at sign there).&lt;/p&gt;
&lt;p&gt;The next bit is serial number / expiration times. You&amp;rsquo;re supposed to bump up the serial number every time you edit, but I usually just kill and restart named.&lt;/p&gt;
&lt;p&gt;After that, I say that the firewall will be the nameserver for the domain.&lt;/p&gt;
&lt;p&gt;Next is the interesting bit: the mapping of host names to host addresses. They must all end in . because BIND requires it. It&amp;rsquo;s very easy to miss a . in your config file and be confused about why things aren&amp;rsquo;t working.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/var/name/master/mydomain.net.rev&lt;/strong&gt; In addition to DNS doing lookup for names, it usually also does lookup for IP addresses. This is what you get when you do nslookup 192.168.150.1, for instance. The reverse domain name file holds that:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;
150.168.192.in-addr.arpa. IN SOA firewall.mydomain.net. myemail.yahoo.com. (
1 ; Serial
10800 ; Refresh after 3 hours
3600 ; Retry after 1 hour
604800 ; Expire after 1 week
86400 ) ; Minimum TTL of 1 day
;
; Name Servers
;
150.168.192.in-addr.arpa. IN NS firewall.mydomain.net.
;
; Addresses point to canonical name
;
1.150.168.192.in-addr.arpa. IN PTR firewall.mydomain.net.
170.150.168.192.in-addr.arpa. IN PTR firesign.mydomain.net.
171.150.168.192.in-addr.arpa. IN PTR frantics.mydomain.net.
172.150.168.192.in-addr.arpa. IN PTR bundolo.mydomain.net.&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Once again, watch for . characters at the end of .arpa. and .net.&lt;/p&gt;
&lt;p&gt;At this point, you can kill and restart named, then: &lt;code&gt;nslookup server localhost frantics&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You should see something like:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;Server: localhost
Address: 127.0.0.1#53
Name: frantics.mydomain.net
Address: 192.168.150.171&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;/etc/resolv.conf.tail&lt;/strong&gt; The DHCP client overwrites /etc/resolv.conf, but then appends whatever/s in /etc/resolv.conf.tail to that. So let&amp;rsquo;s tell OpenBSD that Change /etc/resolv.conf to point to the running nameserver:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;nameserver 192.168.150.1
domain mydomain.net
search mydomain.net
lookup bind file&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;This sets up the firewall as the nameserver to look for, tells what my domain is, says to search foo.mydomain.net when looking for foo, and to look up via bind first and then /etc/hosts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/etc/dhcpd.conf&lt;/strong&gt; Now is a good time to change dhcpd.conf to point to your nameserver instead of someone else:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;option domain-name-servers 192.168.150.1;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Save those changes&lt;/strong&gt; To save the changes that are in /var, use the following command: &lt;code&gt;tar cf /flash/var.tar -C /var .&lt;/code&gt; Might as well save a copy somewhere else too: &lt;code&gt;tar cf /root/named.tar /var/named&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Things are saved away as well as they&amp;rsquo;re going to be; time to reboot and hope you didn&amp;rsquo;t miss anything!&lt;/p&gt;
&lt;p&gt;(This post is part of &lt;a href="https://andrewmemory.acornwall.net/blog/2012-06-21-building-an-alix-firewall" &gt;Building an ALIX firewall&lt;/a&gt;)&lt;/p&gt;</description></item><item><title>Setting up PF for the ALIX firewall</title><link>https://andrewmemory.acornwall.net/blog/2012-06-26-setting-up-pf-for-the-alix-firewall/</link><pubDate>Tue, 26 Jun 2012 23:09:49 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2012-06-26-setting-up-pf-for-the-alix-firewall/</guid><description>&lt;p&gt;The next step on the firewall is to set up the packet filter PF. Most of what I do here comes from the &lt;a href="http://www.openbsd.org/faq/pf/" target="_blank" rel="noreferrer"&gt;OpenBSD PF FAQ&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Setting up PF itself&lt;/strong&gt; The file to edit is /etc/pf.conf. Here&amp;rsquo;s mine:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# macros
int_if=&amp;#34;vr0&amp;#34;
ext_if=&amp;#34;vr1&amp;#34;
# FTP Proxy rules
anchor &amp;#34;ftp-proxy/*&amp;#34;
pass in quick on $int_if inet proto tcp to any port ftp \
divert-to 127.0.0.1 port 8021
# options
set block-policy return
set loginterface $ext_if
set skip on lo
# match rules
match out on egress inet from !(egress) to any nat-to (egress:0)
# filter rules
block in log
pass out quick
antispoof quick for { lo $int_if }
# uncomment this to respond to pings
# pass in inet proto icmp all icmp-type echoreq
pass in on $int_if&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;It&amp;rsquo;s basically the example config file for home or small office, with a couple of changes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I define an int_if and ext_if for internal network and external network&lt;/li&gt;
&lt;li&gt;I don&amp;rsquo;t have any port forwarding from outside through to the inside network except ftp-proxy&lt;/li&gt;
&lt;li&gt;I block all incoming ICMP traffic (which is broken according to spec, but might keep me safer from denial of service attacks).&lt;/li&gt;
&lt;li&gt;I keep port 22 closed on the firewall machine.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Basically, I present a blank wall to the Internet. Traffic I initiate can get out, but outside doesn&amp;rsquo;t get in except via ftp-proxy.&lt;/p&gt;
&lt;p&gt;One thing to note is that if you mess up pf, you can get into a state where you can&amp;rsquo;t talk to your ALIX over the network. So make sure you have a serial port handy to talk to it. I&amp;rsquo;d recommend making changes to pf.conf over serial, and then testing with the network.&lt;/p&gt;
&lt;p&gt;To test, run:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;pfctl -F all
pfctl -f /etc/pf.conf&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;The first command flushes whatever existing PF config is there; the second command loads your new pf config.&lt;/p&gt;
&lt;p&gt;Next, hook up a machine to the switch that&amp;rsquo;s connected to the LAN side of the firewall, and see if you have Internet. If you do, life is good!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Getting FTP running&lt;/strong&gt; You might have noticed I use ftp-proxy in my pf.conf. That&amp;rsquo;s a daemon that needs to be enabled in /etc/rc.conf: &lt;code&gt;ftpproxy_flags=&amp;quot;&amp;quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;According to the &lt;a href="http://www.openbsd.org/faq/pf/ftp.html#client" target="_blank" rel="noreferrer"&gt;PF FAQ&lt;/a&gt;, you can run ftp-proxy to get the daemon going, but I rebooted instead after changing /etc/rc.conf. Also according to the FAQ, some (fussy) clients may need &amp;ldquo;-r&amp;rdquo; on ftpproxy_flags.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Blocking IP addresses using PF&lt;/strong&gt; I haven&amp;rsquo;t done this before, but I wanted to try blocking ad servers by IP address using PF. Some instructions are &lt;a href="http://www.cyberciti.biz/faq/opebsd-pf-firewall-block-subnets-ip-address/" target="_blank" rel="noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;My list of IP addresses came from the excellent &lt;a href="http://pgl.yoyo.org/adservers/" target="_blank" rel="noreferrer"&gt;pgl.yoyo.org/adservers&lt;/a&gt; site. I picked &amp;ldquo;list ad server IP addresses&amp;rdquo; as plain HTML text, checked the &amp;ldquo;view list as plain text&amp;rdquo; button, and pressed &amp;ldquo;go&amp;rdquo;. This gave me a URL that I copied.&lt;/p&gt;
&lt;p&gt;I wanted a semi-automatic way to download this list. Luckily, OpenBSD&amp;rsquo;s ftp is a lot more than plain FTP. You can use it instead of wget/curl/etc. Here&amp;rsquo;s the command I used:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;ftp -o /etc/pf.blocked.ip.conf &amp;#34;http://pgl.yoyo.org\
/adservers/iplist.php?ipformat=plain&amp;amp;;showintro=1&amp;amp;\
mimetype=plaintext&amp;#34;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;Then I updated my pf.conf to account for that:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;# macros
int_if=&amp;#34;vr0&amp;#34;
ext_if=&amp;#34;vr1&amp;#34;
# Table of IP addresses to block
table &amp;lt;blockedips&amp;gt; persist file &amp;#34;/etc/pf.blocked.ip.conf&amp;#34;
# FTP Proxy rules
anchor &amp;#34;ftp-proxy/*&amp;#34;
pass in quick on $int_if inet proto tcp to any port ftp \
divert-to 127.0.0.1 port 8021
# options
set block-policy return
set loginterface $ext_if
set skip on lo
# match rules
match out on egress inet from !(egress) to any nat-to (egress:0)
# filter rules
# These two rules block traffic from blacklisted IP addresses
block drop in quick on $ext_if from &amp;lt;blockedips&amp;gt; to any
block return out quick from any to &amp;lt;blockedips&amp;gt;
block in log
pass out quick
antispoof quick for { lo $int_if }
# pass in inet proto icmp all icmp-type $icmp_types
pass in on $int_if&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;I&amp;rsquo;m not sure if this strategy will work long term. Previously I excluded ad servers in named instead. Excluding by IP address seems to take less RAM (I&amp;rsquo;ve got about 163M free of my 256M RAM with this table loaded) and has the advantage of blocking sneaky servers that use IP address URLs. The downside is that if another server uses the same IP address, I won&amp;rsquo;t get the content, and I have no real way to unblock by name if I need to.&lt;/p&gt;
&lt;p&gt;At any rate, to update, I just need to do the ftp command again, and then: &lt;code&gt;pfctl -t blockedips -T replace -f /etc/pf.blocked.ip.conf&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;(This post is part of &lt;a href="https://andrewmemory.acornwall.net/blog/2012-06-21-building-an-alix-firewall" &gt;Building an ALIX firewall&lt;/a&gt;)&lt;/p&gt;</description></item><item><title>Getting OpenBSD 5.1 on the ALIX firewall</title><link>https://andrewmemory.acornwall.net/blog/2012-06-20-getting-openbsd-5-1-on-the-alix-firewall/</link><pubDate>Wed, 20 Jun 2012 23:11:44 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2012-06-20-getting-openbsd-5-1-on-the-alix-firewall/</guid><description>&lt;p&gt;Getting OpenBSD on the ALIX used to be quite an effort. You had to figure out what your CF card looked like, enter the right drive parameters, and hope. Now it&amp;rsquo;s dead easy:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Download the &lt;a href="http://www.nmedia.net/flashrd/images/" target="_blank" rel="noreferrer"&gt;flashrd binary image&lt;/a&gt;. I used flashimg.i386.wd0.com0-20120531.gz, which is root wd0, com0 38400 console. This matches the Alix BIOS default, which also spits out 38400 serial.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Unzip the image with gzip -d&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write the image to the CF card. I have Cygwin installed, so I was able to use dd. Since I&amp;rsquo;m running this on Windows 7, I had to open my Cygwin shell as Administrator. The command I used:&lt;/p&gt;
&lt;figure class="highlight"&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-" data-lang=""&gt;dd if=flashdist.i386.wd0.com0-20120531 of=/dev/sdd bs=128k&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;
&lt;p&gt;I was pleasantly surprised that dd worked. (I found the device by doing sfdisk -l /dev/sda, then sdb, then sdc, until I found a partition table that looked like my 4 GB flash drive.) I picked 128k as the block size because the image was evenly divisible by that. I don&amp;rsquo;t know if it makes a difference, but I figured why risk it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next I hooked up a DB9 F/F mini null modem to my PC serial port, connected that to the Alix serial port, ran hypertrm (which I had to get from an earlier Windows release) and was talking to OpenBSD. Root password was &amp;ldquo;root&amp;rdquo; (no quotes).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;At this point I reset the password: &lt;code&gt;rw passwd root ro&lt;/code&gt; rw is the flashrd way to say &amp;ldquo;mount the file system read/write&amp;rdquo;, and ro says &amp;ldquo;mount the file system read-only&amp;rdquo;. flashrd boots up read-only (which saves wear on the flash card) so you need to set it to read/write if you want to do pretty much anything.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That&amp;rsquo;s all there is to it!&lt;/p&gt;
&lt;p&gt;(This post is part of &lt;a href="https://andrewmemory.acornwall.net/blog/2012-06-20-building-an-alix-firewall/" &gt;Building an ALIX firewall&lt;/a&gt;)&lt;/p&gt;</description></item><item><title>Building an ALIX firewall</title><link>https://andrewmemory.acornwall.net/blog/2012-06-20-building-an-alix-firewall/</link><pubDate>Wed, 20 Jun 2012 23:02:03 -0700</pubDate><author>andrewmemoryblog@gmail.com (Andrew's Memory Blog)</author><guid>https://andrewmemory.acornwall.net/blog/2012-06-20-building-an-alix-firewall/</guid><description>&lt;p&gt;It&amp;rsquo;s been a long time since I updated my firewall. Right now it&amp;rsquo;s a &lt;a href="http://www.pcengines.ch/alix2c2.htm" target="_blank" rel="noreferrer"&gt;PC Engines ALIX 2c2&lt;/a&gt; that I&amp;rsquo;ve been really happy with. I used &lt;a href="http://www.nmedia.net/flashdist/" target="_blank" rel="noreferrer"&gt;flashdist&lt;/a&gt; and put &lt;a href="http://openbsd.org/44.html" target="_blank" rel="noreferrer"&gt;OpenBSD 4.4&lt;/a&gt; on it.&lt;/p&gt;
&lt;p&gt;I think that&amp;rsquo;s a winning combination, but it&amp;rsquo;s time to upgrade. First, I want to go to &lt;a href="http://openbsd.org/51.html" target="_blank" rel="noreferrer"&gt;OpenBSD 5.1&lt;/a&gt;. Next, flashdist has been replaced with &lt;a href="http://www.nmedia.net/flashrd/" target="_blank" rel="noreferrer"&gt;flashrd&lt;/a&gt;, which is easier to install and use, and more appropriate for larger CF cards.&lt;/p&gt;
&lt;p&gt;I started by getting an &lt;a href="http://www.pcengines.ch/alix2d2.htm" target="_blank" rel="noreferrer"&gt;ALIX 2d2&lt;/a&gt; (just one more IDE header than the 2c2, not much change). I bought it from &lt;a href="http://www.mini-box.com/s.nl/sc.8/category.19/.f" target="_blank" rel="noreferrer"&gt;mini-box.com&lt;/a&gt;, and I also picked up the custom enclosure for it and a power supply.&lt;/p&gt;
&lt;p&gt;I already had a 4 GB CF card: a Kingston 4GB elite pro 133X, which was new when I built the original firewall. Make sure you have a good CF writer. I&amp;rsquo;ve had failures with cheapies, but got a Kingston FCR-HS219/1 and that worked.&lt;/p&gt;
&lt;p&gt;There are a number of steps to get a working firewall. They are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2012-06-20-getting-openbsd-5-1-on-the-alix-firewall/" &gt;Getting OpenBSD 5.1 on the ALIX&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2012-06-25-setting-up-networking-for-the-alix-firewall" &gt;Setting up networking for the ALIX firewall&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2012-06-27-setting-up-pf-for-the-alix-firewall" &gt;Setting up PF for the ALIX firewall&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2012-06-28-setting-up-bind-on-the-alix-firewall" &gt;Setting up BIND on the ALIX firewall&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://andrewmemory.acornwall.net/blog/2012-07-07-final-cleanup-for-the-alix-firewall" &gt;Final cleanup for the ALIX firewall&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;</description></item></channel></rss>