<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Vpn on 0x2142 | Networking Nonsense</title>
    <link>https://0x2142.com/tags/vpn/</link>
    <description>Recent content in Vpn on 0x2142 | Networking Nonsense</description>
    <image>
      <title>0x2142 | Networking Nonsense</title>
      <url>https://0x2142.com/logo.jpg</url>
      <link>https://0x2142.com/logo.jpg</link>
    </image>
    <generator>Hugo -- 0.143.1</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 29 Aug 2023 15:01:15 +0000</lastBuildDate>
    <atom:link href="https://0x2142.com/tags/vpn/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>[How To] Protect Your Home Network with Mullvad VPN &amp; OPNsense</title>
      <link>https://0x2142.com/how-to-protect-your-home-network-with-mullvad-vpn-opnsense/</link>
      <pubDate>Tue, 29 Aug 2023 15:01:15 +0000</pubDate>
      <guid>https://0x2142.com/how-to-protect-your-home-network-with-mullvad-vpn-opnsense/</guid>
      <description>In this post, we&amp;rsquo;ll walk through how to connect an OPNsense firewall to Mullvad&amp;rsquo;s VPN service. This covers both a full tunnel &amp;amp; partial tunnel configuration.</description>
      <content:encoded><![CDATA[<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/9B4FW5pf2wA?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<p>In this post, we&rsquo;ll walk through how to connect an OPNsense firewall to Mullvad&rsquo;s wireguard VPN. This can be used in various deployments to help protect your home network traffic.</p>
<p>As a quick note, this post is not sponsored by <a href="https://mullvad.net/">Mullvad</a> - I just happen to really like their service &amp; appreciate their approach to privacy and security. In fact, they currently don&rsquo;t offer any incentives or paid promotions of their product. More info on their current policy can be found <a href="https://mullvad.net/en/help/policy-reviews-advertising-and-affiliates/">here</a>.</p>
<h1 id="creating-an-account">Creating an Account</h1>
<p>Mullvad is unique in that they don&rsquo;t really require any sign up to get started with their service. Instead, when you sign up for new service, they randomly generate an account number. That&rsquo;s it. They don&rsquo;t require any additional information from you.</p>
<p>So first we can hit their new account page <a href="https://mullvad.net/en/account/create">here</a> - then click to generate a new account number.</p>
<p><img alt="create-account" loading="lazy" src="/content/images/2023/07/create-account.png#center"></p>
<blockquote>
<p>Keep this account number somewhere safe. Mullvad has <a href="https://mullvad.net/en/account/recover/">very limited</a> ability to help you recover the account number.</p></blockquote>
<p>Once we have that, we can click the button to <strong>Add time</strong> to our account.</p>
<p>Mullvad doesn&rsquo;t support any recurring subscriptions, so that they are able to keep less data about their customers. Instead, we just add time increments in months for how long we would like to use the service. This can be anywhere from a single month up to a year.</p>
<p>In terms of payments, they do offer a number of options, including the usual PayPal/credit cards - or if you&rsquo;re truly concerned about privacy, they accept a few cryptocurrencies or you can actually mail them a cash payment as well.</p>
<p>After a payment has been made &amp; time added to the account, we can quickly jump into the configuration side of things.</p>
<h1 id="config-mullvad-side">Config: Mullvad Side</h1>
<p>First we&rsquo;ll take a quick look at the configuration required on the Mullvad VPN side of things.</p>
<p>On the left side of the account page, we&rsquo;ll click on <strong>WireGuard Configuration</strong>.</p>
<p>First we&rsquo;ll select <strong>Linux</strong> as our platform (In this context, what is selected here isn&rsquo;t really important) - and then click the button to generate WireGuard keys:</p>
<p><img alt="generate-keys" loading="lazy" src="/content/images/2023/07/generate-keys.png#center"></p>
<blockquote>
<p>Note: Alternatively, we could have generated our WireGuard keys on our OPNsense firewall - then applied them here. It&rsquo;s up to you on which method you prefer!</p></blockquote>
<p>Next, we&rsquo;ll take a look at which server(s) we would like to connect to.</p>
<p><img alt="select-server" loading="lazy" src="/content/images/2023/07/select-server.png#center"></p>
<p>When selecting a server, we have the option to pick our desired country &amp; location - as well as picking a specific server to connect to if we choose. There is also an option to select all servers - in which case the config generator will create a WireGuard configuration file for each server.</p>
<p>For the purpose of this walk through, we&rsquo;ll keep things simple &amp; only select a single server. So in the screenshot above, I&rsquo;ve selected <code>us-qas-wg-004</code>.</p>
<p>We&rsquo;ll also take a quick look at the advanced options, which give us a little flexibility if we need it. For most people, these additional options will not be necessary to change or modify.</p>
<p>We can enable <strong>Multihop</strong> functionality, so long as we only selected a single server to connect to. So if you selected the <strong>All Servers</strong> option, this won&rsquo;t be available. This allows us to specify an entry &amp; exit server for our VPN. In other words, our device would directly connect to the entry server we select - then Mullvad would tunnel our traffic across their network to the exit server, where our traffic would be decrypted &amp; forwarded out to the internet. Depending on your privacy &amp; security desires, this is a really nice option to have the ability to enable.</p>
<p>Next, we have options on what type of connection we would like &amp; which traffic to forward.</p>
<p><strong>Server connection protocol</strong> will specify whether we are using IPv4 or IPv6 between our device &amp; our VPN server. Most likely you&rsquo;ll want to leave this at IPv4, unless you have an IPv6-only internet connection (or if you just would prefer to use IPv6 anyways!).</p>
<p><strong>Tunnel traffic</strong> is how we can specify whether we would like IPv4 or IPv6 <em>client-side</em> traffic to be forwarded over the VPN. So this would depend on whether the clients on our network have IPv4 vs IPv6 connectivity, or both - and whether we prefer to only forward certain types of traffic over the VPN. I&rsquo;ll be leaving this setting as the default: <strong>Both.</strong></p>
<p>Next we can specify a custom port if we would like. By default, wireguard will use UDP port 51820 - and we probably won&rsquo;t need to change this unless the port is being blocked upstream.</p>
<p>Lastly, we also have the option to enable content blocking across the VPN. Mullvad accomplishes content filtering through DNS-level blocking - and when we finish generating a configuration file, the file will include DNS servers to use. This is okay to use if you were connecting a single client to their VPN service. However, if you&rsquo;re using a router or device like OPNsense, you would need to update the DNS on all clients on your network to make this work. This is possible by updating DHCP on our router with the new DNS server address - or configuring a DNS rewrite. We won&rsquo;t get into either of those in this post - so for now I will leave the content blocking options unchecked.</p>
<p>Once we&rsquo;re good with our configuration - we can click the <strong>Download File</strong> button. We&rsquo;ll get a standard WireGuard config file, that looks like this:</p>
<p><img alt="wireguard-config" loading="lazy" src="/content/images/2023/07/wireguard-config.png#center"></p>
<p>At this point, we&rsquo;re good to move onto the next part!</p>
<h1 id="config-opnsense-side">Config: OPNsense Side</h1>
<p>Okay, so now that we have everything ready to go on the Mullvad side - we can configure our OPNsense device.</p>
<p>Make sure you already have WireGuard installed on OPNsense. This can be done by navigating to <strong>System &gt; Firmware &gt; Plugins</strong> then searching for <strong>wireguard</strong> &amp; clicking the install button.</p>
<p>Next, we&rsquo;ll enable Wireguard by navigating to <strong>VPN &gt; Wireguard</strong> and checking the box to <strong>Enable WireGuard</strong>, then <strong>Apply</strong>.</p>
<p><img alt="enable-wireguard" loading="lazy" src="/content/images/2023/07/enable-wireguard.png#center"></p>
<p>Then we&rsquo;ll hop over to the <strong>Endpoints</strong> tab &amp; configure our Mullvad VPN peer.</p>
<p>For this part of the configuration, we&rsquo;ll just copy our public key, allowed IPs, endpoint address, and endpoint port from our Mullvad config file. In the screenshot below, I also named my endpoint with the specific Mullvad server I&rsquo;ll be connecting to:</p>
<p><img alt="mullvad-peer-config-1" loading="lazy" src="/content/images/2023/07/mullvad-peer-config-1.png#center"></p>
<p>Then we can click <strong>Save</strong> and <strong>Apply.</strong></p>
<blockquote>
<p>If you wanted multiple Mullvad servers configured, just create a new endpoint for each one. Then, make sure that you select all of the Mullvad peers on the next step below.</p></blockquote>
<p>After that, we can move over to the <strong>Local</strong> tab to define our OPNsense tunnel configuration.</p>
<p>Click the button to add a new peer, then we&rsquo;ll fill in our private key and tunnel address(es) from the Mullvad config file. Under <strong>Peers</strong>, we&rsquo;ll also select our Mullvad VPN peer that we configured just a moment ago:</p>
<p><img alt="opnsense-local-1" loading="lazy" src="/content/images/2023/07/opnsense-local-1.png#center"></p>
<blockquote>
<p>UPDATE: Looks like with a recent OPNsense update, they now require you to enter both the WireGuard private &amp; public key into the local config (shown above). In the the screenshot, I only show entering the private key - since this was all that was required at the time.
Two ways to get your public key:</p>
<ol>
<li>Log into Mullvad &amp; check the &ldquo;Devices&rdquo; tab under &ldquo;Account Management&rdquo;. This will show your device public key (They don&rsquo;t keep your private key after generating it for you, only the public).</li>
<li>If you have wireguard installed somewhere else, you can use the &ldquo;wg pubkey&rdquo; command to derive a public key from your private key. Command: <code>echo &lt;private_key&gt; | wg pubkey</code></li>
</ol></blockquote>
<blockquote>
<p>Note: By default with the configuration we&rsquo;ve applied so far, this VPN will forward ALL traffic on our network to Mullvad. If we would prefer to selectively choose which traffic to send over the VPN, we can check the box for <strong>Disable Routes</strong> - then use policy routing to forward specific things to Mullvad.
We&rsquo;ll take a look at how to do this later in the post - but for now just be aware that our current configuration will forward ALL traffic.</p></blockquote>
<p>Okay, with that all done we can click <strong>Apply</strong> and <strong>Save</strong> here as well.</p>
<p>With any luck, we can check the <strong>Status</strong> tab &amp; see that there is data being transmitted &amp; successful WireGuard handshakes:</p>
<p><img alt="wg-status" loading="lazy" src="/content/images/2023/07/wg-status.png#center"></p>
<p>However, before our clients traffic can be forwarded over the VPN, we&rsquo;ll need to create a firewall rule to permit traffic &amp; a NAT rule to translate our client addresses to our Mullvad IP.</p>
<p>We&rsquo;ll navigate to <strong>Firewall &gt; Rules &gt; WireGuard (Group)</strong>. Then we&rsquo;ll click to create a new rule.</p>
<p>Within this new rule, I&rsquo;ll update <strong>Direction</strong> to <strong>Out</strong> and change <strong>TCP/IP Version</strong> to <strong>IPv4+IPv6</strong>. I&rsquo;ll leave the source as <strong>Any:</strong></p>
<p><img alt="wgrule1" loading="lazy" src="/content/images/2023/07/wgrule1.png#center"></p>
<p>We can also leave the <strong>Destination</strong> as <strong>Any</strong>, but I&rsquo;ll update the rule to enable logging:</p>
<p><img alt="wgrule2" loading="lazy" src="/content/images/2023/07/wgrule2.png#center"></p>
<p>This rule will allow any clients behind our OPNsense firewall to reach anything on the internet.</p>
<p>Next, we&rsquo;ll have to create a NAT rule. This ensures that our client addresses on our network get appropriately translated to the tunnel IP address that Mullvad has assigned us.</p>
<p>We&rsquo;ll navigate to <strong>Firewall &gt; NAT &gt; Outbound</strong>. By default, OPNsense will be set to <strong>Automatic outbound NAT rule generation</strong>. We&rsquo;ll need to update this to <strong>Hybrid outbound NAT rule generation</strong> to allow custom NAT rules. Then we can click <strong>Save</strong> and <strong>Apply</strong>.</p>
<p><img alt="nat-before" loading="lazy" src="/content/images/2023/07/nat-before.png#center"></p>
<p>Next, we&rsquo;ll create a new <strong>Manual NAT</strong> rule, where we&rsquo;ll update our <strong>Interface</strong> to <strong>WireGuard (Group):</strong></p>
<p><img alt="nat-rule1" loading="lazy" src="/content/images/2023/07/nat-rule1.png#center"></p>
<p>Then we&rsquo;ll make sure our <strong>Translation / target</strong> is set to <strong>Interface Address</strong> - and again, I&rsquo;ll enable logging:</p>
<p><img alt="nat-rule2" loading="lazy" src="/content/images/2023/07/nat-rule2.png#center"></p>
<p>After we click save, we should have a NAT rule that looks like this:</p>
<p><img alt="nat-after" loading="lazy" src="/content/images/2023/07/nat-after.png#center"></p>
<p>At this point, we should be good to test our clients!</p>
<h1 id="testing">Testing</h1>
<p>Of course, it&rsquo;s easy enough to use one of our clients to check that we still have internet access - but how can we be sure that they&rsquo;re using the VPN?</p>
<p>The easiest way might be to check the <a href="https://mullvad.net">mullvad.net</a>, where they do have a quick validation at the top of the page:</p>
<p><img alt="mullvad-test" loading="lazy" src="/content/images/2023/07/mullvad-test.png#center"></p>
<p>So according to Mullvad, it looks like we&rsquo;re connected &amp; they even show which server we&rsquo;re connecting from.</p>
<p>We can also double check using a traceroute or tracepath command:</p>
<p><img alt="tracepath" loading="lazy" src="/content/images/2023/07/tracepath.png#center"></p>
<p>In this case, we can see that our traffic to Google hits our OPNsense gateway, then the Mullvad VPN gateway followed by another external address owned by Mullvad.</p>
<p>So based on some quick testing, it looks like we&rsquo;re all good!</p>
<h1 id="policy-routing">Policy Routing</h1>
<p>So in the above walkthrough, we configured a Mullvad VPN from our OPNsense firewall - but it is forwarding ALL of our network clients over the VPN. What about if we only wanted certain clients to use the VPN? Or all clients to use it, but only for certain destinations?</p>
<p>We can accomplish this through policy routing.</p>
<p>So the first thing we&rsquo;ll do is go back to our WireGuard config, then under the <strong>Local</strong> tab. We&rsquo;ll edit our configuration here, and check the box for <strong>Disable Routes</strong>.</p>
<p><img alt="disable-routes" loading="lazy" src="/content/images/2023/07/disable-routes.png#center"></p>
<p>By default, OPNsense / WireGuard will install routes for any IPs listed in the <strong>AllowedIPs</strong> field for each peer. In our set up, we configured <strong>0.0.0.0/0</strong> - which matches all traffic. By checking the box for <strong>Disable Routes</strong>, we prevent OPNsense from installing that default route - and instead we can manually specify our own.</p>
<blockquote>
<p>If you&rsquo;re curious to double check this, you can try hitting Mullvad&rsquo;s website after changing this setting - and it should show that you&rsquo;re no longer connected.</p></blockquote>
<p>Then, we&rsquo;ll need to set up our WireGuard configuration to use a dedicated, named interface so that we can create a static gateway.</p>
<p>We&rsquo;ll head to <strong>Interfaces &gt; Assignments</strong> - and create a new interface. From the drop-down, we&rsquo;ll select our WireGuard interface - in my case this was <code>wg1</code>. Then we can assign it a name:</p>
<p><img alt="create-interface" loading="lazy" src="/content/images/2023/07/create-interface.png#center"></p>
<p>Then click the <strong>+</strong> icon to add, and <strong>Save.</strong></p>
<p>Then we can navigate to the interface name under the <strong>Interfaces</strong> menu - and enable the new interface:</p>
<p><img alt="enable-interface" loading="lazy" src="/content/images/2023/07/enable-interface.png#center"></p>
<p>Next we can create a gateway to route traffic through. Navigate to <strong>System &gt; Gateways &gt; Single</strong>.</p>
<p>Create a new gateway &amp; give it a name. Then we&rsquo;ll enter our Mullvad VPN gateway IP address, which in my case was <code>10.64.0.1</code>. How did we find this? Well earlier when we tested our VPN connectivity - we performed a tracepath. In the output of this tracepath, our second hop (the one right after our OPNsense firewall) would be the Mullvad VPN gateway. So this is the address we&rsquo;ll use for our gateway here:</p>
<p><img alt="mullvad-gateway" loading="lazy" src="/content/images/2023/07/mullvad-gateway.png#center"></p>
<p>Then clic <strong>Save</strong> and <strong>Apply</strong>.</p>
<blockquote>
<p>Note: You may get an error here, like &ldquo;The gateway address &ldquo;10.64.0.1&rdquo; does not lie within one of the chosen interface&rsquo;s IPv4 subnets.&rdquo;
To resolve this, we&rsquo;ll temporarily change our interface address. Navigate to the WireGuard local config, and re-enter your tunnel address excluding the &ldquo;/32&rdquo;. For example, if your tunnel IP was <code>10.10.10.10/32</code>, change this to just <code>10.10.10.10</code>
You should be able to set the gateway address now. Be sure to change your tunnel IP back afterwards!</p></blockquote>
<p>Next, we&rsquo;ll create a firewall rule for each set of sources or destinations we would like to manipulate.</p>
<p>So we can navigate to <strong>Firewall &gt; Rules &gt; Floating</strong> (or select a specific interface for clients, like LAN).</p>
<p>In here, we&rsquo;ll set whichever parameters we would like to match. So for this example, let&rsquo;s say I have a client PC at <code>10.100.100.10</code> and I only want traffic to <code>8.8.8.8</code> to use Mullvad. All other traffic can use the normal internet connection &amp; not use the VPN.</p>
<p>In that case, I&rsquo;ll set my source address to <code>10.100.100.10/32</code> and my destination to <code>8.8.8.8/32</code>:</p>
<p><img alt="policy-route1" loading="lazy" src="/content/images/2023/07/policy-route1.png#center"></p>
<p>Then all we need to do is update our <strong>Gateway</strong> to use the Mullvad gateway we just created:</p>
<p><img alt="policy-route2" loading="lazy" src="/content/images/2023/07/policy-route2.png#center"></p>
<p>Now, if we hop over to our client PC - Mullvad&rsquo;s website will say that we&rsquo;re not connected to the VPN. However, we can check that traffic to 8.8.8.8 is actually being sent through Mullvad using tracepath again:</p>
<p><img alt="split-routing" loading="lazy" src="/content/images/2023/07/split-routing.png#center"></p>
<p>In the screenshot above, I also included a tracepath to 8.8.4.4, just to show that it is going through my normal internet connection &amp; not Mullvad.</p>
<p>This was just one example, but you could easily create multiple firewall rules for different sources and/or destinations to control where traffic is sent. Aliases can also be used to group sources or destinations, so that multiple can be added to a single firewall rule.</p>
<hr>
<p>Okay - I think that&rsquo;s about all I wanted to cover in this post.</p>
<p>Hope it is helpful! Feel free to leave a comment below - or follow me on <a href="https://youtube.com/@0x2142">YouTube</a> 😊</p>
]]></content:encoded>
    </item>
    <item>
      <title>[How to] Set up Wireguard VPN on OPNsense</title>
      <link>https://0x2142.com/how-to-set-up-wireguard-on-opnsense/</link>
      <pubDate>Tue, 02 Aug 2022 14:50:51 +0000</pubDate>
      <guid>https://0x2142.com/how-to-set-up-wireguard-on-opnsense/</guid>
      <description>In this post, we&amp;rsquo;ll walk through a simple WireGuard remote-access VPN configuration on OPNsense - including client setup examples with Windows &amp;amp; Android.</description>
      <content:encoded><![CDATA[<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/b58PpuIsQ3A?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<p>So in my <a href="/opnsense-qotom-q750gs/">last post</a>, I picked up a Qotom Mini-PC to run OPNsense on. After a few months, the device has been running well &amp; I&rsquo;m very happy with it.</p>
<p>One of the new things I got to try out with OPNsense was Wireguard VPN. I had previously been using something else for VPN connectivity back to my home network - but I heard good things about Wireguard &amp; wanted to give it a try.</p>
<p>So far my experience has been good! I&rsquo;ve been pleasantly suprised with how easy it is to configure &amp; get running. In addition, the performance &amp; overall experience has been very positive. The VPN connects quicker than anything I&rsquo;ve used in the past, and just simply works without issue.</p>
<p>All that being said - I wanted to put together a quick guide on how to configure Wireguard on OPNsense. Specifically, this configuraion will be for remote-access VPN - where clients will connect to a VPN headend. We&rsquo;ll walk through the OPNsense configuration &amp; a few clients as well. So let&rsquo;s dig in!</p>
<hr>
<h2 id="topology">Topology</h2>
<p>For the purpose of this blog post, we&rsquo;ll be using the lab topology below:</p>
<p><img alt="topology" loading="lazy" src="/content/images/2022/07/topology.png#center"></p>
<p>I will be using the reserved IP range 203.0.113.0/24 for the WAN-side addressing. I&rsquo;ll have one Windows &amp; one Android client that we&rsquo;ll walk through &amp; connect to the VPN.</p>
<h2 id="installing-the-wireguard-plugin">Installing the Wireguard Plugin</h2>
<p>To get started, first thing we will want to do is install the Wireguard plugin for OPNsense. By default, OPNsense will have standard IPSec &amp; OpenVPN already available - but other VPN options can be enabled easily.</p>
<p>So in OPNsense, we&rsquo;ll navigate down to <strong>System &gt; Firmware &gt; Plugins</strong>, then search for <strong>wireguard</strong> and click the plus icon.</p>
<p><img alt="addplugin" loading="lazy" src="/content/images/2022/07/addplugin.png#center"></p>
<p>This should pull down the package &amp; install pretty quickly. No reboot required here!</p>
<p><img alt="plugindownload" loading="lazy" src="/content/images/2022/07/plugindownload.png#center"></p>
<p>Once installed, you may have to refresh the page or navigate to a new page so that the menu bar has a chance to reload. Then we&rsquo;ll have a new option under <strong>VPN</strong>:</p>
<p><img alt="vpnmenu" loading="lazy" src="/content/images/2022/07/vpnmenu.png#center"></p>
<h2 id="wireguard-tunnel-configuration">Wireguard Tunnel Configuration</h2>
<p>Next we&rsquo;ll begin configuring Wireguard on the OPNsense side.</p>
<p>There is a little bit of a chicken &amp; egg scenario here since everything is based on cryptographic keys. We&rsquo;ll need to generate keys on the firewall, which we need to enter on the client - but we also need the client keys to enter on the firewall. A bit of bouncing between the two - but for now we&rsquo;ll try to complete as much as we can on the firewall side.</p>
<p>We&rsquo;ll enable Wireguard by dropping down to <strong>VPN &gt; WireGuard</strong> then clicking <strong>Enable</strong> and <strong>Apply</strong></p>
<p><img alt="enablewg" loading="lazy" src="/content/images/2022/07/enablewg.png#center"></p>
<p>Next we&rsquo;ll set up the Wireguard tunnel interface on OPNsense. This will be a virtual tunnel interface that will be created as interface <code>wg&lt;instance number&gt;</code>.</p>
<p>To do this, we&rsquo;ll navigate to the <strong>Local</strong> tab, and click the plus icon to add a new tunnel.</p>
<p><img alt="localconfig-pt1-1" loading="lazy" src="/content/images/2022/07/localconfig-pt1-1.png#center"></p>
<p>In the above screenshot, I&rsquo;ve filled in just a few details.</p>
<p>For <strong>Name</strong>, I&rsquo;ve entered our virtual interface name <code>wg1</code>. Since OPNsense shows the <strong>Instance</strong> as <code>1</code> - it will create a <code>wg</code> interface with that instance number.</p>
<p>We&rsquo;ll leave <strong>Public Key</strong> &amp; <strong>Private Key</strong> blank for now. OPNsense will auto-generate these keys once we save this config.</p>
<p>For <strong>Listen Port</strong>, I&rsquo;ve set this to 51820 which is the default for Wireguard. It&rsquo;s not stated here, but this is a UDP tunnel.</p>
<p>For <strong>Tunnel Address</strong> - this is where we add the IP address of the virtual tunnel interface. This will be the gateway for our remote clients. In my lab I&rsquo;ll be using 10.50.50.1/24 here.</p>
<p>We have no peers configured yet - so we can&rsquo;t select any here. We&rsquo;ll leave this blank for now, but come back later.</p>
<p>We will leave <strong>Disable Routes</strong> unchecked. By default, OPNsense will add static/connected routes for any client via the tunnel interface. You might not want this behavior if you wanted to do custom routing - for example, in a site-to-site VPN connection - but we&rsquo;ll leave this enabled.</p>
<p>Once we&rsquo;re done, we&rsquo;ll click <strong>Save</strong>.</p>
<p>Like I mentioned before, OPNsense will now auto-generate our crypto keys for the tunnels. So if we edit our tunnel, we&rsquo;ll now see those fields populated:</p>
<p><img alt="localconfig-pt2-1" loading="lazy" src="/content/images/2022/07/localconfig-pt2-1.png#center"></p>
<p>We&rsquo;ll want to copy the <strong>Public Key</strong> &amp; save it for later. This will need to be imported onto our clients, so that they can communicate securely with our firewall.</p>
<h2 id="wireguard-interface-assignment">Wireguard Interface Assignment</h2>
<p>Now that we have our headend tunnel interface defined, we can map our <code>wg1</code> interface to an OPNsense interface. The OPNsense documentation suggests this is optional, but I would recommend it since it will allow us to create firewall rules to permit/deny access to clients.</p>
<p>We&rsquo;ll navigate to <strong>Interfaces &gt; Assignments</strong>, and we should see a <strong>New interface</strong> available: our <code>wg1</code> tunnel.</p>
<p>We can assign this a name, then click the plus icon &amp; <strong>Save</strong>.</p>
<p><img alt="newinterface" loading="lazy" src="/content/images/2022/07/newinterface.png#center"></p>
<p>Next we&rsquo;ll enable the interface by navigating to <strong>Interfaces &gt; WG1</strong>. Here we&rsquo;ll only need to click <strong>Enable</strong> &amp; save the change - nothing else is necessary.</p>
<p><img alt="enableinterface" loading="lazy" src="/content/images/2022/07/enableinterface.png#center"></p>
<p>Of course, we&rsquo;ll be prompted to apply the changes - which we will do:</p>
<p><img alt="applychangeinterface" loading="lazy" src="/content/images/2022/07/applychangeinterface.png#center"></p>
<p>By default, all traffic through our <code>WG1</code> firewall interface will be blocked - so please make sure to configure a firewall rule to permit traffic from the Wireguard clients.</p>
<h2 id="firewall-rules-allow-inbound-wireguard-traffic">Firewall Rules: Allow Inbound Wireguard Traffic</h2>
<p>Next we need to permit the Wireguard traffic into our firewall. By default the WAN interface will block all traffic that isn&rsquo;t explicitly allowed - including our Wireguard traffic.</p>
<p>For this, we&rsquo;ll navigate to <strong>Firewall &gt; Rules &gt; WAN</strong>. Then click the plus icon to add a new rule.</p>
<p><img alt="waninboundfwrule" loading="lazy" src="/content/images/2022/07/waninboundfwrule.png#center"></p>
<p>The screenshot above shows what our firewall rule will look like.</p>
<p>Here&rsquo;s the summary:</p>
<ul>
<li>Action: Pass</li>
<li>Interface: WAN</li>
<li>Direction: In</li>
<li>TCP/IP Version: IPv4
<ul>
<li>You can enable IPv6 as well, if you have IPv6 connectivity (this is a lab box, which does not)</li>
</ul>
</li>
<li>Protocol: UDP</li>
<li>Source: Any
<ul>
<li>This will allow anyone on the internet to reach our VPN. We could restrict source IP addresses, if our clients had permanent, static IPs.</li>
</ul>
</li>
<li>Destination: WAN Address
<ul>
<li>The firewall itself is the destination for this traffic</li>
</ul>
</li>
<li>Destination Port Range: (other) / 51820</li>
</ul>
<p>I also enabled logging &amp; added a quick description. After we have all this configured, we can click <strong>Save</strong> - then <strong>Apply Changes</strong>.</p>
<h2 id="client-setup---windows">Client Setup - Windows</h2>
<p>So first we&rsquo;ll start with an easy configuration on a Windows client. Wireguard client software can be found on the Wireguard site <a href="https://www.wireguard.com/install/">here</a>.</p>
<p>For the sake of the walkthrough, we will manually configure each client. However, this can be a difficult task if there is a large number of clients. Wireguard does support importing configurations, and there are a number of free tools available to help automate generating config files for clients - including some which will generate QR codes for easy import on mobile clients.</p>
<p>So on my lab Windows machine, we&rsquo;ll open up the Wireguard client &amp; click <strong>Add Empty Tunnel:</strong></p>
<p><img alt="windows-addnew" loading="lazy" src="/content/images/2022/07/windows-addnew.png#center"></p>
<p>Then we&rsquo;ll be given a blank config file, with only the devices public &amp; private key pair generated for us.</p>
<p>We&rsquo;re going to fill in details similar to the below screenshot:</p>
<p><img alt="windows-tunnelconfig" loading="lazy" src="/content/images/2022/07/windows-tunnelconfig.png#center"></p>
<p>The configuration under [Interface] is the local, client-side configuration. I&rsquo;ve added the client&rsquo;s tunnel address - which will be 10.50.50.15/32. I&rsquo;ve also configured DNS servers which the client can reach via the VPN.</p>
<p>Then we&rsquo;ll add the [Peer] section, which contains info about our VPN headend. Here&rsquo;s where we&rsquo;ll need the public key from our OPNsense firewall. We&rsquo;ll also specify the <strong>Endpoint</strong> address, which is the IP or hostname of our VPN headend &amp; the port (which by default is 51820).</p>
<p>We&rsquo;ve also configured <strong>AllowedIPs</strong> as <code>0.0.0.0/0</code>. This will force <strong>all</strong> client traffic over the VPN tunnel - including general internet traffic. However, we could limit this to specific subnets. For example, let&rsquo;s say your network only used 172.16.90.0/24 &amp; 10.1.1.0/16 subnets &amp; we only wanted the user to be able to access those. We would configure the following: <code>AllowedIPs = 172.16.90.0/24, 10.1.1.0/16</code>. In this case, only traffic for those subnets would be routed over the VPN - any other traffic would use the devices default internet connection.</p>
<p>Now, we&rsquo;ll save this - and again need to copy the device&rsquo;s <strong>Public Key</strong>, which we&rsquo;ll need to enter on the OPNsense firewall.</p>
<h2 id="client-setup---adding-clients-to-opnsense">Client Setup - Adding Clients to OPNsense</h2>
<p>In order for the Windows machine to connect to OPNsense, we&rsquo;ll also need to configure a client profile on the firewall.</p>
<p>In OPNsense, we&rsquo;ll navigate back to <strong>VPN &gt; WireGuard</strong>, then click on the <strong>Endpoints</strong> tab.</p>
<p><img alt="wg-client-win" loading="lazy" src="/content/images/2022/07/wg-client-win.png#center"></p>
<p>Here we&rsquo;ll configure a name for our client &amp; paste in the client&rsquo;s <strong>Public Key</strong>.</p>
<p>We&rsquo;ll also set <strong>AllowedIPs</strong> to the client&rsquo;s IP address, which we have configured as <code>10.50.50.15/32</code>. This controls what IP addresses are reachable via this endpoint.</p>
<p>We do have some additional fields available, which we will leave blank. For example - <strong>Endpoint Address</strong> &amp; <strong>Endpoint Port</strong> would be used to define a public IP that we expect our client to connect from. Since a remote-access client could connect from any IP, we leave those fields blank to allow this.</p>
<p>Once we&rsquo;re done, we&rsquo;ll click <strong>Save</strong> then <strong>Apply</strong>.</p>
<p>Next we&rsquo;ll jump back to the <strong>Local</strong> tab, and edit our headend tunnel configuration.</p>
<p>We should now see our windows client in the <strong>Peers</strong> dropdown. We&rsquo;ll select that client, so that Wireguard will permit that client to connect via this tunnel interface.</p>
<p><img alt="localconfig-pt3" loading="lazy" src="/content/images/2022/07/localconfig-pt3.png#center"></p>
<p>Then, as always, click <strong>Save</strong> &amp; <strong>Apply</strong></p>
<p>Last but not least - we should restart our Wireguard server on OPNsense. This can be done by either disabling &amp; re-enabling Wireguard - or by navigating back to the OPNsense dashboard &amp; clicking the restart icon next to the <strong>wireguard-go</strong> service.</p>
<h2 id="testing-the-connection">Testing The Connection</h2>
<p>Okay - now that we have all that completed, it&rsquo;s finally time to test connectivity from our client.</p>
<p>On my Windows client, I&rsquo;ll just click the <strong>Activate</strong> button for the tunnel:</p>
<p><img alt="windows-tunnelconnected" loading="lazy" src="/content/images/2022/07/windows-tunnelconnected.png#center"></p>
<p>And we&rsquo;ll see that the <strong>Status</strong> shows <strong>Active</strong>, and we&rsquo;ll start to see updates to the <strong>Last Handshake</strong> &amp; <strong>Transfer</strong> fields - indicating we are connected &amp; sending data.</p>
<p>To further validate, we can check the <strong>Log</strong> tab:</p>
<p><img alt="windows-log" loading="lazy" src="/content/images/2022/07/windows-log.png#center"></p>
<p>The key things to look for here, are the following messages:</p>
<ul>
<li><strong>Receiving handshake response</strong> which indicates our firewall responded to our request to connect</li>
<li><strong>Keypair 1 created</strong> which indicates that our connection is healthy to our peer</li>
<li><strong>Receiving keepalive packet from peer</strong> - we should see these periodically to maintain our connection. If keepalives stop flowing, then we may have a break in connectivity between client &amp; peer.</li>
</ul>
<p>We should also be able to reach out <code>wg1</code> tunnel address from the Windows client:</p>
<p><img alt="windows-ping" loading="lazy" src="/content/images/2022/07/windows-ping.png#center"></p>
<p>On the OPNsense side of things, we can check what client is connected via the <strong>List Configuration</strong> tab, under <strong>VPN &gt; Wireguard</strong>:</p>
<p><img alt="wireguard-listconfig" loading="lazy" src="/content/images/2022/07/wireguard-listconfig.png#center"></p>
<p>On this screen, we can see we have 1 peer connected - which matches the IP &amp; public key of our Windows client. We&rsquo;ll see similar output like the Windows client, where we can see the latest handshake &amp; data transfer.</p>
<p>Additionally, for easier access we can add the Wireguard widget to the OPNsense dashboard.</p>
<p>If we navigate to our dashboard, then click <strong>Add widget</strong> - we can add the <strong>Wireguard</strong> widget.</p>
<p>Here&rsquo;s what that looks like:</p>
<p><img alt="wg-widget" loading="lazy" src="/content/images/2022/07/wg-widget.png#center"></p>
<h2 id="additional-client-setup---android">Additional Client Setup - Android</h2>
<p>Let&rsquo;s also take a quick look at a mobile client. I&rsquo;ll get through this pretty quickly, since the configuration will be very similar to our other client - just a different UI.</p>
<p>On my Android device - if I open up the Wireguard app, I have a few options for creating or importing a tunnel:</p>
<p><img alt="android-create-1" loading="lazy" src="/content/images/2022/07/android-create-1.png#center"></p>
<p>In this case, we&rsquo;ll again walk through creating a tunnel manually. Again, it&rsquo;s worth mentioning that there are 3rd party apps available to auto-generate config imports or QR codes to make this easier.</p>
<p>First we&rsquo;ll have a handful of fields to fill in about the Android-side configuration. This includes a name for the tunnel, an address, and DNS servers.</p>
<p>We can click on the refresh icon in the <strong>Private Key</strong> field to auto-generate our key pairs:</p>
<p><img alt="android-interface-1" loading="lazy" src="/content/images/2022/07/android-interface-1.png#center"></p>
<p>One of the interesting parts of the mobile app is the ability to permit/exclude individual apps from traversing the VPN tunnel.</p>
<p>Here&rsquo;s a quick screenshot, where we can pick either to allow only certain apps to use the VPN - or permit all except a few we choose to exclude:</p>
<p><img alt="android-app-list-1" loading="lazy" src="/content/images/2022/07/android-app-list-1.png#center"></p>
<p>In my case, I&rsquo;ll keep this set to allow all applications.</p>
<p>Next we&rsquo;ll work on the peer config:</p>
<p><img alt="android-peer-1" loading="lazy" src="/content/images/2022/07/android-peer-1.png#center"></p>
<p>After that, all we need to do is save our VPN configuration - then we can toggle the tunnel on or off:</p>
<p><img alt="android-enable-1" loading="lazy" src="/content/images/2022/07/android-enable-1.png#center"></p>
<p>And similar to the Windows client, we can click on the tunnel itself to see current status / data transfer:</p>
<p><img alt="android-stats-1" loading="lazy" src="/content/images/2022/07/android-stats-1.png#center"></p>
<p>So it looks like we should be connected &amp; can try accessing VPN resources!</p>
<p>We can also use the same methods as earlier to check connectivity from the OPNsense side.</p>
<hr>
<p>Okay - that&rsquo;s all I wanted to share today. I&rsquo;ve been quite pleased with how easy to use WireGuard has been  - and how well it performs! I hope this blog post was helpful if you&rsquo;re interested in trying it out.</p>
<p>Thanks!!</p>
]]></content:encoded>
    </item>
    <item>
      <title>OPNsense on Qotom Q750G5 - Hardware Overview &amp; Perf Testing</title>
      <link>https://0x2142.com/opnsense-qotom-q750gs/</link>
      <pubDate>Sat, 18 Jun 2022 18:21:18 +0000</pubDate>
      <guid>https://0x2142.com/opnsense-qotom-q750gs/</guid>
      <description>In this post, we will take a look at the Qotom Q750G5 hardware (with 2.5GbE), install OPNsense, and walk through a few performance tests.</description>
      <content:encoded><![CDATA[<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/ppS6IhKSkfY?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<p><sup><em>Note: I may receive commissions for purchases made through links in this post. This is to help support my blog and does not have any impact on my recommendations.</em></sup></p>
<p>One day I would love to have symmetric internet speeds, but for the meantime I have to work with what I have - which is dismal upload speeds that don&rsquo;t come anywhere close to the download speed.</p>
<p>So I&rsquo;m currently at 200Mb/s down &amp; 10Mb/s up - and I would prefer to have higher upload speeds. However, even just 20Mb/s upload requires me to purchase a 500Mb/s download plan. 🙄</p>
<p>I&rsquo;ve been hesitant to upgrade, since my current Meraki MX64 tops out at ~250Mb/s throughput. I would have to upgrade my firewall or half of my new download speed would be unusable.</p>
<p>While Meraki does have faster firewalls, they&rsquo;re a bit expensive &amp; at the moment somewhat difficult to obtain. So instead I searched around for alternatives, and came across the <a href="https://amzn.to/3apFx5R">Qotom Q750G5</a> - which is a barebones mini-PC that I could load pfSense or OPNsense onto.</p>
<p>So in this blog post - I wanted to talk about the device &amp; some of the performance testing I did.</p>
<hr>
<h2 id="qotom-q750g5---hardware">Qotom Q750G5 - Hardware</h2>
<p>First let&rsquo;s take a quick look at the hardware. What got my attention quickly was the five 2.5GbE ports, but this small device offers quite a lot for how inexpensive it was.</p>
<p>A quick look at the specs:</p>
<ul>
<li>Intel Celeron J4125 Quad Core 2.0Ghz (Burst 2.7Ghz)</li>
<li>Five Intel I225-V 2.5Gb Ethernet ports</li>
<li>Optional WiFi slot</li>
<li>Optional 3G Cellular &amp; SIM card slots</li>
<li>1 RAM slot</li>
<li>1 mSATA slot</li>
<li>1 2.5in SATA HDD slot</li>
<li>2x USB 2.0 &amp; 3x USB 3.0 ports</li>
</ul>
<p>By default it seems this is a barebones kit, however I did opt to buy a model that included 16GB RAM &amp; a 256GB mSATA SSD. It arrived with a single 16GB TeamGroup DDR4 3200Mhz module &amp; 256GB Hoodisk mSATA SSD.</p>
<p>Are the specs a bit overkill for an embedded firewall? Yeah definitely. But the whole kit was only around $230 USD - which seemed crazy to me.</p>
<p>The big thing that pulled me toward this model (besides price) was the 2.5GbE ports. Since a lot more places have gigabit residential internet these days, and some lucky places are starting to see 2Gb/s - I was hoping that this little box would offer me a bit of future-proofing.</p>
<p>Of course, I was a little curious about what performance this device could realistically achieve - but more on that later!</p>
<p>I wanted to provide a few photos of the unit as well. The casing itself is pretty minimal, but the box is definitely heavier than you would expect!</p>
<p><strong>Front Photo:</strong></p>
<p><img alt="qotom750g5-front" loading="lazy" src="/content/images/2022/05/qotom750g5-front.jpg#center"></p>
<p>On the front there isn&rsquo;t a whole lot to see. Power button, reset button, status LEDs, and USB ports. Oh - and there is an HDMI port as well, which comes in handy when installing an operating system (or if you&rsquo;re using this as an actual PC).</p>
<p><strong>Back Photo:</strong></p>
<p><img alt="qotom750g5-back" loading="lazy" src="/content/images/2022/05/qotom750g5-back.jpg#center"></p>
<p>The back shows off the five 2.5Gb Ethernet ports, as well as the power plug. While I didn&rsquo;t get a WiFi-enabled unit, the back faceplate still has cutouts for wireless antenna. I could opt to add wireless to this later, but I do wish the faceplate came with plugs or something to cover the holes in the meantine.</p>
<p><strong>Inside Photo:</strong></p>
<p><img alt="qotom750g5-internal-1" loading="lazy" src="/content/images/2022/05/qotom750g5-internal-1.jpg#center"></p>
<p>Now here&rsquo;s where things get interesting! This box surprisingly packs a lot in it&rsquo;s tiny size.</p>
<p>In the upper right, there is a PCI slot for WiFi. There&rsquo;s also a WiFi/3G PCI slot in the lower left.</p>
<p>Just above the 3G slot is the SSD mSATA slot. When a drive is installed, it does cover the SIM card slot - meaning that the SSD would need to be removed to change SIM cards.</p>
<p>Also on the left, mostly out of the photo, is a connector for a 2.5in HDD. While I didn&rsquo;t snap a photo of the bottom of the unit, the drive would screw into the bottom plate.</p>
<p>Interestingly enough, the CPU is on the other side of the motherboard. While you might think that the overall unit kinda looks like a heatsink - I was surprised to see that&rsquo;s exactly what it is. The CPU is located right under the four screws with black washers and has thermal paste pre-applied. It rests up against the top of the case &amp; uses the top as a heatsink.</p>
<p>As a last note about the CPU - it does get <em>quite toasty</em> at times. During one of my performance tests, the CPU reached ~90°C - and the top of the unit was very hot to the touch. It may not act as the world&rsquo;s best heatsink, so I would avoid placing anything on top of the unit - or resting your hand there for too long 🙂.</p>
<h2 id="performance-testing">Performance Testing</h2>
<p>As a quick note before we get to the good stuff: All of my tests were performed using <a href="https://iperf.fr/iperf-download.php">iPerf3</a>. This may not show us the best real-world throughput tests, but I had quite a difficult time getting dpdk drivers to compile correctly for the Intel 2.5GbE ports (so I could use something like <a href="https://trex-tgn.cisco.com/">TRex</a>). I may attempt to go back to this later, but the iPerf data is what I&rsquo;ll provide for now.</p>
<h3 id="the-testbed">The Testbed</h3>
<p>For the performance testing, I used the two <a href="/home-lab-upgrade-intel-nuc11/">Intel NUC11</a> PCs that I purchased recently for my VMware lab. These already come with a 2.5GbE port, which I am currently using for vMotion between the two. I disconnected the vMotion port temporarily, and instead enabled PCI-passthrough to connect the ports directly to a VM.</p>
<p>I built a VM on each NUC with the following specs:</p>
<ul>
<li>Debian 11</li>
<li>8x vCPU</li>
<li>16GB RAM</li>
<li>PCI-passthrough to 2.5GbE adapter</li>
</ul>
<p>iPerf 3.9 was used for all tests. The iPerf server was enabled with the <code>iperf3 -s</code> command, and the client tests were run with <code>iperf3 -c &lt;client ip&gt; -P 8 -t 600</code>. Each test was run for 10 minutes.</p>
<p>The devices were connected &amp; configured with the following topology:</p>
<p><img alt="network-diagram" loading="lazy" src="/content/images/2022/05/network-diagram.png#center"></p>
<blockquote>
<p>Note: In the below paragraphs, I will talk about the configuration I used for each test. If you&rsquo;re interested in more detail, please check out the video at the top of this blog post. In the video, I walk through the configuration &amp; setup for most of the tests below.</p></blockquote>
<h3 id="test-1-no-firewall">Test 1: No Firewall</h3>
<blockquote>
<p>Avg: 2.35Gb/s</p></blockquote>
<p>Okay, so expecting that I likely wouldn&rsquo;t get the full 2.5Gb speeds once I added the firewall - I wanted to perform a baseline test with the VM&rsquo;s directly connected via the 2.5GbE passthrough port.</p>
<p>In each of these tests, I was able to reach an average speed of: 2.35Gb/s</p>
<h3 id="test-2-routing-nat-simple-firewall-rules">Test 2: Routing, NAT, Simple Firewall rules</h3>
<blockquote>
<p>Avg: 2.35Gb/s</p></blockquote>
<p>In this test case, OPNsense was configured to match the diagram above. The iPerf server was located on the LAN segment, with an IP of 10.2.2.1 &amp; a default route toward the LAN interface of the OPNsense box (10.2.2.2). The client is connected via the WAN interface, at 203.0.113.50.</p>
<p>I created a proxy-ARP virtual address for the 203.0.113.25 IP address, then created a NAT rule to forward traffic sent to that address to 10.2.2.1.</p>
<p>Next, there was a single firewall rule created to permit TCP port 5201 inbound from the WAN. This is the default port that iPerf will use.</p>
<p>During these tests, I averaged about 2.35Gb/s and relatively low CPU usage around 10-20%.</p>
<p><em>As an interesting side note to this: Originally I didn&rsquo;t use the default LAN &amp; WAN ports (ports 1 &amp; 2), but instead used ports 3 &amp; 4. During testing between those ports, I could only reach ~1.7Gb/s. Once I switched to ports 1 &amp; 2, I could easily hit 2.35Gb/s. I&rsquo;m curious to dig in later &amp; see if this is a hardware issue, or possibly OPNsense is prioritizing the LAN/WAN traffic differently</em></p>
<h3 id="test-3-large-firewall-ruleset">Test 3: Large Firewall Ruleset</h3>
<blockquote>
<p>Avg: 2.35Gb/s</p></blockquote>
<p>While my home network will likely have a somewhat minimal firewall ruleset, I was curious to see how well the device would perform with a large ruleset.</p>
<p>So I wrote a script to auto-generate ~1,200 firewall rules with random IP addresses, ports, and a mix of permit/block actions. I applied the ruleset inbound on both the LAN &amp; WAN ports.</p>
<p>Under this test, I was still able to reach the 2.35Gb/s speeds - but now the CPU was creeping up to 30-40%.</p>
<p>So what next? Well I decided to see if I could stress the box a little - and increased the auto-generated ruleset to just over ~15,000 rules.</p>
<p>The increased ruleset took about 5-10 minutes to load into the system, and CPU was pegged at 100% the whole time. In fact, the CPU never really came back down. Even after the rules had loaded, the CPU was flat at 100% - and it took anywhere from 2-4 minutes to navigate between pages in the web GUI. (This is the part where my CPU temps went from &lt;50°C to over 90°C 🙃)</p>
<p>I ended up having to re-image the box.</p>
<h3 id="test-4-suricata-ips">Test 4: Suricata IPS</h3>
<blockquote>
<p>Avg: 2.35Gb/s (But sometimes much, much less)</p></blockquote>
<p>Next I loaded up the built-in IDS/IPS, which uses suricata. I downloaded all available free rulesets, and enabled all of them. Ideally, you wouldn&rsquo;t necessarily enable everything - but I wanted to start off with a full load test.</p>
<p>My experience with these tests was highly variable. <em>Most</em> times, I was surprised to see that I could still push 2.35Gb/s through without any issue. During these tests, the CPU usually bounced between 50-80% usage.</p>
<p>Strangely, every so often I would test and get significantly less than that. Most times when this happened, I would instead only see somewhere between 400-700Mb/s - but on one test the box slowed to just over 200Mb/s. Each time this happened, the performance tests would remain degraded until I restarted the suricata service - then I would be able to reach the 2.35Gb/s again.</p>
<p>My best guess is that something is getting stuck. I know some older IPS systems I&rsquo;ve worked with in the past had issues with CPU-pinning, and you might get garbage performance if your traffic hit the wrong CPU core. I didn&rsquo;t spend a lot of time digging into this, but it feels a bit similar.</p>
<h3 id="test-5-wireguard-vpn">Test 5: Wireguard VPN</h3>
<blockquote>
<p>Avg: 800Mb/s, 650-700Mb/s with IPS also enabled</p></blockquote>
<p>I also wanted to try VPN performance. There are a lot of options for VPN services within OPNsense, including standard IPSec and OpenVPN. However, I opted to try out wireguard - since it&rsquo;s really easy to set up &amp; get running.</p>
<p>In this case, I definitely hit a limitation with CPU-pinning. With my initial tests, I could only reach about ~450-500Mb/s - but the Qotom CPU was only spiking up to 70%.</p>
<p>Seems like the wireguard client (at least for same source/destination/port traffic) does pin everything to a single CPU. So my client CPU, between encrypting the traffic &amp; generating it, was actually maxing out long before the Qotom was.</p>
<p>I ended up spinning up a second VM on the client side (which required disabling PCI passthough &amp; adding both VMs to a shared vSwitch). With both of these running, I was able to max out the Qotom CPU at 100% - and hit a fairly consistent 800Mb/s VPN throughput.</p>
<p>As a final test, I enabled the suricata IPS on top of the VPN as well. Now the traffic would need to be decrypted &amp; inspected before reaching the server. With a single client, I averaged ~400-450Mb/s - and with both clients it was around ~650-700Mb/s</p>
<hr>
<p>Overall I&rsquo;m really pleased with how well this thing performs, especially for how relatively inexpensive it was. I also expected OPNsense to have a steep learning curve, but it was surprisingly easy to get up and running very quickly.</p>
<p>Next I&rsquo;ll be working on getting this firewall up &amp; running at home. I may be tempted to write up some more on OPNsense - so if there are any questions or specific configurations you might like to see, please leave a comment!</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
