How to Setup Pi-hole on a Synology NAS
Having redundant DNS servers is very important. It is suggested that you configure Pi-hole on a spare raspberry pi and have two Pi-hole DNS servers. This will ensure that when your NAS is rebooted, your clients do not lose DNS resolution services.
1. Initial Steps
These steps need to be performed for either install, so we will get these steps out of the way first.
1. Install Docker from Synology’s Package Center.
2. We need to create two folders that we will map our Docker image to. By default, Docker will create a folder named docker after it’s finished installing. Inside of this folder, we are going to create a folder named pihole. Inside of that folder, we are going to create two subfolders. Create one folder named pihole and another folder named dnsmasq.d.
2. Host Network Interface – Synology NAS Pi-hole Setup
As stated above, this option will use the host network interface. For this reason, you will need to access Pi-hole using your Synology NAS’s IP address and a defined port.
3. Open Docker, navigate to the Registry, and search for Pi-hole. Double click Pi-hole/Pi-hole (official Pi-hole docker image) to download it.
4. Select Latest. The image will now download.
5. Double click the Pi-hole image to launch the Docker configuration.
6. Give your container a name, and then select Advanced Settings. NOTE: If you intend on using Pi-hole for DHCP, you need to check Execute container using high privilege.
7. We now need to configure the Advanced Settings.
- Check off Enable auto-restart.
- In the Volume section, we need to map the folders we created to the internal Docker Pi-hole locations. Select Add Folder and add the dnsmasq.d folder and type the mount path as /etc/dnsmasq.d. Do the same for the pihole folder with the mount path as /etc/pihole.
- Under Network, select Use the same network as Docker Host.
- Navigate to the Environment section. We will need to add a few variables.
- Click the + sign and add these variables:WEBPASSWORD: password that you’d like to access the admin portal with.
- WEB_PORT: The port you’d like to access the admin portal with. This needs to be something that’s not used. Generally, something in the 8000’s should be fine.
- DNSMASQ_LISTENING: local
- ServerIP: This already exists. Change this to the IP address of your NAS.
8. Click Apply to create the Pi-hole docker container.
9. Since you are using your host network interface, you will have to open port 53 and the “WEB_PORT” you selected above (8888 is what I used) on your Synology firewall. This is the default DNS port and the port for the Pi-hole web portal.
10. Open the Control Panel and navigate to Firewall. Select Edit Rules.
11. Create a rule with the custom port that you defined above. The protocol can be left as TCP.
12. Create a rule with the DNS port which is 53. Under protocol, select All.
13. Ensure the rules are above your Deny All rule.
14. You should now be able to access Pi-hole using this web address: http://[NAS IP_ADDRESS]:[WEB_PORT]/admin
15. The installation process is now complete. Navigate to the DNS Configuration section to complete the configuration process.