How do I show hostnames instead of IP addresses in the dashboard?

There are two ways to accomplish this:

  1. use Pi-hole's built in DHCP server
  2. use your router's DHCP server and modify /etc/hosts on your Pi-hole machine

Use Pi-hole's DHCP server

When you enable Pi-hole's DHCP server, you have the option to assign DHCP reservations and pair them with a hostname. Just make a reservation for every device on your network.

Edit /etc/hosts on your Pi-hole

The other option is useful if you want to keep your existing DHCP server (usually your router) and just use Pi-hole for DNS.

All you need to do is edit the /etc/hosts file on your Pi-hole to add hostnames and IP addresses. These will then show up in the query log.

/etc/hosts Network-wide

Normally, /etc/hosts applies only to the machine on which the file exists. But since Pi-hole is acting as a DNS server (resolving names into IP's) this file becomes available to any device using Pi-hole for DNS.

DHCP Reservations

You should also note that if you do not use DHCP reservation from your router, if you assign a hostname to an IP and your router hands out that IP to a different device than you are expecting, the names may not be accurate.

Privacy Settings

Please note that for either option above, if you have the privacy mode enabled, the hostnames will not show in the dashboard.

7 Likes

Thanks all for you answer It's clear.
I was first thinking that the name in my (Not pihole ) DCHP server can be used now i understand why i have always Ip :wink:

2 Likes

Just a quick remark :

Hosts file modification need a reboot to be taken into account (For newbie like me)

1 Like

Good point. I think we could also probably just

pihole restartdns

but I'll have to check to make sure.

This is true. Thanks. FYI pihole restartdns does not resolve this. It does in fact require a reboot.

I know this is old but I didn't need to reboot, I just ran sudo service pihole-FTL restart. I had already restarted dnsmasq so not sure if that needs to be done first or not.

I'm using Pihole 4.0 and i do not see host names anywhere. I'm running in net=host mode, using Pihole's DHCP server. In order to see hostnames instead of IP addresses i had to edit the hosts file.

Was using pihole 3.3 previously and the behavior was the same.

I never used pihole as dhcp and always got my hostnames in the dashboard. But since 4.0 its not working like before. You broke it.

And working with handmade hostslist cant be the solution..

I can ping every client in my network by the name from my windows client, which has the pihole as dns server. Looks for me like a bug, because the pihole definitly knows the hostnames of the internal ips.

What are you seeing now? Screen shots would be helpful if you have them. And when did this behavior change - as soon as you updated to V4.0 or sometime later?

Now I see the ips of the clients in the dashboard. I did a clean install with 4.0. Since this day i never saw any hostname of my clients in the dashboard. It worked the past 10 months before the update with different older versions.

Even with activated contitional forwarding, disabled "never forward non-FQDNs" and disabled "Never forward reverse lookups for private IP ranges" - no hostnames, only ips.

From a client other than Windows, can you dig local clients in your network?

Yes, I can open the webinterface of my printer on my android device with its hostname.

From the terminal on your Pi, run dig for the hostnames of both the Windows client and Android client and see if the IP is returned.

Nope, this is not working.

What was the output of your commands?

root@DietPi:~# dig pc

; <<>> DiG 9.10.3-P4-Debian <<>> pc
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 4315
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;pc.                            IN      A

;; AUTHORITY SECTION:
.                       10800   IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2018110300 1800 900 604800 86400

;; Query time: 19 msec
;; SERVER: 62.109.121.1#53(62.109.121.1)
;; WHEN: Sat Nov 03 18:19:04 GMT 2018
;; MSG SIZE  rcvd: 106

This does not appear to be the case, based on the results of the dig for a local client. If you would like to upload a debug log and post the token, we can take a look at your setup.

Your best option at this point is either map the clients in the /etc/hosts file or use the Pi-Hole as DHCP server. Either of those two options will restore the client names to the logs and dashboard.

Stupid question here: Editing the host file on the Pi worked fine as it now shows names instead of IP addresses in the Pi Hole interface. BUT I would like to see these names also in other programs running on my computer. Is that possible?

E. g. I use the iStat Pro widget in my Mac's dashboard and would like it to show the name instead of the IP address under the network setting.
I was hoping that editing the host file on the Pi would do the trick but it doesn't seem so.
What am I missing?

3 posts were split to a new topic: Cannot resolve host names

Here's a script that does exactly this - updates the hosts file with human-friendly hostnames, that the pihole uses in its reporting. There is no need to set the devices to have static IP address, or configure anything on the hosts themselves. This is a script that listens on the network for DHCP messages and updates the hosts file on the pihole server automatically. It does also try to profile to give the the hostname some additional context (like is it a TV, or fridge) but that's optional, and you can eliminate that part, if the basic hostname is enough.

http://aquriousmind.com/pihole/

I hope you find it useful.

1 Like