Hostname changed to "Mac.lan" for no reason
A thread about this problem was opened in November that can be read here:
Hostname changed to "Mac.lan" for no reas… - Apple Community
The problem is that the hostname of a computer changes to Mac.lan for no reason after connecting to the network, despite the computer name (in System Settings > General > About) and Local hostname (in System Settings > General > Sharing) being set to something else. Even after resetting the name with "sudo hostname <originalname>" it eventually reverts back to Mac.lan. Disconnecting form the network restores the original name of the local hostname with the .local domain.
Having experienced this problem myself I tried searching for help but that thread was literally the only page that mentioned the problem. Unfortunately the problem was not resolved and now Apple has unhelpfully locked the thread so it cannot be answered. However I have worked out what is going so I apologize if posting in this way is against etiquette but I think it is more important to provide an answer for others in the same position.
The change of hostname appears to be related to the use of Private Wi-Fi address in Sequoia which by default will present a unique MAC address different to the hardware one to each network. It also seems to present a generic hostname of Mac to the network.
On my modem I assign a fixed LAN address to each device, this feature also takes a hostname which is given when it receives a DHCP request. The modem uses the domain .lan for the local network devices. Although I had set up my computer with the same hostname as set for the computer name and local hostname, I noticed it was not using this.
It appears what happened is because the computer was identifying itself with a different MAC address that was not in the modem's list it was being assigned a dynamic IP address, it also added the generic hostname of Mac used by the Private Wi-Fi address to its DNS database and so responded to the DHCP request with Mac.lan as the hostname.
I cannot see any way to change the behavior of the Private Wi-Fi address feature from identify itself as simply Mac to the modem, and my modem does not allow me other change how it responds to DHCP requests other than by assigning a fixed LAN assignment. Though as that is what I was doing anyway that is a suitable solution for me.
This does mean that with my modem it would not be possible to set Private Wi-Fi address to Rotating while retaining a consistent hostname. It would be nice if Apple provided an option to prevent it from also making the hostname private, though it appears the problem is the behaviour of the modem in assigning a hostname rather than Sequoia. If I connect to my iPhone as a hotspot it does not change the hostname.
But my solution was simply to update the MAC address on the modem to use the Wi-Fi address shown for my local network (System Settings > Wi-Fi > Details… of the connect network) rather than the hardware one. Now when connected to the network it is <hostname>.lan as assigned in the modem and when disconnected it used <hostname>.local as assigned in the System Settings.
I hope this helps other with the same problem, and I am sorry I could not have replied with this directly to the original thread
MacBook Pro 14″, macOS 15.3