How do I install Pi-hole on a Synology NAS?


Please run

sudo grep -c ^ /etc/pihole/

It gives me:


I don’t have this file, just reinstalled pihole.


Ok, so since you don’t have it cached you’ll just have to wait until the list comes back online.


no question, just wanted to say that your instructions were clear and easy to follow. everything is working as expected, thank you!


The new code has been implemented so between that and the Original Post author’s instructions and fixes there should be no further problems with the firewall installation.


Succesfully updated from 2.11 and web interface 2.3 to 2.11.2 with webinterface 2.3.1

No hassle.

Login with ssh: ssh admin@diskstation-ip
sudo su -
/var/packages/debian-chroot/scripts/start-stop-status chroot
pihole -up

That’s all. No issues.


A couple of questions…

After a Synology firmware update I could not reach the web interface. So I logged in and updated first the Debian system, then the PiHole … still no luck.
I then realized that the lighttpd.conf file was issueing :80 as the port, so I modify it to my value and restarted it (alongside with dnsmasq). Now everything seemed to be ok.

Moments after I found that was not reachable (I was given a “Synology” error page). Added the domain to the whitelist from the web interface == no luck, added it via CLI and the web interface showed it in the ‘good guys’ … still I cannot read the domain.

Any ideas on why all that happened ?


Same experience on both fronts:

Fixed the admin console not showing up after an up date by re-adding the correct port to lighttpd.conf and restarting lighttpd.

For me, it wasn’t but (a site I visit once a day or so) that is giving the Synology message. Not in the blacklist, and adding to the whitelist didn’t make a difference. Very odd.


Did you try to restart dnsmasq ?

1 Like

Wow, that was easy. Thanks!


I have a error,
After doing this :

mv gistfile1.txt /usr/local/etc/rc.d/

mv: cannot move ‘gistfile1.txt’ to ‘/usr/local/etc/rc.d/’: No such file or directory

I tried sudo nano /usr/local/etc/rc.d/ and added the text manually but when I save I have
[ Error writing /usr/local/etc/rc.d/ No such file or directory ]


I ran into the same issue kevincork. It needed 2x ‘exit’ for me. My prompt changed from root@ to ash-4.3#
With that prompt I was able to install the script and the directory /usr/local/etc/rc.d/ is available.

I haven’t restarted my Synology yet to test though, but if I execute the script manually, the services are restarted.


That is why you needed to exit chroot first.


Setup DS212+ DSM 6 with chroot package.

When I select disable in the webinterface. The pi-hole service is not disabled.
When I use the cli in chroot (on my Synology): “pihole disable” I get:

root@DiskStation:/# pihole disable
::: Blocking has been disabled!
Running in chroot, ignoring request.

So the request is ignored. Which is very annoying.Anyone with the same issue? And is there an easy solution to enable/disable pihole using the webinterface?


The thing is: pihole checks if systemctl is being used and if yes execute systemctl:

if [ -x "$(command -v systemctl)" ]; then

In chroot this validates as true, but systemctl should/cannot not be used in chroot, service dnsmasq restart should be used instead.

If you change the restartDNS() function in /usr/local/bin/pihole to:

`restartDNS() {
dnsmasqPid=$(pidof dnsmasq)
if [[ ${dnsmasqPid} ]]; then
service dnsmasq restart
service dnsmasq start


You can use the webinterface and commandline as well.

Or if you don’t want to change it (as it will break upon updates) you can use:

pihole disable service dnsmasq restart

A more permanent solution could be to implement a detection of chroot, but remember that pihole is for a raspberry pi, nothing else.

Performing a ls -id / with an output anything else than 2 would mean a chrooted environment.


Open a GitHub issue or PR some code for use to check over and we can see if it can be included in the mainline release for environment detection. (Excuse the terseness, on mobile ATM.)

1 Like

Thanks bakman2, I changed the code and all working great.


We actually support most installs of Debian and centos/Fedora.


Got this working beautifully and without much fuss. I appreciate these instructions being shared!

The only bump that I had was similar to @johnny2678 where after entering chroot, apt-get wasn’t present. Turns out that the installation of Debian Chroot runs debootstrap in the background after the installation is complete, which provides apt-get and other various necessary tools.

After installing chroot and entering it, run ps aux and if you see the following processes…

root 30894 0.0 0.2 3040 560 ? S 08:25 0:00 /bin/sh /var/packages/debian-chroot/scripts/postinst
root 30896 0.0 0.2 1552 620 ? S 08:25 0:00 /bin/sh /debootstrap/debootstrap --second-stage

You should probably wait until they’re complete to ensure your new chroot environment is consistent. This took about six minutes on a DS214se running DSM 6.1-15047.

1 Like

I stuck here:
root@_HDD:/# nano /etc/lighttpd/lighttpd.conf
Then this file appear empty and when I try to add server.port = 1024 and save got bellow error
Error writing /etc/lighttpd/lighttpd.conf: No such file or directory

And also this:
root@_HDD:/# crontab /etc/cron.d/pihole
/etc/cron.d/pihole: No such file or directory
root@s_HDD:/etc/cron.d# crontab -l
no crontab for root

Any help appreaciated