I am trying to add local DNS entries on my docker setup. On the local DNS page the following is show:
The order of locally defined DNS records is:
The device's host name and pi.hole
Configured in a config file in /etc/dnsmasq.d/
Read from /etc/hosts
Read from the "Local (custom) DNS" list (stored in /etc/pihole/custom.list)
So I am mounting a file 97-custom-dns.conf to my docker setup. This file is seen inside of the container, but FTL will not run and shows the following error: FTL failed to start due to bad option at line 1 of /etc/dnsmasq.d/97-custom-dns.conf
What is the correct format for this file?
I am currently using a simple file that matches the custom.list file when you add an entry manually.
I think this is different than the 'Local DNS' option. I tried that format anyway, and FTL still had an error starting up.
That is what I have done so far. I am hoping to add a file with the domains/IPs when starting up the container so I wouldn't have to manually input the records if I get a new device or start with a fresh pi-hole install.
Then you are almost there, I think:
Local DNS Records -as managed via Pi-hole's UI- are indeed stored in a file, as mentioned:
You may edit that file and add one IP-address-to-hostname association per line, with at most one IPv4 and one IPv6 appearing for the same hostname, e..g.
192.168.1.10 laptop
fe80::10 laptop
If that would fit your bill, you're done.
And that would come with the additional benefit of having your names accessible via Pi-hole's UI.
As for configuration files in `/etc/dnsmasq.d/` (click for more)
Handling other files would only be necessary if you'd require more control over hostname records, e.g. defining more than one IPv4 for a name.
A custom dnsmasq configuration will give you the most detailed control, but you'd have to familiarise yourself with dnsmasq's documentation. host-record would seem the most obvious option to use here, but you'd have to look into others as well.
I'd recommend to try editing /etc/pihole/custom.list first.
Pi-hole doesn't populate the hosts file - that's done by the host OS and/or user input.
For simple hostname definitions, there's really no need to look any further:
The easiest way to define local hostnames would be via Pi-hole's UI, which stores its definitions in /etc/pihole/custom.list.
That file could also be used to populate it from some external source, provided the limitations I've mentioned above are met.
For Docker, both that file under /etc/pihole as well as any custom dnsmasq configuration under /etc/dnsmasq.d/ would have to be stored in respective volume mounts, as catered for by our sample configuration.
I'm going to try and make a docker setup with a custom.list. I like the custom.list idea for the reasons you pointed out. You can quickly see if your file took, and you can make changes with the web gui.
Might be a day or two, have a lot going on today. Thank you for your feed back.
I am trying to add the 97-custom-dns.conf file and can't quite workout the format. Based on the other files it seems it should maybe have some sort of string=key format, but I don't know what that would be for dns entries.
I was just looking through the dnsmasq.conf example file and I think the format for the local custom DNS should be as shown on line 76-82:
# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.
#address=/double-click.net/127.0.0.1
# --address (and --server) work with IPv6 addresses too.
#address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83
I can confirm that adding a file with DNS entries as shown works!
# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.
address=/double-click.net/127.0.0.1
# --address (and --server) work with IPv6 addresses too.
address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83
It does not however show those entries in the GUI under '"Local DNS > DNS Records'.
Looks like mounting a custom 'custom.list' does show the records in the Local DNS Records though so this might be the best option! I mounted it with my docker compose: - ./pihole/custom.list:/etc/pihole/custom.list
and the file looked like: