How do I install Pi-hole on a Synology NAS
This is a basic functional installation, it does not take into account any special servers/services that you may have running on your DSM. This was done succesfully on DSM 5.2-5967 and DSM 6.0.2-8451 Update 2. It uses Debian chroot to run Pi-hole and should take less than 30 minutes to install.
- Add source: Package Center > Settings > Package Sources > add: http://packages.synocommunity.com/
- In Package Center > Community > Install Debian Chroot
Open a terminal/use putty, ssh to your NAS
On the command line, make sure you are root.
In DSM 6 use
sudo su -
Login with your admin password:
/var/packages/debian-chroot/scripts/start-stop-status start /var/packages/debian-chroot/scripts/start-stop-status chroot
You may receive a locale error, can be ignored - the prompt should have changed.
Now you are on the chroot prompt, which enables you to install many packages that are available for Debian.
Enter one by one:
apt-get update apt-get upgrade apt-get install locales sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && locale-gen
This may take a while (5-10 minutes depending on CPU speed)
dpkg-reconfigure tzdata apt-get install curl mount /proc cat /proc/mounts > /etc/mtab
This is to fix a filesystem issue.
curl -L https://install.pi-hole.net | bash
Just follow the steps…
The Pi-hole webserver runs on port 80, which is usually already occupied by the webserver, so we need to modify the webserver config:
server.port = xxxx to a suitable port (higher than 1023)
ctrl+x to save
crontab /etc/cron.d/pihole crontab -l
Verify that you see several entries for pihole.
sudo service cron restart sudo service lighttpd restart sudo service dnsmasq restart
This will restart the webserver, dnsmasq and cron with the new config.
Now you should be able to access it with your browser on
If you see the admin page of Pi-hole you can modify your devices: change the DNS IP address to the NAS IP.
Autostart after reboot
As nothing in chroot is started automatically we need to make a startup script that survives a reboot:
exit (from chroot - should still be root)
Retrieve the RC script - in this file it is assumed that you use
cd;wget https://gist.githubusercontent.com/bakman2/dcfe3fdfd02c9ff8326bbf35da539f27/raw/c177d818b878ab2ee5c7de54af35116e0ded2a37/gistfile1.txt mv gistfile1.txt /usr/local/etc/rc.d/S99pihole.sh chmod +x /usr/local/etc/rc.d/S99pihole.sh
Test the script:
If succesful, pi-hole and all the services should automatically start after a reboot.
If pi-hole does not work you can retry the install from chroot
curl -L https://install.pi-hole.net | bash service dnsmasq restart service lighttpd restart
To get into chroot from your dsm you can use
or to enable ssh in chroot, follow this blog post
If you are using dhcp in your network, configure your router to use the DNS on your NAS.
change the webserver port again:
nano /etc/lighttpd/lighttpd.conf - change the port ctrl+x y,enter to save service lighttpd restart service dnsmasq restart