Pi-Hole is a custom DNS server designed specifically to block ads, trackers, and malware. Pi-Hole can run from virtually any always-on hardware, including a Raspberry Pi, old PC, NAS, or Cloud Service.
See https://pi-hole.net/ for more information.
Here I will discuss my installation process, some initial results, and some extra resources.
Difficulty: Easy, but you should know your network’s/router’s configuration. For example, what is the IP to access your router from? What is the subnet of your network? General linux command line knowledge is helpful, but not needed.
I chose to install Pi-Hole to a virtual machine on my FreeNAS system. This is ideal for me because my network-attached storage (NAS) is always on and has plenty of resources to handle Pi-Hole. The steps below assume you have a FreeNAS 11.2 (or other always-on virtual machine). You can use older versions of FreeNAS, but the screenshots will be different.
Download the Ubuntu Server 18.04 LTS ISO.
Copy the ISO onto your NAS storage.
Create a virtual machine on FreeNAS.
From the main menu, navigate to “Virtual Machines”. Click “Add”.
Give your VM a name (e.g., “MyPiHole”). Make sure that Start on Boot and Enable VNC are checked.
Assign resources. At minimum it 2 CPUs and 1MB of RAM.
Assign hard-disk space. I chose 60GB, but that’s a lot. 16GB is about the minimum I would use.
Choose your network interface. Your MAC address should show up - I’ve blanked mine for privacy.
Choose the Ubuntu ISO from your drive.
Confirm your configuration and click “Submit” or go back and make changes.
Start the VM and connect through the VNC.
Select the installation. Select your language and keyboard configuration options. Select “Install Ubuntu”.
Configure DNS IP (IMPORTANT!!)
Setup your network configuration to use a static IP address so that your router always knows where to send DNS requests. When you come to the Network Connections screen, choose your network interface, choose Ipv4, and change it to “Manual”. Configure the options to match your network.
Subnet should be a CDN formatted IP address. For example, a default might be 192.168.1.0/8 if all of the IPs on your network would fall into the range 192.168.1.1 to 192.168.1.255.
Address is the IP address you want to use for your DNS (this must fall in your subnet). For example, 192.168.1.222.
Gateway is the IP of your router. For example, 192.168.1.1.
Name Servers are the IP addresses you want Ubuntu to use for DNS lookups. You can use any you want, for example Google DNS is 188.8.131.52 and 184.108.40.206 and Cloudflare is 220.127.116.11 and 18.104.22.168.
Search domains can be left empty.
Continue installation (most defaults are OK). You can use the entire drive space you allotted and it’s OK to erase all data (nothing on it to start with). Be sure to remember the username and password you assigned during installation.
Once installation is completed, disconnect from the VNC and stop the VM. Go to “Devices” from the three-dots menu of the VM and remove the CD drive. This will allow the system to boot into Ubuntu Server on restart.
Start the VM and connect through VNC again. You should reach the terminal and be asked for login. Go ahead and login with the user you setup during installation.
Make sure your network configuration is correct by trying to ping www.google.com. You should be able to get a response. If you do not, then you will first need to edit your network configuration file at /etc/netplan/<network configuration file here>.yaml.
After you confirm internet connectivity, update Ubuntu. Type:
sudo apt-get update
sudo apt-get upgrade
If prompted for your password, enter it. “sudo” stands for “super user do” and temporarily elevates your privileges to allow system changes. These commands are safe, but don’t generally “sudo” things unless you know what you’re doing.
Install Pi-Hole from the terminal. At the terminal prompt type:
sudo curl -sSL https://install.pi-hole.net | bash
Pi-Hole should start installing right away. Setup Pi-Hole as you prefer (defaults are usually Ok). I prefer Cloudflare for DNS because of speed and privacy, but use whatever makes sense for you. Once done, write-down or copy the default password assigned to you.
Login to Pi-Hole to confirm it’s live by visiting <VM Static IP>/admin in your browser.
Configure your router to use Pi-Hole as your DNS. This will vary for each router, but a quick Google Search should come up with some easy instructions if your router supports it.
Congratulations! You now have a functional ad-blocking custom DNS server! You can test this by visiting some website known to run ads - most should not show up anymore! You may see a few “We had trouble loading…” or other placeholders. This means the ad request was blocked!
After a few days of using Pi-Hole, I noticed that my Pi-Hole Dashboard shows about 35% of DNS requests blocked! Some ads from Facebook and Google still slipped through, especially from YouTube, but overall I’m happy with the initial results.
To block the YouTube ads that got through, I added the following RegEx to my blacklist:
Boom! No more YouTube ads.
https://firebog.net/ contains additional lists you can add to Pi-Hole for extra privacy, blocking, etc. to fit your internet needs!