Pi-Hole running in a container on QNAP Container Station
On the QNAP, go into the “Container Station”. Select the create option from the left side of the menu and then scroll to the bottom of the window. There are several types of Docker and LXC containers listed.
Choose the LXC Ubuntu 16.04 container. That’s the underlying OS for the QNAP QTS Operating System on the NAS. Let’s name the container “Pi-Hole” and set the CPU limit to 20% and the memory limit to 1024MB which is more than enough for Pi-Hole.
Then click on “Advanced Settings”. Change the network mode to “Bridge”, select “Use Static IP” and change the IP address to a unique address on your LAN. Go back to the “Overview” section in Container Station and after a few minutes you should see your container listed.
Click on the name of the container and you will enter the console.
Type passwd to change the password. Note the original password is ubuntu.
Before we can install Pi-hole, we need to update this very lightweight LXC container to add some features. First run updates:
sudo apt-get update
Next install the ssh server:
sudo apt-get install -y openssh-server
Now add a username other than the default. Just go through the dialogue and answer the prompts for the new user.
sudo adduser piuser
Now grant the new user privilege:
sudo usermod -aG sudo piuser
Open a terminal back on your desktop computer and “ssh” to the new machine with the address you used to create the LXC instance:
Get privilege in the command window:
sudo apt-get install curl
Now you can install pi-hole:
curl -sSL https://install.pi-hole.net | bash
Select the defaults until the DNS screen and then choose Cloudflare as your DNS when you see the screen below.
Accept all the rest of the defaults and be careful not to change them. This will assure that you get the admin web interface and that statistics are logged. The installation will continue for a few minutes after you answer the prompts. After your installation completes, you will receive a message telling you to set up the DHCP settings on your router to make the address of your Pi-Hole the primary DNS for your network. That will insert the Pi-Hole as the “man-in-the-middle” to scrutinize all DNS names before they are either passed to the Internet or “Pi-Holed”.
When you return to the prompt in the “ssh” terminal session, enter the following command to set your Pi-hole password:
pihole -a -p
You can now close the “ssh” terminal session.
Go to your web browser and enter the address of your Pi-Hole followed by /admin:
Select the login and you should be able to log in with the password you just set.
Since this is a “scratch” install in an LXC container, you will be able to start and stop the container and reboot the QNAP NAS without any problems and even upgrade Pi-Hole when new releases are available. This LXC container is very lean and uses a minimal amount of system resources.
Don’t forget to set the DNS settings for your DHCP server on your router because Pi-Hole will not be used by any of your network clients until that occurs. A good practice is to make the Pi-Hole DNS 1 and then Cloudflare 184.108.40.206 as DNS 2. That will assure DNS translation when your Pi-Hole is not running.