<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Yarmo - docker</title>
    <subtitle>Blog of an Open Source developer</subtitle>
    <link rel="self" type="application/atom+xml" href="https://yarmo.eu/tags/docker/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://yarmo.eu"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2022-04-16T12:00:12+00:00</updated>
    <id>https://yarmo.eu/tags/docker/atom.xml</id>
    <entry xml:lang="en">
        <title>Wireguard and docker: providing VPN access to arbitrary containers</title>
        <published>2022-04-16T12:00:12+00:00</published>
        <updated>2022-04-16T12:00:12+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://yarmo.eu/blog/wireguard-docker/"/>
        <id>https://yarmo.eu/blog/wireguard-docker/</id>
        
        <content type="html" xml:base="https://yarmo.eu/blog/wireguard-docker/">&lt;h2 id=&quot;Your_container_might_benefit_from_VPN_access&quot;&gt;Your container might benefit from VPN access&lt;&#x2F;h2&gt;
&lt;p&gt;Some containers just aren&#x27;t meant to be connected directly to the internet. After all, you wouldn&#x27;t want your ISP knowing which Linux distribution you download and share.&lt;&#x2F;p&gt;
&lt;p&gt;If like me you have your BitTorrent client installed as a container on a homeserver to make sure it&#x27;s always connected but you don&#x27;t want to route your other containers through a VPN, you&#x27;ll probably want to use a VPN-in-a-container and route your BitTorrent client through it.&lt;&#x2F;p&gt;
&lt;p&gt;I already had a similar solution using OpenVPN but it was time for an upgrade. Oh yes, it&#x27;s &lt;a href=&quot;https:&#x2F;&#x2F;www.wireguard.com&#x2F;&quot;&gt;Wireguard&lt;&#x2F;a&gt; time.&lt;&#x2F;p&gt;
&lt;p&gt;As VPN provider, I use &lt;a href=&quot;https:&#x2F;&#x2F;mullvad.net&#x2F;&quot;&gt;Mullvad&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;The_solution&quot;&gt;The solution&lt;&#x2F;h2&gt;
&lt;p&gt;Our situation is this: our homeserver (could be a Linux machine, a Raspberry Pi…) runs two docker containers, one which is fine to be directly connected to the internet and one which would benefit from VPN access.&lt;&#x2F;p&gt;
&lt;p&gt;One could install the Wireguard client straight on the machine and route both containers through the VPN, but for various reasons, that&#x27;s now what we want here.&lt;&#x2F;p&gt;
&lt;p&gt;Our solution will be to add another container which connects to the VPN and route our sensitive container through the VPN container.&lt;&#x2F;p&gt;
&lt;p&gt;With some experimenting, I got it working 90%. The only issue was that while the BitTorrent client was perfectly shielded by the VPN, I could no longer access the client myself. Not great.&lt;&#x2F;p&gt;
&lt;p&gt;After two days of trying stuff out and searching the internet, I found the working solution on a blog post from 2021 which sadly already no longer exists. But thanks to the Web Archive, &lt;a href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20210207170757&#x2F;https:&#x2F;&#x2F;bookstack.almueti.com&#x2F;books&#x2F;wireguard&#x2F;page&#x2F;docker-compose-with-mullvad-wireguard-arbitrary-service&quot;&gt;its wisdom is lost no more&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;PostUp_and_PreDown&quot;&gt;PostUp and PreDown&lt;&#x2F;h2&gt;
&lt;p&gt;The reason I didn&#x27;t get it working myself is because I knew the problem lay in the &lt;code&gt;PostUp&#x2F;PreDown&lt;&#x2F;code&gt; commands of the Wireguard configuration. And I don&#x27;t know how to read or write those :&#x2F; Mullvad provides their own but they do not work in this situation.&lt;&#x2F;p&gt;
&lt;p&gt;I must therefore warn you that I sadly do not fully understand the solution. I probably could fiddle with it and get it working on a different system, but I don&#x27;t &lt;em&gt;understand&lt;&#x2F;em&gt; it. I simply took my 90%-functional implementation, copy-pasted the &lt;code&gt;PostUp&#x2F;PreDown&lt;&#x2F;code&gt; commands from the linked blog post and voilà, success!&lt;&#x2F;p&gt;
&lt;p&gt;Not proud of it, and I hope I&#x27;ll gain understanding of these commands in the near future, but that&#x27;s the situation.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;The_implementation&quot;&gt;The implementation&lt;&#x2F;h2&gt;
&lt;p&gt;You must have Wireguard installed on your system but it doesn&#x27;t need to be running any connection.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;docker-compose.yml&quot;&gt;&lt;code&gt;docker-compose.yml&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;yml&quot; style=&quot;background-color:#212733;color:#ccc9c2;&quot; class=&quot;language-yml &quot;&gt;&lt;code class=&quot;language-yml&quot; data-lang=&quot;yml&quot;&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;version&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;&amp;#39;2.3&amp;#39;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;services&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;wireguard&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;image&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;linuxserver&#x2F;wireguard
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;hostname&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;wireguard
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;container_name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;wireguard
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;cap_add&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;net_admin
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;sys_module
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;ports&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;8112:8112
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;58846:58846
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;volumes&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;&#x2F;lib&#x2F;modules:&#x2F;lib&#x2F;modules
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;.&#x2F;data&#x2F;wireguard:&#x2F;config
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;sysctls&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;net.ipv4.conf.all.src_valid_mark=1
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;deluge&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;image&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;linuxserver&#x2F;deluge
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;container_name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;deluge
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;network_mode&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;service:wireguard
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;volumes&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;.&#x2F;data&#x2F;deluge:&#x2F;config
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;.&#x2F;data&#x2F;downloads:&#x2F;downloads
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In this docker-compose setup, we use the &lt;a href=&quot;https:&#x2F;&#x2F;hub.docker.com&#x2F;r&#x2F;linuxserver&#x2F;wireguard&quot;&gt;linuxserver&#x2F;wireguard&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;hub.docker.com&#x2F;r&#x2F;linuxserver&#x2F;deluge&quot;&gt;linuxserver&#x2F;deluge&lt;&#x2F;a&gt; container images. Please have a look at their respective documentation for more information on their configuration.&lt;&#x2F;p&gt;
&lt;p&gt;A few interesting notes:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yml&quot; style=&quot;background-color:#212733;color:#ccc9c2;&quot; class=&quot;language-yml &quot;&gt;&lt;code class=&quot;language-yml&quot; data-lang=&quot;yml&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;cap_add&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;net_admin
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;sys_module
&lt;&#x2F;span&gt;&lt;span&gt;    [&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;…&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;volumes&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;&#x2F;lib&#x2F;modules:&#x2F;lib&#x2F;modules
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;a href=&quot;https:&#x2F;&#x2F;hub.docker.com&#x2F;r&#x2F;linuxserver&#x2F;wireguard&quot;&gt;linuxserver&#x2F;wireguard&lt;&#x2F;a&gt; image uses the system&#x27;s Wireguard module and this configuration allows the container to access it.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yml&quot; style=&quot;background-color:#212733;color:#ccc9c2;&quot; class=&quot;language-yml &quot;&gt;&lt;code class=&quot;language-yml&quot; data-lang=&quot;yml&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;sysctls&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;net.ipv4.conf.all.src_valid_mark=1
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is important but sadly, I do not know what it does.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yml&quot; style=&quot;background-color:#212733;color:#ccc9c2;&quot; class=&quot;language-yml &quot;&gt;&lt;code class=&quot;language-yml&quot; data-lang=&quot;yml&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;ports&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;8112:8112
&lt;&#x2F;span&gt;&lt;span&gt;      - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;58846:58846
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is the interesting part. We assign those ports to the &lt;code&gt;wireguard&lt;&#x2F;code&gt; container, but they are the &lt;a href=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;linuxserver&#x2F;docker-deluge&#x2F;58ce900bc33b06d3c9cec24e7f17ac9d8b4433cf&#x2F;Dockerfile&quot;&gt;ports exposed by the &lt;code&gt;deluge&lt;&#x2F;code&gt; container&lt;&#x2F;a&gt;! Indeed, since the &lt;code&gt;deluge&lt;&#x2F;code&gt; container&#x27;s network flows through the &lt;code&gt;wireguard&lt;&#x2F;code&gt; container, we can only access the &lt;code&gt;deluge&lt;&#x2F;code&gt; container through the &lt;code&gt;wireguard&lt;&#x2F;code&gt; container&#x27;s network.&lt;&#x2F;p&gt;
&lt;p&gt;By the way, port &lt;code&gt;8112&lt;&#x2F;code&gt; is used for the &lt;a href=&quot;https:&#x2F;&#x2F;deluge.readthedocs.io&#x2F;en&#x2F;latest&#x2F;reference&#x2F;web.html&quot;&gt;Deluge WebUI&lt;&#x2F;a&gt; and port &lt;code&gt;58846&lt;&#x2F;code&gt; is used by &lt;a href=&quot;https:&#x2F;&#x2F;dev.deluge-torrent.org&#x2F;wiki&#x2F;UserGuide&#x2F;ThinClient&quot;&gt;Deluge Thin Clients&lt;&#x2F;a&gt;. Your BitTorrent client of choice will most likely use different ports!&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yml&quot; style=&quot;background-color:#212733;color:#ccc9c2;&quot; class=&quot;language-yml &quot;&gt;&lt;code class=&quot;language-yml&quot; data-lang=&quot;yml&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#73d0ff;&quot;&gt;network_mode&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ccc9c2cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;service:wireguard
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The trick that makes it all work: make sure that the &lt;code&gt;deluge&lt;&#x2F;code&gt; container connects to the internet through the &lt;code&gt;wireguard&lt;&#x2F;code&gt; container.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;wg0.conf&quot;&gt;&lt;code&gt;wg0.conf&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;This Wireguard configuration file is based on the one provided by Mullvad, but with the &lt;code&gt;PostUp&#x2F;PreDown&lt;&#x2F;code&gt; commands found in the &lt;a href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20210207170757&#x2F;https:&#x2F;&#x2F;bookstack.almueti.com&#x2F;books&#x2F;wireguard&#x2F;page&#x2F;docker-compose-with-mullvad-wireguard-arbitrary-service&quot;&gt;blog post mentioned earlier&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;conf&quot; style=&quot;background-color:#212733;color:#ccc9c2;&quot; class=&quot;language-conf &quot;&gt;&lt;code class=&quot;language-conf&quot; data-lang=&quot;conf&quot;&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;[Interface]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;PrivateKey &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;= &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;private key&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;Address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;= &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;ip address&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;DNS &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;= &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;ip address&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;PostUp &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;DROUTE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;$(ip route &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;|&lt;&#x2F;span&gt;&lt;span&gt; grep default &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;|&lt;&#x2F;span&gt;&lt;span&gt; awk &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bae67e;&quot;&gt;&amp;#39;{print $3}&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;); &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;HOMENET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;192.168.0.0&#x2F;16&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;HOMENET2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;10.0.0.0&#x2F;8&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;HOMENET3&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;172.16.0.0&#x2F;12&lt;&#x2F;span&gt;&lt;span&gt;; ip route add &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET3&lt;&#x2F;span&gt;&lt;span&gt; via &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$DROUTE&lt;&#x2F;span&gt;&lt;span&gt;;ip route add &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET2&lt;&#x2F;span&gt;&lt;span&gt; via &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$DROUTE&lt;&#x2F;span&gt;&lt;span&gt;; ip route add &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET&lt;&#x2F;span&gt;&lt;span&gt; via &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$DROUTE&lt;&#x2F;span&gt;&lt;span&gt;;iptables &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;I OUTPUT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;j &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;iptables &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;A OUTPUT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET2 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;j &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;; iptables &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;A OUTPUT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET3 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;j &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;  iptables &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;A OUTPUT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;! -&lt;&#x2F;span&gt;&lt;span&gt;o &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;%i &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;m mark &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;! --&lt;&#x2F;span&gt;&lt;span&gt;mark $(wg show &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;%i&lt;&#x2F;span&gt;&lt;span&gt; fwmark) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;m addrtype &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;! --&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;LOCAL &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;j &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;REJECT
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;PreDown &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;HOMENET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;192.168.0.0&#x2F;16&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;HOMENET2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;10.0.0.0&#x2F;8&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;HOMENET3&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;172.16.0.0&#x2F;12&lt;&#x2F;span&gt;&lt;span&gt;; ip route del &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET3&lt;&#x2F;span&gt;&lt;span&gt; via &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$DROUTE&lt;&#x2F;span&gt;&lt;span&gt;;ip route del &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET2&lt;&#x2F;span&gt;&lt;span&gt; via &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$DROUTE&lt;&#x2F;span&gt;&lt;span&gt;; ip route del &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET&lt;&#x2F;span&gt;&lt;span&gt; via &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$DROUTE&lt;&#x2F;span&gt;&lt;span&gt;; iptables &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;D OUTPUT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;! -&lt;&#x2F;span&gt;&lt;span&gt;o &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;%i &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;m mark &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;! --&lt;&#x2F;span&gt;&lt;span&gt;mark $(wg show &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;%i&lt;&#x2F;span&gt;&lt;span&gt; fwmark) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;m addrtype &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;! --&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;LOCAL &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;j &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;REJECT&lt;&#x2F;span&gt;&lt;span&gt;; iptables &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;D OUTPUT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;j &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;; iptables &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;D OUTPUT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET2 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;j &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;; iptables &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;D OUTPUT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;$HOMENET3 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;j &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#f29e74;&quot;&gt;ACCEPT
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;[Peer]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;PublicKey &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;= &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;public key&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;AllowedIPs &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;0.0.0.0&#x2F;0
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt;Endpoint &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;= &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;ip address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffa759;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span&gt; port&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29e74;&quot;&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;Verification&quot;&gt;Verification&lt;&#x2F;h2&gt;
&lt;p&gt;We need to make sure we are in fact connected safely to Mullvad! To do this, let&#x27;s use Mullvad&#x27;s &lt;code&gt;https:&#x2F;&#x2F;am.i.mullvad.net&#x2F;connected&lt;&#x2F;code&gt; API endpoint.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#212733;color:#ccc9c2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#ffd580;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span&gt; exec&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt; -t&lt;&#x2F;span&gt;&lt;span&gt; wireguard curl https:&#x2F;&#x2F;am.i.mullvad.net&#x2F;connected
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#5c6773;&quot;&gt;# You are connected to Mullvad (server XXYY-wireguard). Your IP address is XYZ.XYZ.XYZ.XYZ
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Success! But wait, that&#x27;s the &lt;code&gt;wireguard&lt;&#x2F;code&gt; container, this just checks whether our config is working. What about the &lt;code&gt;deluge&lt;&#x2F;code&gt; container?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#212733;color:#ccc9c2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#ffd580;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span&gt; exec&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffcc66;&quot;&gt; -t&lt;&#x2F;span&gt;&lt;span&gt; deluge curl https:&#x2F;&#x2F;am.i.mullvad.net&#x2F;connected
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#5c6773;&quot;&gt;# You are connected to Mullvad (server XXYY-wireguard). Your IP address is XYZ.XYZ.XYZ.XYZ
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Victory! Have fun sharing Linux distributions!&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
