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

**URL:** <https://discourse.pi-hole.net/t/solved-how-can-i-get-the-local-domain-name-auto-suffixed-to-hostnames-in-dhcp/46876>\
**Category:** Help\
**Tags:** dhcp\
**Created:** [May 7, 2021, 5:59pm UTC](https://discourse.pi-hole.net/t/solved-how-can-i-get-the-local-domain-name-auto-suffixed-to-hostnames-in-dhcp/46876 "2021-05-07T17:59:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Selim](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/selim/32/15043_2.png) [@Selim](https://discourse.pi-hole.net/u/Selim)\
**Post date:** [May 7, 2021, 5:59pm UTC](https://discourse.pi-hole.net/t/solved-how-can-i-get-the-local-domain-name-auto-suffixed-to-hostnames-in-dhcp/46876/1 "2021-05-07T17:59:47Z")

</div>

## 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>`

 ![image](https://discourse.pi-hole.net/uploads/default/original/3X/4/7/47aed1475a74c9349280ab4f685314e28c41f35c.png)

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](https://tricorder.pi-hole.net/8gvt2xtoor)

---

<div class="post-metadata">

**Author:** ![Bucking\_Horn](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/bucking_horn/32/18719_2.png) [@Bucking\_Horn](https://discourse.pi-hole.net/u/Bucking_Horn)\
**Post date:** [May 7, 2021, 7:02pm UTC](https://discourse.pi-hole.net/t/solved-how-can-i-get-the-local-domain-name-auto-suffixed-to-hostnames-in-dhcp/46876/2 "2021-05-07T19:02:22Z")

</div>

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](http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html), 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.

---

<div class="post-metadata">

**Author:** ![Selim](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/selim/32/15043_2.png) [@Selim](https://discourse.pi-hole.net/u/Selim)\
**Post date:** [May 7, 2021, 7:15pm UTC](https://discourse.pi-hole.net/t/solved-how-can-i-get-the-local-domain-name-auto-suffixed-to-hostnames-in-dhcp/46876/3 "2021-05-07T19:15:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DanSchaper](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/danschaper/32/91_2.png) [@DanSchaper](https://discourse.pi-hole.net/u/DanSchaper)\
**Post date:** [May 7, 2021, 7:33pm UTC](https://discourse.pi-hole.net/t/solved-how-can-i-get-the-local-domain-name-auto-suffixed-to-hostnames-in-dhcp/46876/4 "2021-05-07T19:33:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Selim](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/selim/32/15043_2.png) [@Selim](https://discourse.pi-hole.net/u/Selim)\
**Post date:** [May 10, 2021, 2:06pm UTC](https://discourse.pi-hole.net/t/solved-how-can-i-get-the-local-domain-name-auto-suffixed-to-hostnames-in-dhcp/46876/5 "2021-05-10T14:06:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://discourse.pi-hole.net/uploads/default/original/3X/7/c/7c8792f649eeb921c5d2b4c41564ffa873d9a2b8.png) [@system](https://discourse.pi-hole.net/u/system)\
**Post date:** [May 31, 2021, 2:06pm UTC](https://discourse.pi-hole.net/t/solved-how-can-i-get-the-local-domain-name-auto-suffixed-to-hostnames-in-dhcp/46876/6 "2021-05-31T14:06:12Z")

</div>

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