Proper way to do domain name & hostnames

Hello! I have been running pi-hole for quite some time, and wondered if I have it truly configured correctly. I am using pi-hole for my DHCP server, and I have "home.lan" under the DHCP settings for "Pi-hole domain name". Under my "Static DHCP leases configuration", whenever I add a new static entry, I've been manually setting the hostname to have the home.lan suffix - so for example, my printer has a fixed DHCP entry and the hostname is printer.home.lan

Then, I usually go into "Local DNS -> DNS Records" and add the static IP pointed at that same domain name.

Is this all redundant? My main questions, I guess:

  • Do I need to put the ".home.lan" suffix on my DHCP static entries?
  • Do I need to put my full local domain names like "printer.home.lan" in the DNS Records?

Thanks in advance for the help. I'm probably going to change the domain name to a domain name I actually own, or possibly use home.arpa

dnsmasq's expand-hosts option could help here, but there is no obvious wrong or right answer to your question.

Each of printer and printer.home.lan constitute a domain, even if the latter could be derived by attaching the local search domain to a plain hostname.

Consequently, to be able to automatically associate the same A/AAAA records with two domains, Pi-hole has to be aware of your local domain.
That is usually only the case if you operate Pi-hole as your DHCP server.
In that case, Pi-hole can also add expand-hosts option to its configuration if you'd tick Never forward non-FQDNs as well.

If Pi-hole isn't your DHCP server, you may add a custom configuration file, e.g. 42-local-network-awareness.conf, with the following contents:

expand-hosts
domain=fritz.box

But you should be aware that expand-hosts does not cover all types of DNS record, e.g. CNAMEs would still need explicit dual definitions (if required). In addition, you should note that resolution for DHCP-client supplied hostnames only works as long as the client is active.

Also note that creating local DNS records would give you local name resolution independent from other sources like your DHCP server, which may be an advantage, e.g. if you are forced to swap to use a router model that doesn't register DHCP provided names into its integrated local DNS server.

So while you certainly could spare yourself from a bit of typing, creating dedicated DNS records may give you greater flexibility and persistence.

Hence, it would depend on your specific network requirements as well as your personal preferences which mix of measures would work best for you.

1 Like

Thanks for the reply! I am indeed using pi-hole entirely as my DHCP server. And yep, I have the "Never forward non-FQDN A and AAAA queries" option checked. I believe I follow what you're saying - if I do not add the entries under "Local DNS Records", name resolution for that DHCP client would only work if their lease was active. I think I want resolution to still work even if the client isn't connected - so it sounds like I should keep adding entries there as well.

Do you know if it's "correct" to put the full name (with the domain name suffix) when I add a new Static DHCP lease? For example, should I put "printer.home.lan" - or should it just say "printer" -- and pi-hole will handle adding the domain name suffix for resolution purposes?

I'd stick with the plain hostnames, lest you want to encourage lots of additional requests for printer.home.lan.home.lan .

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.