<?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>NAS on Tom Burkert</title><link>https://blog.burkert.me/tags/nas/</link><description>Recent content in NAS on Tom Burkert</description><image><title>Tom Burkert</title><url>https://blog.burkert.me/assets/</url><link>https://blog.burkert.me/assets/</link></image><generator>Hugo -- 0.148.0</generator><language>en-us</language><lastBuildDate>Tue, 11 Feb 2025 22:37:22 +0200</lastBuildDate><atom:link href="https://blog.burkert.me/tags/nas/index.xml" rel="self" type="application/rss+xml"/><item><title>Setting Up Pi-Hole on Synology NAS DS218play</title><link>https://blog.burkert.me/posts/setting-up-pi-hole-on-synology-nas-ds218play/</link><pubDate>Tue, 11 Feb 2025 22:37:22 +0200</pubDate><guid>https://blog.burkert.me/posts/setting-up-pi-hole-on-synology-nas-ds218play/</guid><description>&lt;h2 id="intro">Intro&lt;/h2>
&lt;p>As part of my journey towards higher privacy while using internet, I decided to set up &lt;a href="https://pi-hole.net/" target="_blank" rel="noopener">Pi-hole&lt;/a> on my &lt;a href="https://www.synology.com/products/DS218play" target="_blank" rel="noopener">Synology NAS DS218play&lt;/a>. If you are reading this article, you probably don&amp;rsquo;t need the following explanation, but just in case: Pi-hole is perhaps the most popular DNS sinkhole, which aims to block ads, trackers and malicious sites for all devices on your local network.&lt;/p>
&lt;p>Now, your NAS is one of the best candidates for running Pi-hole since it is typically on 24/7 and connected via high-speed wired connection to your router. Since I already was an owner of Synology NAS, I started googling how to set up Pi-hole on my device. There are &lt;a href="https://www.synology.com/products/DS218play" target="_blank" rel="noopener">plenty&lt;/a> &lt;a href="https://mariushosting.com/how-to-install-pi-hole-on-your-synology-nas/" target="_blank" rel="noopener">of&lt;/a> &lt;a href="https://www.youtube.com/watch?v=bPs2M-GvRtQ" target="_blank" rel="noopener">howto&amp;rsquo;s&lt;/a> &lt;a href="https://github.com/markdumay/synology-pihole" target="_blank" rel="noopener">which&lt;/a> &lt;a href="https://erulezz.dev/synology/pi-hole-installation-on-synology-nas-with-docker/" target="_blank" rel="noopener">describe&lt;/a> &lt;a href="https://kevquirk.com/how-to-setup-pi-hole-on-a-synology-nas/" target="_blank" rel="noopener">the&lt;/a> &lt;a href="https://drfrankenstein.co.uk/pihole-in-docker-on-a-synology-nas/" target="_blank" rel="noopener">process&lt;/a>, but they have one fatal flaw: they rely on the &lt;em>Docker&lt;/em> (or &lt;em>Container Manager&lt;/em>, as it was later renamed to) Synology package to be installed and used for the setup. And this is where it starts to get interesting: Docker is not officially supported on ARM-based Synology NASes (such as the &lt;em>j&lt;/em> and &lt;em>play&lt;/em> models), supposedly &lt;a href="https://community.synology.com/enu/forum/17/post/90211" target="_blank" rel="noopener">due to insufficient performance of their CPUs&lt;/a>. This means you will not find the packages in the Package Manager and will not be able to install it the usual way.&lt;/p></description><content:encoded><![CDATA[<h2 id="intro">Intro</h2>
<p>As part of my journey towards higher privacy while using internet, I decided to set up <a href="https://pi-hole.net/" target="_blank" rel="noopener">Pi-hole</a> on my <a href="https://www.synology.com/products/DS218play" target="_blank" rel="noopener">Synology NAS DS218play</a>. If you are reading this article, you probably don&rsquo;t need the following explanation, but just in case: Pi-hole is perhaps the most popular DNS sinkhole, which aims to block ads, trackers and malicious sites for all devices on your local network.</p>
<p>Now, your NAS is one of the best candidates for running Pi-hole since it is typically on 24/7 and connected via high-speed wired connection to your router. Since I already was an owner of Synology NAS, I started googling how to set up Pi-hole on my device. There are <a href="https://www.synology.com/products/DS218play" target="_blank" rel="noopener">plenty</a> <a href="https://mariushosting.com/how-to-install-pi-hole-on-your-synology-nas/" target="_blank" rel="noopener">of</a> <a href="https://www.youtube.com/watch?v=bPs2M-GvRtQ" target="_blank" rel="noopener">howto&rsquo;s</a> <a href="https://github.com/markdumay/synology-pihole" target="_blank" rel="noopener">which</a> <a href="https://erulezz.dev/synology/pi-hole-installation-on-synology-nas-with-docker/" target="_blank" rel="noopener">describe</a> <a href="https://kevquirk.com/how-to-setup-pi-hole-on-a-synology-nas/" target="_blank" rel="noopener">the</a> <a href="https://drfrankenstein.co.uk/pihole-in-docker-on-a-synology-nas/" target="_blank" rel="noopener">process</a>, but they have one fatal flaw: they rely on the <em>Docker</em> (or <em>Container Manager</em>, as it was later renamed to) Synology package to be installed and used for the setup. And this is where it starts to get interesting: Docker is not officially supported on ARM-based Synology NASes (such as the <em>j</em> and <em>play</em> models), supposedly <a href="https://community.synology.com/enu/forum/17/post/90211" target="_blank" rel="noopener">due to insufficient performance of their CPUs</a>. This means you will not find the packages in the Package Manager and will not be able to install it the usual way.</p>
<p>There are many users asking how to install Docker (or even specifically <a href="https://www.reddit.com/r/pihole/comments/kw2xqv/pihole_on_synology_ds218play_no_docker/" target="_blank" rel="noopener">Pi-Hole</a>) on the DS218play and the answer is always the same - unsupported, not available, you&rsquo;re out of luck, you will need to upgrade to the <em>plus</em> model (which uses x86 CPUs) or get a Raspberry Pi.</p>
<p>That is not entirely true, though, and that&rsquo;s why you&rsquo;re likely here. The setup requires a little bit of technical skills and bravery, but it is not an overly complicated process. It does need to be said though that <strong>the Docker support is indeed unofficial, one could even say hacky, and you are doing this at your own risk</strong>. On the upside, the Realtek RTD1296 CPU in the DS218play is perfectly capable of running a simple app such as Pi-hole in Docker (the CPU barely registers usage from multiple local network devices), and can probably run even more complex apps, so the argument related to the CPU&rsquo;s performance is not entirely based on reality - it probably has more to do with Synology not wanting to maintain packages for multiple architectures, especially if moving to the + line is such a good upsell for them.</p>
<p>Also, while I can give you no guarantees on this, the how-to is likely to work on some other Synology models (such as DS220j, DS223j, DS118, DS218, DS418 - basically anything that has <em>aarch64</em> CPU model listed <a href="https://nascompares.com/2020/03/02/plex-synology-nas-performance-list-2020-edition/" target="_blank" rel="noopener">here</a>). Furthermore, based on my cursory Google research, changing the architecture in below scripts from <code>aarch64</code> to <code>armhf</code> might allow you to use it for the ARMv7 models (such as DS218j, DS216j or DS416) as well.</p>
<h2 id="prerequisites">Prerequisites</h2>
<p>OK, now that you have been warned and given necessary context, let&rsquo;s see what we will need:</p>
<ul>
<li>Access to the Synology NAS using a privileged user (can be your regular user but should be in the administrators group - i.e. the main account you use to manage the NAS using DSM</li>
<li>DSM version 7.2.x (tested on 7.2.1, likely works on all 7.x.x)</li>
<li>Enabled SSH access (see below)</li>
<li>Internet access (duh)</li>
<li>An SSH client (<a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/" target="_blank" rel="noopener">PuTTY</a> is a great one if you&rsquo;re on Windows, but you can also <a href="https://www.howtogeek.com/336775/how-to-enable-and-use-windows-10s-built-in-ssh-commands/" target="_blank" rel="noopener">install an ssh client from Windows;</a> Linux and Mac usually comes with a command-line SSH client)</li>
</ul>
<h3 id="enabling-ssh-access-to-your-nas">Enabling SSH access to your NAS</h3>
<p>Your Synology NAS may not have a remote terminal access enabled. This is how you enable it:</p>
<ol>
<li>Open <strong>Control Panel</strong>.</li>
<li>Go to <strong>Terminal &amp; SNMP</strong>.</li>
<li>Check the <strong>Enable SSH service</strong> checkbox.</li>
<li>Done!</li>
</ol>
<p>In case the port is set to anything else than the usual port 22, you should make a mental note of that number.</p>
<h2 id="step-by-step-instructions">Step-by-step instructions</h2>
<h3 id="connecting-and-gaining-root-access">Connecting and gaining root access</h3>
<ol>
<li>Use your SSH client to connect to the NAS. You will need to specify the NAS&rsquo;s IP Address - if you do not know it, you can find it out in <strong>Control Panel</strong> → <strong>Network</strong> → <strong>Network Interface</strong>. Mine is 192.168.0.101 and let&rsquo;s say the main user account is &ldquo;tom&rdquo;.</li>
</ol>
<p><code>ssh tom@192.168.0.101 </code><br>
If you are using a different port than 22, add the <code>-p</code> parameter, e.g.:<br>
<code>ssh tom@192.168.0.101 -p 22345</code> <br>
2. You might be prompted to accept the host&rsquo;s key the first time you connect. Accept it.<br>
3. Now enter the password for tom&rsquo;s account - this is the same as you use to log in into DSM using your browser.<br>
4. Now you should be remotely connected to your NAS, but we need to get the system administrator (<code>root</code>) privileges. On DSM, simply type <code>sudo -i</code>  and use the same password as in step 3.<br>
5.  Now the command line should say something like <code>root@nas</code> (or whatever hostname you chose after the @ sign).</p>
<h3 id="docker-installation">Docker installation</h3>
<ol>
<li>Navigate to you main user&rsquo;s home directory.<br>
<code>cd /volume1/homes/tom/</code><br>
Note that you will need to adjust the username and potentially the volume number based on your system&rsquo;s settings.</li>
<li>Grab the file below and save it to your desktop computer. Let&rsquo;s call the file <code>get-docker.sh</code></li>
</ol>
<pre tabindex="0"><code>#!/bin/bash
set -e

ARCH=aarch64
DOCKER_VERSION=20.10.9
COMPOSE_VERSION=2.5.1
DOCKER_DIR=/volume1/@docker

echo &#34;Downloading docker $DOCKER_VERSION-$ARCH&#34;
curl &#34;https://download.docker.com/linux/static/stable/$ARCH/docker-$DOCKER_VERSION.tgz&#34; | tar -xz -C /usr/local/bin --strip-components=1

echo &#34;Creating docker working directory $DOCKER_DIR&#34;
mkdir -p &#34;$DOCKER_DIR&#34;

echo &#34;Creating docker.json config file&#34;
mkdir -p /usr/local/etc/docker
cat &lt;&lt;EOT &gt; /usr/local/etc/docker/docker.json
{
  &#34;storage-driver&#34;: &#34;vfs&#34;,
  &#34;iptables&#34;: false,
  &#34;bridge&#34;: &#34;none&#34;,
  &#34;data-root&#34;: &#34;$DOCKER_DIR&#34;
}
EOT

echo &#34;Creating docker startup script&#34;
cat &lt;&lt;&#39;EOT&#39; &gt; /usr/local/etc/rc.d/docker.sh
#!/bin/sh
# Start docker daemon

NAME=dockerd
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS=&#34;--config-file=/usr/local/etc/docker/docker.json --pidfile=$PIDFILE&#34;

case &#34;$1&#34; in
    start)
        echo &#34;Starting docker daemon&#34;
        # ulimit -n 4096  # needed for influxdb (uncomment if your limit is lower)
        /usr/local/bin/dockerd $DAEMON_ARGS &amp;
        ;;
    stop)
        echo &#34;Stopping docker daemon&#34;
        kill $(cat $PIDFILE)
        ;;
    *)
        echo &#34;Usage: &#34;$1&#34; {start|stop}&#34;
        exit 1
esac
exit 0
EOT

chmod 755 /usr/local/etc/rc.d/docker.sh

echo &#34;Creating docker group&#34;
egrep -q docker /etc/group || synogroup --add docker root

echo &#34;Installing docker compose $COMPOSE_VERSION&#34;
curl -SL &#34;https://github.com/docker/compose/releases/download/v$COMPOSE_VERSION/docker-compose-linux-$ARCH&#34; \
     --create-dirs -o /usr/local/lib/docker/cli-plugins/docker-compose
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
chgrp -R docker /usr/local/lib/docker

echo &#34;Starting docker&#34;
/usr/local/etc/rc.d/docker.sh start

echo &#34;Done.  Please add your user to the docker group in the Synology GUI and reboot your NAS.&#34;
</code></pre><p><a href="https://gist.github.com/DaveMDS/c35d77e51e0186a4fe2e577f51a5b09a" target="_blank" rel="noopener">Credits to DaveMDS</a> <br>
_Note: The versions of Docker and Docker Compose might be outdated when you read this. If you want to use the the latest versions, check them <a href="https://download.docker.com/linux/static/stable/aarch64/" target="_blank" rel="noopener">here</a> and <a href="https://github.com/docker/compose/releases" target="_blank" rel="noopener">here</a>.  _</p>
<ol>
<li>Upload the <code>get-docker.sh</code> file to your home folder in DSM: Open <strong>File Station</strong>, navigate to your home, click on <strong>Upload</strong> and the <strong>Upload - Overwrite</strong>.</li>
<li>Now back to SSH terminal - make the script executable:<br>
<code>chmod +x ./get-docker.sh</code></li>
<li>Run the installation script:<br>
<code>./get-docker.sh</code></li>
<li>Docker should now be installed! Let&rsquo;s follow the instruction to add our user to the docker group: go to <strong>Control Panel</strong> → <strong>User &amp; Group</strong> → <strong>Group</strong> → select <code>docker</code> → <strong>Edit</strong> → <strong>Members</strong> → select the checkbox next to <code>tom</code> (your main user) → <strong>Save</strong>.</li>
<li>Reboot your NAS!</li>
</ol>
<h3 id="installing-pi-hole">Installing Pi-Hole</h3>
<ol>
<li>While your NAS rebooted, your SSH session got disconnected, so you will need to repeat steps from the above section <strong>Connecting and gaining root access</strong>.</li>
<li>Using the same process as with the <code>get-docker.sh</code> file, upload the below script and name it <code>install-pihole.sh</code>. Do not forget to change the value of the PIHOLE_PWD variable.</li>
</ol>
<pre tabindex="0"><code>#!/bin/bash

IP_ADDRESS=$(ifconfig eth0 | awk &#39;/inet addr/ {gsub(&#34;addr:&#34;, &#34;&#34;, $2); print $2}&#39;)
TZ=$(realpath --relative-to /usr/share/zoneinfo /etc/localtime)
PORT=8080
PIHOLE_PWD=&#34;piholepwd&#34;

PIHOLE_BASE=&#34;${PIHOLE_BASE:-$(pwd)}&#34;
[[ -d &#34;$PIHOLE_BASE&#34; ]] || mkdir -p &#34;$PIHOLE_BASE&#34; || { echo &#34;Couldn&#39;t create storage directory: $PIHOLE_BASE&#34;; exit 1; }

echo -e &#34;Setting up pihole container at ${IP_ADDRESS}:${PORT} (timezone ${TZ})&#34;

docker run -d --name=pihole \
-e WEB_PORT=$PORT \
-e WEBPASSWORD=$PIHOLE_PWD \
-e WEB_BIND_ADDR=$IP_ADDRESS \
-e TZ=$TZ \
-e DNSMASQ_USER=root \
-e DNSMASQ_LISTENING=local \
-v /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d \
-v /volume1/docker/pihole/pihole:/etc/pihole \
--net=host \
--restart always \
pihole/pihole

printf &#39;Starting up pihole container &#39;
for i in $(seq 1 20); do
    if [ &#34;$(docker inspect -f &#34;{{.State.Health.Status}}&#34; pihole)&#34; == &#34;healthy&#34; ] ; then
        printf &#39; OK&#39;
        echo -e &#34;\nPi-hole running at http://${IP_ADDRESS}:${PORT}/admin/ - use password &#39;${PIHOLE_PWD}&#39; to log in.&#34;
        exit 0
    else
        sleep 3
        printf &#39;.&#39;
    fi

    if [ $i -eq 20 ] ; then
        echo -e &#34;\nTimed out waiting for Pi-hole start, consult your container logs for more info (\`docker logs pihole\`)&#34;
        exit 1
    fi
done;
</code></pre><p>The script was adapted from the <a href="https://github.com/pi-hole/docker-pi-hole/blob/master/examples/docker_run.sh" target="_blank" rel="noopener">official pi-hole example</a>.</p>
<ol>
<li>Run the Pi-hole installation script (assuming you&rsquo;re in the main user home directory again):<br>
<code>./install-pihole.sh</code></li>
<li>Downloading and setting up the pihole container may take some time. Once it is done, you should see a message like this:<br>
<code>Pi-hole running at http://192.168.0.101:8080/admin/ - use password 'piholepwd' to log in.</code></li>
<li>If everything went well, navigating to <code>http://192.168.0.101:8080/admin</code> should lead you to the Pi-Hole login screen. Success!</li>
<li>Do not forget to configure your NAS&rsquo;s IP address as the DNS server for your network - this would typically be done in the router settings, for example <a href="https://docs.pi-hole.net/routers/asus/" target="_blank" rel="noopener">like so</a>.</li>
</ol>
<h2 id="additional-considerations">Additional considerations</h2>
<ul>
<li>Since Pi-hole is now the sole resource for DNS resolution, it becomes a critical part of your network infrastructure. If the NAS or Pi-Hole itself stops working or gets disconnected, none of the clients on your network will be able to connect to the internet. This can be easily fixed by rebooting/reconnecting your NAS or simply reverting the router DNS settings to default or, for example, to Cloudflare&rsquo;s 1.1.1.1 DNS server, but you can only do that if you are physically at home (or have other means of connecting to your router).
<ul>
<li>To prevent my loved ones from undergoing the terrible torture of not having access to the internet when I&rsquo;m not at home (and also for general peace of mind), I decided to build redundancy into my Pi-Hole setup: I bought a super-cheap used Raspberry Pi 2 and added it as another Pi-Hole to my home network. I actually use the RPi2 as my primary DNS server and the NAS one as the secondary one (most routers will allow you to specify two DNS servers for your WAN), and have not had any issues with this setup so far. Knock on the wood.</li>
<li><strong>Tip:</strong> Use the <a href="https://engineerworkshop.com/blog/avoid-disaster-how-to-securely-backup-your-pihole-configuration-and-keep-your-network-running-smoothly/" target="_blank" rel="noopener">Teleporter</a> feature to easily sync settings between the two Pi-Holes.</li>
</ul>
</li>
<li>The setup above persists even through NAS reboots (docker will start automatically, and so will Pi-Hole), and it also survives DSM patches (7.2.x), but I have yet to test whether it survives minor updates (7.x.x). I will update this article with my findings once I have an opportunity to test it.
<ul>
<li>My hunch is that minor updates will be fine, but I am fairly certain that a major update (to DSM8) will likely need a docker reinstall. However, since the scripts are stored in my home folder, SSHing to the NAS and running them again will be minimal effort, should any of the DSM updates disrupt the setup.</li>
</ul>
</li>
</ul>
<h2 id="support-pi-hole">Support Pi-Hole!</h2>
<p>Pi-Hole is a wonderful project that objectively improves the digital life of many people. If it is the case for you, consider <a href="https://pi-hole.net/donate/#donate" target="_blank" rel="noopener">supporting the creators</a> - surely your privacy on the internet is worth a donation of few bucks.</p>
]]></content:encoded></item></channel></rss>