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

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

Hello. I have pi-hole 5 on a raspberry pi, with dhcp from my router. I only see one client in pi-hole, just the router's IP. I edited etc/hosts adding IP and hostname from other machine on the LAN, but nothing happens. Still only one client, router IP. Any sugestions?

Change to setting in your router do assign pihole's IP as DNS-server via DHCP to clients in LAN.

Disable the 'DNS Relay' mode on the router.

It would be cool to use hw-address to assign aliases to devices and ignore hostnames altogether, ip adresses could change and I do not control all devices setups.

assigning aliases to hw-adresses would be a simple and effective solution that does not need any permissions

line 19 causes the script to fail:

from scapy.all import *

what is scapy.all , why? where?.... i'm lost on this line.

It's a networking tool written in Python. It's being imported into this script and used to listen for, and decode, DHCP traffic on your network. Then the script uses that info to update your hosts file and look up the device vendors on the external third-party Fingerbank service. It's failing because you need to install Scapy first, as well as some other prep which the script comments mention.

The script is 3.5 years old and Pi-hole has changed quite a lot since then, with new features and newer ways of doing things. Linux has also undergone many changes. It may not be a valid assumption today that changing the standard hosts file is the way to do what this script was written to do back then. It also uses this external Fingerbank service to identify your devices, and that service has its own Privacy Policy to consider.

I would advise against using the script until you have asked yourself what you are trying to achieve, and then looked at what Pi-hole today can provide natively on a current supported distro like Raspberry Pi OS Bullseye. For example Pi-hole's Network overview in Tools, which appeared a few months after this script, gives a very nice overview of all the devices visible on your network, with their hostnames, IPs, MAC addresses, vendor names and how recent they are.

1 Like

tyvm for advice, but yes I ditched the script quickly. I don't want my pi reliant on Fingerbank. I just edited the hosts file using suggested commands above: sudo nano /etc/hosts , then a pihole restartdns
I copied in IPs and device names to the hosts file from my router, after setting them permanent in router's DHCP, or just made up device names for those that lacked them like wife's iPhones and iPads ;p

Sorry script fans, it wasn't very elegant or automated, but it worked.

This OS Bullseye you mention is interesting, tho, but I don't see anything in the pihole web admin interface about network overview or see my hostnames (unless they're one's i've manually added to the hosts file), but will look further.