Today we are going to install Pi-hole on OpenMediaVault using Docker and Portainer.
Fortunately, OpenMediaVault makes it very easy to install Docker and Portainer. We will be installing Pi-hole on Portainer and using a macvlan network interface so that we don’t have any port conflicts with our OpenMediaVault instance. If you haven’t installed OpenMediaVault yet, you can learn how to do that here.
Before we get started, it is incredibly important to note that having redundant DNS servers is very important. I highly suggest that you purchase a cheap Raspberry Pi Zero and configure Pi-hole on it so that you have two Pi-hole DNS servers. This will ensure that when your NAS is rebooted, your clients do not lose DNS resolution services.
Instructions – Pi-Hole OpenMediaVault
1. Login to OpenMediaVault and select OMV-Extras on the left-hand side. If you don’t have OMV-Extras, you will need to install it from the Plugins section.
2. Select the Docker tab, then click the Docker drop-down and select Install. Docker will now install.
3. Select the Portainer drop-down and select Install. We will be using Portainer to install Pi-hole.
4. When Portainer finishes, restart your Raspberry Pi and when it comes back up, Open Portainer.
5. Set up your username and password for Portainer.
6. Select Docker and then Connect.
7. Select Local. Leave this up in the background and we will get back to it in a few steps.
8. Now that Portainer is set up, we need to create a docker macvlan network interface. SSH into your Raspberry Pi the same way you did when you initially set up OpenMediaVault. We need to determine what network interfaces currently exist (on your Raspberry Pi) and note down the adapter name. To do this, run the command below and note down the network interface name that has your Raspberry Pi’s IP address (in this example, mine is enxb827eb03ae0e).
ifconfig
9. Next, you need to run the command below while substituting the correct subnet (most are 192.168.1.0/24 by default) and network interface ID (mine is enxb827eb03ae0e). You also need to pick an IP address that you’d like to use that’s not currently in use. I will be using 192.168.1.195. NOTE: ph_network will be the name of the network (you can substitute this as you’d like). The items listed below in pink might need to be updated when you run this command.
sudo docker network create -d macvlan -o parent=enxb827eb03ae0e --subnet=192.168.1.0/24 --gateway=192.168.1.1 --ip-range=192.168.1.195/32 ph_network
10. The network interface is now setup. Go back to Portainer and select Volumes.
11. Select Add Volume and add two total volumes. One with the name etc-pihole and one with the name etc-dnsmasq.d.
12. Select Containers and then Add Container.
13. Give the container a Name and then in the Image section, enter pihole/pihole:latest.
14. Select Publish a new network port five total times and match the ports as the screenshot below shows. NOTE: Ensure that you have the two top ports (53, 67) set as UDP ports.
15. Select Volumes and select map additional volume twice. Enter the first container as /etc/pihole and select the /etc/pihole volume. Enter the second container as /etc/dnsmasq.d and select the /etc/dnsmasq.d volume.
16. In the Network tab, select the macvlan network we created earlier.
17. In the Env section, enter the two variables in the screenshot below. Ensure that you replace WEBPASSWORD value with the password that you’d like to use to access Pi-Hole. Also, change the ServerIP value to match the IP address you created for your macvlan network interface.
18. In the Restart Policy, change this to Always. This will force Pi-Hole to always start when Docker starts.
19. Finally, in the Capabilities, turn on NET_ADMIN.
20. Select Deploy the container. The container will take a few minutes to fully download and install, but when it’s done and reporting running, you will be able to access the Pi-Hole web admin interface using the ServerIP address you assigned!
http://[serverIP]
DNS Configuration
Now that the setup of Pi-hole is complete, we need to determine a way to point our clients to our DNS server. There are two main ways to do this:
- Point your router’s DNS server to your Pi-hole server IP address. This will ensure that any device connected will use Pi-hole as its DNS server.
- Point each client to your DNS server. This is beneficial if you only want certain clients to use Pi-hole as a DNS server.
I point my routers DNS servers to my Pi-hole server as I want to ensure every device connects to it.
Conclusion
Setting up Pi-Hole on OpenMediaVault isn’t too bad thanks to Portainer. Technically, this tutorial will work for any Docker instance where Portainer is installed if OpenMediaVault isn’t something that you have installed!
Thank you for reading the tutorial! As always, if you have any questions, please leave them in the comments!