Local DNS Records

Hello,

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!

-JeffH

1 Like

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.

1 Like

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?

1 Like

Here:

addn-hosts=/etc/pihole/local.list
addn-hosts=/etc/pihole/custom.list

localise-queries

no-resolv

cache-size=10000

log-queries
log-facility=/var/log/pihole.log

local-ttl=2

log-async
server=1.1.1.1
server=1.0.0.1
interface=eth0
server=/use-application-dns.net/

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

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

; <<>> DiG 9.11.5-P4-5.1-Debian <<>> mooby @127.0.0.1
;; 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

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;mooby.                         IN      A

;; ANSWER SECTION:
mooby.                  2       IN      A       10.10.10.10

;; Query time: 3 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun May 10 18:19:50 UTC 2020
;; MSG SIZE  rcvd: 50

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

; <<>> DiG 9.11.5-P4-5.1-Debian <<>> -x 10.10.10.10 @127.0.0.1
;; 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

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;10.10.10.10.in-addr.arpa.      IN      PTR

;; ANSWER SECTION:
10.10.10.10.in-addr.arpa. 2     IN      PTR     mooby.

;; Query time: 2 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; 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?

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.