How to show readable hostnames when Conditional Forwarding supplies only gobbledygook

Please follow the below template, it will help us to help you!

Expected Behaviour:

I insert the local ip of my router and the local domain to see the names of my clients instead of their ip.

Actual Behaviour:

I use a fritz box and the local domain is fritz.box and now all of my clients sound like this
"galaxy-s9.fritz.box". How canI change it to show just the name withouth the local domain of my network?

Debug Token:

https://tricorder.pi-hole.net/rnjmb7s4v6

As you are using a frutz.bax ;), you can't.

By enabling Conditional Forwarding, you are configuring Pi-hole to ask your FB to provide names for IP addresses. As of today, FB does neither allow changing the local domain (i.e. fritz.box) nor to suppress it when being queried for a name.
Also, many network commands or applications will append hostnames by the local search domain automatically, so likely, other routers would behave similar to FB.

Instead of using Conditional Forwarding, you could resort to supplying local hostnames for IP addresses by editing Pi-hole's /etc/hosts manually.
This will work reliable as long as a device's IP doesn't change, i.e. you configure your FB to use DHCP lease reservation to assign a fixed IP address to a device.

Alternatively, you could disable DHCP in your FB and enable DHCP on your Pi-hole, supplying names through Pi-hole's DHCP settings pane, where you also could change the local domain name (but you may still see that domain being appended).

Hey, thx for your hint :wink:

I've thought that it isnt possible...
I know the other options you told me but since I have one device that schould never connect to the pihole the dhcp server is not an option and editing the hosts file seems to be pretty rough and some other guys around here said that its a forbidden fruit.
So after all I think I just have to live with the stupid name endings. The clients are still recognizable.

If you shy away from editing the hosts file, there may be another approach to assay, but it'll involve more manual editing, and you have to test for yourself to find out whether this will produce the names in your fashion, or whether Conditional Forwarding still would take precedence (if enabled coexistingly).

You could try setting up a hostrecord with pihole-FTL for each client by adding a custom configuration file under /etc/dnsmasq.d/.

You can either do that completely manually from scratch, studying the man page for dnsmasq , or have pihole assist you by executing

pihole -a hostrecord <hostname> 192.168.178.<x>

Of course, you'd have to replace the <bracketed terms> with your respectively applicable values. Implemented FR Domain Redirect - #3 by DL6ER has more details on this.

Pi-hole is adding hostrecords to /etc/dnsmasq.d/01-pihole.conf by default.
You should be aware that updating pi-hole may overwrite your changes in 01-pihole.conf.

That's why I'd suggest moving the hostrecord lines into a separate custom configuration file, e.g. /etc/dnsmasq.d/20-local-hostnames.conf. Once you are familiar with the pattern, you should also be able to edit that file directly, but don't forget to restart when finished. :wink:

Thank you for your advice. I think I'll go with the option I've discribed in my first post :wink:
The Question is: Why are some clients, like my smart-tv or my iPad not shown with their exact names. They are named like "N/A" or "com-mid1.fritz.box" even though I've renamed them. After all I've never seen these names in my network or my router settings.The other devices I've renamed haven't changed their names in pi-hole too, even a reboot did'nt helped...
So where does the names come from? :thinking:

There may be multiple names associated with a single device, and a client may chose to construct a name for itself, with our without considering name relevant values supplied by your router or ISP (happens e.g. when using IPv6, resulting e.g. in names containing dip0.t-ipconnect.de).

Your FritzBox provides a list of names when a name is requested for an IP - execute nslookup 192.168.178.1 on your RPi and see for yourself. I am not aware of a way to make Pi-hole pick a specific name from such a list.

This is also the reason why I personally chose to edit my hosts file, as Android devices were listed with ridiculously long and meaningless names like android-38967b82fa5effbe.local.domain, instead of the nice clean ones I set in my router :wink:

Okay so how exactly do i edit the hosts file? Just entering it and enter the ip followed by the name, exit the ssh session and reboot the system? And of course give my devices static ips :wink:

sudo nano /etc/hosts and follow the pattern already in there, i.e. one line for each <ip-address> <hostname> association, save on exit and restart Pi-hole's DNS:

pihole restartdns

IP addresses don't have to be strictly static, fixed is enough (as configured by DHCP lease reservation in your FB).

Okay, so I just enter the Ips make a space and then the name and do this for every device, one per line. Since I've never worked with the dhcp server I'll just use static ips, no disadvantage I think.
But how exactly do I exit the menu on the ssh client? If I enter "^X" nothing happens...

We are not using a DHCP server on your RPi here, just configuring name resolution.

Sorry, I might have confused you by being overly pedantic on the terms "static" and "fixed" (click for more)

Static IPs have to be configured on each client individually, commonly by editing each client's corresponding network configuration, which implies you can easily access that client's CLI (or equivalent).

Fixed IPs can be centrally configured via a DHCP server (i.e. your FritzBox). A fixed address is still assigned to a client dynamically, but your FB assures that a client always gets the same address by DHCP lease reservation.

Both serve the same purpose, to much the same effect, but fixed IPs are a bit easier to maintain.

Granted, even in IT, these terms are often used interchangeably, even though they differ :wink:


You mean exiting nano?
"^X" stands for the keys <Ctrl><X> pressed simultaneously. <Ctrl> may read <Strg> on your keyboard (German layout, right?).

1 Like

Alright now Im getting it^^
The terms "fixed" and "static" are indeed confusing.
And yes Im using a german key layout. So now I finally know how to work with these commands :wink:
The option for conditional forwarding has to be disabled to prevent trouble right?
And what does these option anyway? :smiley:

Enabling or disabling Conditional Forwarding would depend on your exact configuration and on your personal preference.

If you'd just want to handle those misbehaving devices that otherwise would appear with too long/unintelligable a name, you could just add those to /etc/hosts/ and leave the rest to your router. I'd prefer that if I had a large number of hosts with very few misbehaving devices, but in your case, going the full way is maybe what you want anyway, as that's the only way to get rid of the 'fritz.box' domain suffix. It's really a question of personal choice.

In general, Conditional Forwarding tells your Pi-hole to ask your router (or more precisely: an arbitrary device) to provide a name for an IP address that Pi-hole's DNS cannot associate with a name. Also, directly above the option in Pi-hole's UI there's a nice paragraph explaining how it does this and when it should be applied :wink:

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