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

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

Thanks, but what is the purpose of the "Conditional Forwarding" then?

I am also interested in the answer to this.

The purpose of conditional forwarding is when Pi-hole is not your DHCP server, but you want to automatically have it resolve client hostnames and get their hostnames from their IP address (reverse lookup).

It seems to be working fine, just give it couple minutes to spin up, or enforce new DHCP assignment

Newbie here, thanks for this script, but can I ask where you run it? Just on the pi itself?

Is there another way of doing this without having to edit my /etc/hosts file?

I'm able to see the local hostnames on my system using the mdns-scan command, and resolve them to IP addresses using the avahi-resolve-host-name commands, is it possible to somehow get Pihole to do this?

@dev_rath That link isn't working - is the script still available?

Looks like the script is still available on archive.org: Pihole with a view – AQuriousMind – Comics for the Curious

I honestly don't get why pi-hole can't just automate the hostname discovery. I was using pfsense with pfblockerng and it was working just fine. I also miss the posibility to whitelist all subdomains from a domain

Its not done through discovery.
The clients hostname is advertised to the DHCP servers during the DHCP renewal process.
Below client of mine is configured like below to advertise its hostname:

xbian@avr ~ $ cat /etc/dhcp/dhclient.conf
[..]
send host-name = gethostname();
[..]

So initially, only the DHCP server knows of these hostnames.

Pi-Hole V5.0 has the capability for wildcard whitelisting.

I though there was a script that can do that.

Dont need to script anything.
If the client acquires an IP through the router DHCP, you router gets to know its hostname and creates a "PTR" DNS record for it.
In below example, on a client with IP 10.0.0.9, Pi-hole does DHCP for my network:

xbian@avr ~ $ hostname -I
10.0.0.9

xbian@avr ~ $ dig +short @pi.hole ptr 9.0.0.10.in-addr.arpa
avr.dehakkelaar.nl.

EDIT: probably below is easier to understand:

xbian@avr ~ $ dig +short @pi.hole -x 10.0.0.9
avr.dehakkelaar.nl.
1 Like