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
Jellyfin10.0.7.108096jellyfinhttp://jellyfin:8096
Piwigo10.0.7.1282piwigohttp://piwigo:80

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
127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters
# --- BEGIN PVE ---
192.168.20.10 pihole.1.1.1.1 pihole
# --- END PVE ---

# Anything above this line are part of your Pi-Hole installation
# Internal domain
192.168.7.10	jellyfin
192.168.7.12	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.

Cheers!

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x