Local domain persistance in Docker Pi-hole

Hi @DL6ER,
I have a similar problem I’m trying to solve. But instead of .local it’s rather that I have a domain name for which I host servers inside my local network. For example server1.exampledomain.com has A records in the public name servers pointing to my public IP. I use my router to port forward the requests to my internal servers. Is there a way I can configure pi-hole to resolve these fully qualified public domains to internal IP addresses? I’m running pi-hole in a docker so I can’t just edit the /etc/hosts file. In the docker appdata folder I found local.list but having tried that here What is best practice for static setting of domains hosts file style in docker? I found that didn’t work.

Is there some way I can persistently configure local addresses for FQDs that will survive docker updates?

Pinging @diginc and @DanSchaper as this is a docker-specific question which is outside my field of expertise.

1 Like

Thanks all. Much appreciated.

Custom dnsmasq.d rules should be fine. No difference between regular pihole really, other than the files are volume mounted in from my workspace so pathing is `./etc-dnsmasq/ points to /etc/dnsmasq.d/.

I just tested this with one of my external domains to confirm it worked:

# Before edit
$ host techjunktrunk.com
techjunktrunk.com has address 104.28.25.19
techjunktrunk.com has address 104.28.24.19
techjunktrunk.com has IPv6 address 2606:4700:30::681c:1813
techjunktrunk.com has IPv6 address 2606:4700:30::681c:1913
techjunktrunk.com mail is handled by 10 mail.protonmail.ch.

# Edit the volume mounted directory / config
$ vim etc-dnsmasqd/02-diginclan.conf
$ grep techjunktrunk etc-dnsmasqd/*
etc-dnsmasqd/02-diginclan.conf:address=/techjunktrunk.com/192.168.9.99

# Bounce container/dnsmasq
$ docker restart pihole
pihole

# Updated (my computer's DNS points to the pihole also)
$ host techjunktrunk.com
techjunktrunk.com has address 192.168.9.99

Hi @diginc, thanks so much for the reply, genuinely appreciated.

In the appdata folder for the docker there is a dnsmasq.d folder which presumably maps to /etc/dnsmasq.d/ inside the docker. So you create a new file there, ok.

Just one question, discuss has split the grep statement over 2 lines, is there supposed to be a space or new line between etc-dnsmasqd/* and etc/-dnsmasqd/ (presumably there is a single space right?)

Asking for clarification for future readers as much as myself. Thanks in advance.

Hi again @diginc I’ve CD’d to the docker dnsmasq.d folder, which in my case is just appdata/dnsmasq.d/

When I run either:

with space:

grep mydomain ./* ./02-localservers.conf:address=/server.mydomain.com/10.100.100.10

or without space:

grep mydomain ./*./02-localservers.conf:address=/server.mydomain.com/10.100.100.10

I get “No such file or directory”

Can’t I just insert some lines into the the file 02-mylan.conf ? If so what’s the pattern?

I used vim to edit my conf.d file, grep was to show what the actual addition to the file was.

You’ll need to use your editor of choice to add address=/server.mydomain.com/10.100.100.10 to the .conf file.