[SOLVED] How can I get the local domain name auto suffixed to hostnames in DHCP?

Expected Behaviour:

  1. Devices should be reachable via <device_hostname_from_DHCP_reservation>.<local_domain_name>
  2. I should be able to define DHCP lease reservations based on MAC address and host name. At this point, I should not need to add the local domain name suffix, since the server already know what domain name it is assigned, e.g., .lan
  3. When these devices get their IP address, they should be discoverable using <device_hostname_from_DHCP_reservation>.<local_domain_name>

In the above example, I am assigning the name DX70 to the 2nd device. Instead of having to type DX70.lan, I should simply be able to type DX70, and the servers should auto-add .lan at the end in its configuration.

Actual Behaviour:

  1. I need to add per device DNS records to be able to use <device_hostname_from_DHCP_reservation>.<local_domain_name>.
  2. I can use <device_hostname_from_DHCP_reservation> to find the device.
  3. I cannot use <device_hostname_from_DHCP_reservation>.<local_domain_name> to find the device.

Debug Token:

https://tricorder.pi-hole.net/8gvt2xtoor

You have a couple of options here.

By default, Pi-hole's embdedded dnsmasq would only automatically add DNS records for a simple hostname expanded by the local search domain if a DHCP client would claim that hostname during DHCP lease negotiation.
If I remember correctly, this also would mean that the lease had to be active, but you want to verify that.

As you've observed, any manual DNS definitions (including CNAMEs, PTRs, SRVs, etc.) would be added as is, i.e without considering the search domain.

You may try to enable expand-hosts as a custom configuration option, but note that according to dnsmasq documentation , this won't work for all definition types, but for definitions in hosts files only.

For configurations where Pi-hole is acting as DHCP server, ticking Never forward non-FQDNs would also prompt an expand-hosts option to be set.

Adding the DNS records explicitly may be more tedious, but it certainly is the safer way to provide resolution for local FQDNs, and it will also work when Pi-hole is not your DHCP server.

Great explanation .. I will try the suggestions.

FYI, I already have Never forward non-FQDNs checked, but it doesn't help with full FQDN resolution of local hostname.domainname from DHCP laase reservation.

Also, check your clients resolver configurations.

If it's linux then check /etc/resolv.conf and see if there are any search domains listed.

If Windows then check ipconfig for any Connection-specific DNS Suffix.

Yes, the search domain was set correctly. It turns out that a corporate security package that proxies DNS queries had some caching issues.

After a reboot of my machine, all name resolution WITH and WITHOUT domain suffix is working WITHOUT me having to enter the full FQDN in the local DNS settings of PiHole.

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