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

Thanks for the quick reply Dan, no here is the full log.

::: You are root.
::: Repair option selected.
::: Verifying free disk space...
:::
::: Updating local cache of available packages... done!
:::
::: Checking apt-get for upgraded packages.... done!
:::
::: Kernel update detected, please reboot your system and try again if your installation fails.
::: Checking for apt-utils... installed!
::: Checking for debconf... installed!
::: Checking for dhcpcd5... installed!
::: Checking for git... installed!
::: Checking for iproute2... installed!
::: Checking for whiptail... installed!
::: --reconfigure passed to install script. Not downloading/updating local repos
::: Checking for bc... installed!
::: Checking for cron... installed!
::: Checking for curl... installed!
::: Checking for dnsmasq... installed!
::: Checking for dnsutils... installed!
::: Checking for iputils-ping... installed!
::: Checking for lsof... installed!
::: Checking for netcat... installed!
::: Checking for sudo... installed!
::: Checking for unzip... installed!
::: Checking for wget... installed!
::: Checking for lighttpd... installed!
::: Checking for php5-common... installed!
::: Checking for php5-cgi... installed!
:::
::: Installing scripts from /etc/.pihole... done.
:::
::: Installing configs from /etc/.pihole...
::: Existing dnsmasq.conf found... it is not a Pi-hole file, leaving alone!
::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf... done.
:::
::: Creating log file and changing owner to dnsmasq... already exists!
:::
::: Installing pihole custom index page...
::: Existing index.php detected, not overwriting
::: Existing index.js detected, not overwriting
::: Existing blockingpage.css detected, not overwriting
:::
::: Installing sudoer file... done!
:::
::: Installing latest Cron script... done!
:::
::: Installing latest logrotate script... done!
:::
::: Downloading latest version of FTL...
::: Detected x86_64 architecture
::: Installing FTL... transferred... done.
::: Restarting services...
:::
::: Starting dnsmasq service... done.
:::
::: Enabling dnsmasq service to start on reboot... done.
:::
::: Starting lighttpd service... done.
:::
::: Enabling lighttpd service to start on reboot... done.
:::
::: Preparing to run gravity.sh to refresh hosts...
::: Cleaning up previous install (preserving whitelist/blacklist)
::: Running gravity.sh
:::
::: Neutrino emissions detected...
:::
::: Pulling source lists into range... done!
:::
::: Getting raw.githubusercontent.com list... done
::: Status: Success (OK)
::: List updated, transport successful!
::: Getting mirror1.malwaredomains.com list... done
::: Status: Success (OK)
::: List updated, transport successful!
::: Getting sysctl.org list... done
::: Status: Success (OK)
::: List updated, transport successful!
::: Getting zeustracker.abuse.ch list... done
::: Status: Success (OK)
::: List updated, transport successful!
::: Getting s3.amazonaws.com list... done
::: Status: Success (OK)
::: List updated, transport successful!
::: Getting s3.amazonaws.com list... done
::: Status: Success (OK)
::: List updated, transport successful!
::: Getting hosts-file.net list... done
::: Status: Success (OK)
::: List updated, transport successful!
:::
::: Aggregating list of domains... done!
::: Formatting list of domains to remove comments.... done!
::: 128379 domains being pulled in by gravity...
::: Removing duplicate domains.... done!
::: 104740 unique domains trapped in the event horizon.
:::
::: Adding adlist sources to the whitelist... done!
::: Whitelisting 6 domains... done!
::: Blacklisting 1 domain... done!
::: No wildcards used!
::: Formatting domains into a HOSTS file... done!
:::
::: Cleaning up un-needed files... done!
:::
::: Refresh lists in dnsmasq...Running in chroot, ignoring request.
done!
::: DNS service is running
::: Pi-hole blocking is Enabled
:::
::: Starting pihole-FTL service... done.
:::
::: Enabling pihole-FTL service to start on reboot... done.
::: done.
:::
::: Update complete!
:::

Yeah, that's showing the chroot problems that we've seen. There is a discussion that we have had on how to account for knowing if the install is rooted, as it is any call to systemctl is ignored since the init inside the jail doesn't handle it fully.

Righto, is this to do with what version of DSM we are running? Seeing as some comments just say "followed the instructions, all working fine"

I don't believe its version related, but more of the chroot environment. I don't have access to a device to fully test out so I'm going by what appears to be happening and what others that have way more knowledge than I have stated.

From your chroot environment try

service dnsmasq restart

Thanks Bakman 2, But tried this (individually) and restarting the script many times.

This is what I get once I log in.

i have Pi-hole running on my NAS for some time now, but since its installed, it never stops the hdds from spinning. Is there a way to let them stop? We dont use the the NAS very frequently, its more like a Backup Storage, so there is no reason for the drives to spinn all the time. Has someone here experience with this and can help me?

Unlikely. Pi-hole writes each query in the logfile, will need disks for that. If you want to avoid it - get a Pi and install Pi-Hole on it.

What are the responses when you restart the services from the cli ?
What output does this give from chroot:

ps -ef | egrep 'lighttpd|dnsmasq|pihole' | grep -v grep

Thats bad news. Could it be possible to change the location of the logfile to the onboard storage? It seems protectet, but whats about packets, are they stored on the hdds?

I would humbly like to request to update your original post with the info which services are absolutely needed when using your how-to, e.g. dnsmasq and lighttpd. without those services, a normal synology NAS user fails pi-hole installation each and every time.

1 Like

Its possible to move Logs on USB flash drive to prevent HDD to spin when they are not in use?

Excellent article. I am just stuck at this line. At first this line brought an empty file which made me think lighttpd wasn't configured in my DiskStation. Surely enough, when I tried

service lighttpd restart

it said, unrecognised service.

Any ideas please?

Edit: Silly me. I did apt-get install lighttpd.

After installing lighttpd which wasn't installed before, I ran into another issue. The local was set to AU but that caused Pi-Hole to not install the UI for some reason. I ran dpkg-reconfigure locales and reinstalled Pi-Hole which then managed to install the UI.

I still have an issue where the block page does not load when I go to 888.com for example it shows the DiskStation page. I can confirm Pi Hole runs okay using its designated port 1111.

Anyone run Pi-hole on DS216j?

I've been trying to free up the port 80 in my Synology Disksation DS414 for the past 24 hours. Has anybody had any luck doing this?

What do you mean with "trying to free up"?

I managed!

I did not like the way my custom port in lighttpd wasn't going to be saved with new ph updates.
I then attempted to follow the article at http://tonylawrence.com/post/unix/synology/freeing-port-80/ to free up port 80.

Under admin@DiskStation:
I did not have an editor to edit the files you mentioned. There was no nano. Nano was under root@DiskStation.
Once I did: sudo /var/packages/debian-chroot/scripts/start-stop-status chroot under admin@DiskStation, what I noticed was I lost access to the mustache files you mentioned in your article as I was now under root@DiskStation.

I installed Midnight Commander using the Package Center > Settings > Package Sources.

As admin@DiskStation I then managed to do: sudo /usr/syno/share/nginx/server.mustache etc. to edit the files.

I edited my lighttpd conf file to make use of port 80 and skipped all the steps after the article said Congratulations, you have no freed your port 80.

Now I have a future updates proof Pi-hole without any custom port! :slight_smile:

Thanks again!

Keep in mind that now ads will be requesting whatever you have on port 80, since you can't redirect ports when resolving DNS.