Hostname for MacBook appears odd

The issue I am facing:
Pi-hole is not using the correct hostname of my MacBook. I guess it's an old name.

MacBook:

hostname
d4Rks-MacBook-Pro
nslookup 192.168.178.119
Server:         192.168.178.2
Address:        192.168.178.2#53

119.178.168.192.in-addr.arpa    name = d4Rks-MBP.lan.

I already tried

  • renew DHCP lease
  • flush network table
  • restart dns
  • restart pihole
  • deleted FTL network and network_addresses tables
  • etc. (basically everything I found about this)

Is there a way to debug this, to find out, where the Pi-hole actually pulls the hostname from?

Details about my system:

  • Pi-hole is running as DNS and DHCP server on 192.168.178.2
  • There are not custom rules in WebUI, /etc/hosts, dnsmasq, etc.
  • I'm using a FRITZ!Box as a router, but DHCP is switched off there. Actually the MacBook's hostname is displayed correctly on the FB web interface.

What I have changed since installing Pi-hole:
Nothing?

Any hints and help is highly appreciated :slight_smile:

Look in the Mac system preferences > Network > Advanced > TCP/IP and see what name the Macbook is advertising.

image

Edit - also run the following command from the Pi terminal to see the source of the reply from Pi-hole:

grep -C5 119.178.168.192.in-addr.arpa /var/log/pihole.log

1 Like

You mean DHCP Client ID? It's empty on my MacBook.

grep -C5 119.178.168.192.in-addr.arpa /var/log/pihole.log
[...]
Nov 30 21:03:18 dnsmasq[568]: query[PTR] 119.178.168.192.in-addr.arpa from 127.0.0.1
Nov 30 21:03:18 dnsmasq[568]: DHCP 192.168.178.119 is d4Rks-MBP.lan
[...]

This line indicates that Pi-hole found the answer in the DHCP information. That is either in the Pi-hole DHCP settings or from the client.

Also check the sharing section of the Mac system preferences - there is an optional device name setting there as well:

image

Also, please upload a debug log and post just the token URL that is generated after the log is uploaded by running the following command from the Pi-hole host terminal:

pihole -d

or do it through the Web interface:

Tools > Generate Debug Log

Guess this is fine?

And here's the token: https://tricorder.pi-hole.net/yBDu8iKG/

As you mention:

and

Maybe it's still stored in Pi-hole's lease list.

What does the following command return?

grep -c d4Rks-MBP /etc/pihole/dhcp.leases
1 Like
grep -c d4Rks-MBP /etc/pihole/dhcp.leases
1

So yeah, it's definitely in there. But how does the old hostname get there.
I already renewed the DHCP-lease and anyway it's set to only be valid for 24h.

I guess it has been stored when the lease was first created, and has been used with any renewal or request since.

To get rid of it, you could try to delete the respective line from dhcp.leases.
It may be advisable to stop Pi-hole before doing so, and restart it afterwards:

sudo service pihole-FTL stop
sudo service pihole-FTL start

I tried exactly that, but unfortunately without success.

After renewing the DHCP lease from my MacBook, I got "d4Rks-MBP" back in the dhcp.leases file.
And of course, nslookup shows the same result.

Could you upload a new debug log, please?

Sure, here you go:

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

Your debug log still shows no sign that your hostname is defined within Pi-hole's scope.

Together with the DHCP lease entry refreshing with d4Rks-MBP, this would strongly suggest your MacBook is sending that name during DHCP lease negotiation.

I don't own a MacBook, but let's try to find out what your MacBook calls itself.
Run from your MacBook, what's the output of:

sudo scutil --get HostName
sudo scutil --get LocalHostName
sudo scutil --get ComputerName

Firstly: Thx again for all your nice help!

Here's the output:

sudo scutil --get HostName
d4Rks-MacBook-Pro

sudo scutil --get LocalHostName
d4Rks-MacBook-Pro

sudo scutil --get ComputerName
d4Rk's MacBook Pro

Looks all pretty good... and until now I was pretty sure, it must be some kind of caching issue on the pi-hole...
BUT I just did a packet capture using Wireshark, while renewing the DHCP lease.

And here it looks a lot different:

So I guess, I will point the research/debugging more towards the MacBook now!

1 Like

Got it. :partying_face:

There must not be a space inside the "Computer Name" (System Preferences -> Sharing), see link below.:see_no_evil:
Really no clue, why I can set the hostname to whatever I want, when in the end, it matters what the computer name is?! Thx Apple for this confusion :wink:

Anyway, it works now!

nslookup 192.168.178.119
Server:		192.168.178.2
Address:	192.168.178.2#53

119.178.168.192.in-addr.arpa	name = d4Rks-MacBook-Pro.lan.

https://discussions.apple.com/thread/3177321?answerId=23944909022#23944909022

Glad you found a solution. :slight_smile:

For the benefit of other users coming by your post, would you be so kind as to share your MacOS version, in case your observed (mis)behaviour would be tied to that specifically?

Also, please note that although your issue has been solved by removing spaces, the discussion you linked was addressing a slightly different one, i.e. the spaces there prevented MacOS from sending a hostname at all, while in your case, MacOS sent a hostname it made up itself, differing from the one you configured.

Anyway, this seems like a veritable bug within Apple's OS to me. :wink:
(EDIT: And it's all the more confusing since the bulk of the names appearing in your MacBook correctly have dealt with spaces by replacing them with a hyphen "-".)

Yea, that's right, it's not exactly the same issue, but very similar and it pointed me directly to the solution.
I'm using the latest macOS Monterey (12.0.1).

I also just file a bug report to Apple.

1 Like

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