Local DNS Records


I'm really LOVING Pi-Hole 5 thus far. I used to use 'lan.list' on Pi-Hole 4.x to add DNS records for hosts on my internal network, but I see the new 'Local DNS Records' option.

I used the web interface to add a couple of hosts. That process works well but is VERY slow.

I have a couple of questions:

  1. Is it possible to add DNS entries from the command-line?

  2. Where are the local DNS records stored? I'd like to be able to create backups of the records in the event that something catastrophic happens to my Pi and I need to rebuild. I definitely don't want to go through the process of adding several dozen records to the configuration after a rebuild.

Thanks for all your hard work!


The Local DNS records are stored in file /etc/pihole/custom.list

You can also make direct changes in /etc/hosts , which acts similarly.

Yeah - I found that shortly after I clicked submit on the article. Sorry about that! :-/

Wait - so you can also add entries into /etc/hosts and Pihole will return the values as responses to DNS clients?

Yes. This has always been the case.

1 Like

Does adding entries to /etc/pihole/custom.list make them show up in the 'Local DNS Records' in the web portal?

Yes, it does.

So as an experiment I removed all my entries from the /etc/pihole/custom.list and "Local DNS Records" page in the web portal. I rebooted the pi-hole and then manually added entries into the /etc/pihole/custom.list with following format:

ipaddress hostname

I then rebooted the pi-hole again. The entries are still in /etc/pihole/custom.list but they aren't in the Local DNS Records section nor are the hostnames being used correctly anymore as it's just pulling the "unfriendly" actual hostname from my DHCP server..

What does your /etc/dnsmasq.d/01-pihole.conf look like? Does it have any references to custom.list?









Okay, what is the permissions on the file? ls -lac /etc/pihole/custom.list?

dschaper@nanopi-r2s:/etc/pihole$ cat custom.list mooby
dschaper@nanopi-r2s:/etc/pihole$ dig mooby @

; <<>> DiG 9.11.5-P4-5.1-Debian <<>> mooby @
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53047
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 4096
;mooby.                         IN      A

mooby.                  2       IN      A

;; Query time: 3 msec
;; WHEN: Sun May 10 18:19:50 UTC 2020
;; MSG SIZE  rcvd: 50

dschaper@nanopi-r2s:/etc/pihole$ dig -x @

; <<>> DiG 9.11.5-P4-5.1-Debian <<>> -x @
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55926
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 4096
;      IN      PTR

;; ANSWER SECTION: 2     IN      PTR     mooby.

;; Query time: 2 msec
;; WHEN: Sun May 10 18:19:59 UTC 2020
;; MSG SIZE  rcvd: 72
dschaper@nanopi-r2s:/etc/pihole$ ls -la /etc/pihole/custom.list
-rw-r--r-- 1 root root 18 May 10 18:19 /etc/pihole/custom.list

ls -lac /etc/pihole/custom.list
-rw-r--r-- 1 root root 1 May 10 12:01 /etc/pihole/custom.list

And do your dig results show anything?

Crap. I figured it out. For some reason I was editing a custom.list file in /etc/apt/ for some reason. Once I figured that out I removed that file and edited the custom.list file in /etc/pihole/ all is working normally.

Sorry for wasting your time. lol

It's possible for me to link an domain to an IP. I have some services running on a specific port number. Is it possible that i can add the port number in the local dns records feature?

Not in Pi-hole but you could do that in a webserver using virtual host.

The vhost redirects to a URL with a specific port.

Wait -- I'm having a similar problem. I have a set of custom hosts defined which are visible in both the /etc/pihole/custom.list and in the Web UI but I cannot edit the list from the Web UI. I get "Error while adding this custom DNS entry". I had an old lan.list that was manually linked in from the /etc/dnsmasq.d/ directory but I fixed that (removed the link and the file). Any other ideas of what might be causing the error?

Try opening a new help thread and filling out the template in full with all the information that would help us try to debug.