Pi-Hole as your local DNS server

If you are looking for a network-wide ad blocker, Pi-Hole is the product you are looking for. Pi-Hole blocks advertisement at the DNS level; therefore, all your clients who use your Pi-Hole as their DNS server, will be protected by Pi-Hole. As far as I can tell, Pi-Hole was developed for Raspberry Pi. However, the same one-line easy installer can be used for Debian 9 as well.

To install Pi-Hole, you would just copy and paste this command

curl -sSL https://install.pi-hole.net | bash

Instead of using the IP address to access our internal services, we can utilize Pi-Hole to resolve whatever name we assigned to each service. Let’s say we have a Jellyfin media server and Piwigo photo gallery server. Our objective is to use their hostname (or FQDN) to access these services.

ServiceIP AddressPortHostnameURL

We just need to add some lines to the /etc/hosts file and restart Pi-Hole service. To do so, vim /etc/hosts

Note: I was running this on Debian 9 LXC and I was using the root account. If you are not using the root account, you would need to add sudo at the beginning.

root@pihole:~# vim /etc/hosts	localhost
::1		localhost ip6-localhost ip6-loopback
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters
# --- BEGIN PVE --- pihole. pihole
# --- END PVE ---

# Anything above this line are part of your Pi-Hole installation
# Internal domain	jellyfin	piwigo

Once you are done, save the changes and restart Pi-Hole DNS.

pihole restartdns

That is it. You can add more hostnames or FQDN whichever you preferred to the /etc/hosts file. Just remember that whenever you edit the /etc/hosts file, you would need to restart the DNS service.


Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x