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


#81

Please run

sudo grep -c ^ /etc/pihole/list.6.hosts-file.net.domains

It gives me:

47984

#82

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


#83

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


#84

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


#85

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.


#86

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.


#87

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 https://help.evernote.com/hc/it 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 ?
TIA


#88

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 Evernote.com but marketwatch.com (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.


#89

Did you try to restart dnsmasq ?


#90

Wow, that was easy. Thanks!


#91

I have a error,
After doing this :
cd;wget https://gist.githubusercontent.com/bakman2/dcfe3fdfd02c9ff8326bbf35da539f27/raw/0c59b7b62b0d351276895744e6d0750c8baf5be5/gistfile1.txt

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

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

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


#92

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.


#94

That is why you needed to exit chroot first.


#95

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.
root@DiskStation:/#

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?


#96

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
else
service dnsmasq start
fi

}`

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.


#97

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.)


#98

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


#99

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


#100

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.


#101

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