How to Install Pi-Hole on Your Synology NAS

How to Install Pi-Hole on Your Synology NAS

Pi-Hole is a Linux network-level advertisement and Internet tracker blocking application which acts as a DNS sinkhole (and, optionally, a DHCP server), intended for use on a private network. What is a DNS sinkhole? A DNS sinkhole, also known as a sinkhole server, Internet sinkhole, or Blackhole DNS is a DNS server that gives out false information, to prevent the use of a domain name. It is designed for use on embedded devices with network capability, such as the Raspberry Pi, but it can be used on other machines running Linux like Synology NAS and cloud implementations. Pi-Hole has the ability to block traditional website adverts as well as adverts in unconventional places, such as smart TVs and mobile operating system adverts.

💡Note: This guide works perfectly with the latest version of Pi-Hole v5.18.2 and DSM 7.2.1

đź’ˇNote: Check out my new guide on how to Install Pi-Hole Using Portainer.

I’m not a fan of applications like Pi-hole because Ad blocking software is leading to ‘the slow death of niches’ like my website. Ad blockers are white flagging Google, Amazon, Facebook and other Internet giants, but what about the small and medium publishers whose livelihood depends on ad revenues? Where is the morality in this? Anyway, my blog has no ads. See below my step by step guide on how to install Pi-Hole on your Synology NAS device. If you prefer AdGuard over Pi-Hole read my step by step guide on How to install AdGuard on your Synology NAS using docker.

  • STEP 1

Please Support My work by Making a Donation.

  • STEP 2

Install Container Manager via Synology “Package Center”. If you run an older DSM version (under 7.2), search for Docker instead of Container Manager.

Download Container Manager Synology Docker

  • STEP 3

Add Google DNS. Go to Control Panel / Network / General. Check “Manually configure DNS server” and add on Preferred DNS Server: 8.8.8.8 and on Alternative DNS Server: 8.8.4.4 Click Apply. Follow the instructions in the image below.

Pi-hole Synology NAS Set up 1 new 2024

  • STEP 4

Go to File Station and open the docker folder. Inside the docker folder, create one new folder and name it pihole. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Pi-hole Synology NAS Set up 2 new 2024

  • STEP 5

Now create two new folders inside the pihole folder that you previously created at STEP 4 and name them dnsmasq.d and pihole. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Pi-hole Synology NAS Set up 3 new 2024

  • STEP 6

Go to Control Panel / Task Scheduler / Create / Scheduled Task / User-defined script. Follow the instructions in the image below.

Pi-Hole Synology Task Scheduler

  • STEP 7

Once you click on User-defined script a new window will open. Follow the instructions below:

  1. General: In the Task field type in “Install Pi-hole“. Uncheck “Enabled” option. Select root User.
  2. Schedule: Select Run on the following date then select “Do not repeat“.
  3. Task Settings: Check “Send run details by email“, add your email then copy paste the code below in the Run command area. After that click OK.
docker run -d --name=pihole \
-e WEB_PORT=8080 \
-e WEBPASSWORD=mariushosting \
-e WEB_BIND_ADDR=192.168.1.18 \
-e TZ=Europe/Bucharest \
-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

Note: Before you paste the code above in the Run command area below, change the value for WEBPASSWORD and add your own password. mariushosting is an example for a password, you should use your own password.
Note: Before you paste the code above in the Run command area below, change the value for WEB_BIND_ADDR and add your own Synology NAS Local LAN IP. 192.168.1.18 is my NAS local LAN IP, you should use your own NAS local LAN IP.
Note: Before you paste the code above in the Run command area below, change the value for TZ. (Select your current Time Zone from this list.)

Pihole Synology NAS Set up 5.17 new 2024

  • STEP 8

After you click OK on STEP 7 a new warning pop up window will open. Click OK.

Pihole Synology NAS Set up 5.17 new2 2024

After you click OK, type in your DSM Password then click Submit. Follow the instructions in the image below.

Synology Task Scheduler Confirm Admin Password

  • STEP 9

After you click Submit on STEP 8, select your “Install Pi-hole” Task then click the “Run” tab. You will be asked to run Install Pi-hole – click OK. Follow the instructions in the image below.

Pihole Synology NAS Set up 5.17 new3 2024

  • STEP 10

Go back to STEP 1 or you will deal with karma 🙂

  • STEP 11

The installation process can take up to a few seconds/minutes. It will depend on your Internet speed connection. Now open your browser and type in http://Synology-ip-address:8080/admin/login.php Type in the password you have previously created at STEP 7. Click Log in. Follow the instructions in the image below.

Pihole Synology NAS Set up 8 5.17

Enjoy your Pi-hole! Set it up according to your preference.

Pi-hole Synology NAS Set up 5.18.2

If you have Portainer installed on your Synology NAS you can also see the Pi-hole container perfectly running with the healthy status.

Pihole healthy container in Portainer

  • STEP 12

Download (click on the blue link below) to download the Pi-Hole Macvlan Docker Compose. Advantages For Pi-Hole with Macvlan: Works well with NAS devices or hard port conflicts. A Macvlan network is the most advanced option since it requires more network knowledge and setup. This mode is similar to host network mode but instead of borrowing the IP of your docker host computer it grabs a new IP address off your LAN network. đź”’Note: Support my work to unlock the password. You can use this password to download any file on mariushosting forever!

👉🏻Pi-Hole Docker Compose Macvlan.txt

That’s it! I hope this little guide helps you install Pi-hole on your Synology NAS.

Note: Many content providers (like YouTube / Reddit / Twitch / Spotify / Pandora / Facebook / Hulu) now stream/serve ads from the same servers as the content (meaning if you attempt to block the ads using a Pi-Hole you will also block the content). If you want to view YouTube without Adverts content, just use Piped or Invidious.
Note: Use Pi-Hole As DNS on Windows 11.
Note: How to Activate Dark Mode in Pi-Hole.
Note: Mandatory is to upgrade your Synology NAS RAM memory. Why do you need more RAM? To be more responsive! You will not use Synology NAS just for Docker. Pi-hole needs a minimum of 512 MB of RAM (I repeat, a minimum and that’s just for Pi-hole). If anyone wants to stay within the strict minimum RAM, they are welcome to, but their system will never be as responsive as those which have more RAM installed.
Note: How to Free Disk Space on Your NAS if You Run Docker.
Note: Some people may have problems launching Pi-Hole via Docker. This may be because of different settings in your Synology NAS and router. Every user has their own router settings etc. It’s really hard to troubleshoot the problem. You can also contact me via email and I will try to find a personalized solution for you.
Note: After installing Pi-hole (through Docker), Synology NAS drives are not hibernating at all. The best solution is to Disable Hibernation. This will be easier and much more beneficial overall for everything Pi-hole needs to read database of filters.
Note: Find out how to update Pi-Hole container with the latest image.

Fix: Pihole 403 Forbidden. If you want to use Pi-Hole with Synology Reverse Proxy, add your DDNS like you did until now, with WebSocket, then access Pi-Hole in your browser using pihole.yourname.synology.me/admin/login.php At the end of your own domain name or DDNS just add /admin/login.php
Fix: If someone has a problem once installation is completed, and gets an error like “This site can’t be reached“, open the Pi-hole GUI and go to Settings / DNS tab and in “Interface listening behavior” change to Listen on all interfaces instead of Listen only on interface eth0. (Reported by jtd).
Fix: If your Pi-hole container keeps disconnecting, uninstall the Synology Package named “DNS Server” or “DHCP Server” which conflicts with Pi-hole on port 53 and doesn’t let your Pi-hole start.
Fix: If you get an error in Pi-hole that says Lost connection to API, restart your Pi-Hole container in Docker or Container Manager. (Reported by Arjan).

Pi-hole Lost Connection to the API
Fix: If your Pi-hole container gets a DNS service not running, uninstall the Synology Package named “DNS Server” or “DHCP Server” which conflicts with Pi-hole on port 53 and doesn’t let your DNS work.
Fix: If you experience connections problems, remember to set your Synology Firewall in Control Panel / Security / Firewall / Edit Rules / Create Firewall Rules and allow Custom Port 53 Protocol All.
Fix: If you can’t play videos from CNN, in the PiHole whitelist add the following address: c.amazon-adsystem.com
Fix: How can I make Pi-Hole work over VPN connection? Go to Pi-Hole / Settings / DNS tab / Interface Settings / choose Permit all origins the scroll down the page all the way and click Save. Follow the instructions in the image below.

Pihole Synology VPN permit all origins

Fix: If you want to run the DHCP server on docker with pi-hole, just add the cap-admin directive as per the instructions below.

docker run -d --name=pihole \
-e WEB_PORT=8080 \
-e WEBPASSWORD=mariushosting \
-e WEB_BIND_ADDR=192.168.1.18 \
-e TZ=Europe/Bucharest \
-e DNSMASQ_USER=root  \
-e DNSMASQ_LISTENING=local \
-v /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d \
-v /volume1/docker/pihole/pihole:/etc/pihole \
--cap-add=NET_ADMIN \
--net=host \
--restart always \
pihole/pihole

Note: Can I run Docker on my Synology NAS? See the supported models.
Note: How to Back Up Docker Containers on your Synology NAS.
Note: At STEP 7 you can also change the value variable for the: WEB_PORT – 8080 to 1010 or whatever you want.
Note: How to Schedule Start & Stop For Docker Containers.
Note: How to Activate Email Notifications.
Note: How to Add Access Control Profile on Your NAS.
Note: How to Change Docker Containers Restart Policy.
Note: How to Use Docker Containers With VPN.
Note: Convert Docker Run Into Docker Compose.
Note: How to Clean Docker.
Note: How to Clean Docker Automatically.
Note: Best Practices When Using Docker and DDNS.
Note: Some Docker Containers Need WebSocket.
Note: Find out the Best NAS Models For Docker.
Note: Activate Gmail SMTP For Docker Containers.

This post was updated on Wednesday / April 3rd, 2024 at 8:22 PM