What is the CORRECT way to get local hostname resolution without pihole as DHCP?



I run pihole on my rpi 3; it works great! For a variety of reasons I don’t use it as DHCP server. I get pretty spotty hostname resolution to local devices, I don’t know why! Some of the time I can ping devices on my network using FQDN (or simply hostname), including pi.hole, other times it doesn’t work.

I’ve tried changing settings in the pi’s /etc/hosts, /etc/dnsmasq.d/01-pihole.conf, /etc/pihole/local.list /etc/dnsmasq.d/localhost.conf, /etc/dnsmasq.conf, /etc/pihole/lan.list, etc. I flush the DNS on my machine (and the relevant services on the pi) and have had some success; but a few hours later it stops working.
I can always ping the local devices from the pi-hole itself, of course.

So I ask: on a brand-new pi-hole, that isn’t a DHCP server, what is the correct way to have DNS clients discover local hostnames (with or without FQDN)?



As an example, I just got it to work again by doing:

sudo pihole -a hostrecord [hostname]

But I’m sure it’ll stop working again, later.


This is done on the Pi in file /etc/hosts. If you have a printer, for example, the line entry in the /etc/hosts file could be: Printer

Note that for this to be correct, your DHCP names have to be reserved (or static) from the router.


That is the very first thing I did. I use static reservations. I can of course ping from the pi.

It works on the clients… Until it doesn’t. I’ll see if it’s something else on my client.


The method I use is described here section Q/A - “Why so many local requests?”.
I’ve been using this for over a year now, pihole is NOT involved in this, I simply use a dnsmasq feature (does also work with pihole-FTL - pihole 4.0).

For this to work, you need to:

  • have static DHCP addresses (using the MAC address) configured on the router (or whatever you use to provide DHCP)
  • have a domain configured in your router.
    I use pfsense, the domain is configured under system / general setup / domain. A lot of routers allow you to specify a domain, this will be distributed, using DHCP, to all clients.

On windows, You can verify you have a domain name by using “ipconfig /all”, look for
“DNS Suffix Search List. . . . . .”

The solution works with ipconfig and nslookup:

ping y50

Pinging y50.localdomain [] with 32 bytes of data:
Reply from bytes=32 time=1ms TTL=128
nslookup y50
Server:  raspberrypi.localdomain

Name:    y50.localdomain

reverse lookup:

Server:  raspberrypi.localdomain

Name:    y50.localdomain


My Ubiquiti USG adds the .local suffix for my domain. I use static reservations from the USG.
I am using Ubuntu 18.04 on my laptop, and have tried adding my domain suffix (which I shouldn’t need - before the pihole, the USG appended the suffix automatically to any DHCP clients).

As of now, nslookup is showing the correct results, and I’m able to ping from my laptop… but from my mobile phone, I have to disconnect/reconnect my wifi connection to get to pi.hole - every time.

I might be looking at a problem outside the pi-hole; but I appreciate the help!