Local DNS records

FTL 6.x offers 2 ways to add local DNS records:

  • dns.hostRecord - this currently is a string, which allows only for a single host record entry to be added (dnsmasq allows an arbitrary number). Ok, one can use the user defined dnsmasq settings to add more, but if this is really considered as a viable way going forward, this needs to be made into a list and put into the web gui.
  • dns.hosts - a very basic IP to name mapping, writing to /etc/pihole/hosts/custom.list and pulling these in via hostsdir config setting.

What I like about the host record entries is that they're concise: Everything you need to know in one line, all names, both IPv4 and IPv6 as well as an optional TTL.

What I like about the hostsdir approach is its flexibility. One can add other files in the same directory that one, for whichever reason, doesn't want FTL to manage directly, and the built-in dnsmasq monitors and applies changes automagically.

What I don't like here is that the current implementation does not provide a good user experience. Only basic 1:1 mappings are supported, so it lacks the "all at one glance" that hosts records provide and maintaining multiple names for both IPv4 and IPv6 is simply a pain.

So can this be pimped that a little bit? What I'd like to have in the web gui:

  • A list box to be able to see/define any number of names.
  • An IPv4 address box.
  • An IPv6 address box.

That way it'd be equally usable as the host records. These could be dumped then from the general config from my point of view: Both are providing 90% the same functionality and if someone really needs the special additional features from host records, these can be added in the user specific section.

The reason why dns.hostRecord exists in exactly this form is simply that it was there pre-v6 and we simply maintain this setting for users. However, dns.hosts does allow multiple names, is this what you are asking for?, e.g.

127.0.0.1 a b c

would be possible to define said IP for all three host names. I don't feel easy deviating from the very well-known HOSTS format allowing multiple address types in the same line (like IPv4 + IPv6) but multiple host names for the same address should already be possible. If not, this is a bug and we can fix it.

Did you take a look at v6's Settings | Local DNS records ?

It's not an ask to move away from HOSTS format. It's a matter of UX: How is the information presented to an end user? In my surroundings users are mostly people who are somewhat ok with IT, but no geeks. The better the UX, the better the acceptance.

Let's say I need to have the following in custom.list:

1.2.3.4 some.long.name.for.a.machine yet.another.long.name third.name.for.this.machine
2::1 some.long.name.for.a.machine yet.another.long.name third.name.for.this.machine

Today with the single line entry field not all of these long names are visible, so it's not easy to verify at a glance before hitting the "+" button.

If the UI would look something like this, it'd be very easy to achieve (very closely related to what today is shown in the list of existing records is done, which uses exactly this broken down format):

Domain(s)                                IPv4
+--------------------------------------+ +------------------------------+
| some.long.name.for.a.machine         | | 1.2.3.4                      |
| yet.another.long.name                | +------------------------------+
| third.name.for.this.machine          | IPv6
|                                      | +------------------------------+
|                                      | | 2::1                         |
+--------------------------------------+ +------------------------------+

This can be very easily converted into the proper HOSTS format (i.e. the above 2 lines in my example).

The current Local DNS records UI design also happens to be a user contributed feature.

As this seems easy for you, would you consider contributing a respective web-related PR with the necessary improvements of Pi-hole v6's Settings | Local DNS records UI?
That would be most welcome.

I'm not much of a web developer :rofl: But let me see if I can work out some kind of PoC.