Using Pi-Hole to Create Local DNS Entries

1. ssh to your pi-hole server
2. use nano to edit the dnsmasq:
sudo nano /etc/dnsmasq.d/05-custom.conf
3. add the dns entry in the following format:
address=/example.com/1.2.3.4

some examples from my network:

address=/violet-fw-01.violet.com/192.168.1.1
address=/violet-nas-01.violet.com/192.168.1.38

4. exit and save the file (control X, then Y)
5. restart the dnsmasq service:
service dnsmasq restart

this has been replaced by sudo service pihole-FTL restart in recent versions of pi-hole, as pihole-FTL now occupies port 53 (dns) and handles dnsmasq

If you want to create cnames, you can utilize the same method, the config file does not care how many hostnames point to the same IP:

#cnames
address=/firewall.violet.com/192.168.1.1
address=/nas.violet.com/192.168.1.38

This is especially useful if you have a proxy server, as you can direct multiple hostnames to the proxy server's IP, and use the proxy server to forward it to the correct port. For example, plex, radarr, nzbget, etc all reside on a ubuntu VM ending in .27, but utilize different ports to be accessed from browser. .40 is my proxy server:

#reverse proxy pre-requisites
address=/plex.violet.com/192.168.1.40
address=/radarr.violet.com/192.168.1.40
address=/sonarr.violet.com/192.168.1.40
address=/lidarr.violet.com/192.168.1.40
address=/nzbget.violet.com/192.168.1.40

More on this on my Proxy Server guide.

Also note here I'm using violet.com not iViolet.net. This is an important distinction as I do not own violet.com (too rich for my blood), so when forwarding to this address internally, whatever is actually hosted on violet.com is not accessible to me. In most cases, this is fine, however, you would not want to choose “google.com” as your designated internal domain name, as whenever you visited the URL internally, it would forward to what you have set in dns, instead of google.

It's recommended you choose something you don't intend to use, or even better, an external/public hostname which you own (iViolet.net). Then you can configure your proxy server in a manner where something like wiki.iViolet.net is accessible both internally and externally from the same hostname, without any dns manipulation. More on that in Helder's proxy guide.

–Brian

Discussion

Enter your comment. Wiki syntax is allowed:
 
Last modified: le 2019/03/28 19:33