Hostname changes on iMac 21" 2019 by itself

Dear Community, dear Apple Support,

on a iMac 21" 2019 with Ventura 13.3.1 I reconized these days, that the original hostname changes sometimes (from day to day or sometimes multiple times a day) with an added number -1, -2 and so on.

Has anyone seen this behaviour too and does anyone know how to fix this to get an stable hostname as known in the good old times? Thx in advance

Hathor27

iMac (2017 – 2020)

Posted on May 3, 2023 04:45 AM

Reply

Similar questions

8 replies

May 3, 2023 05:02 AM in response to Hathor27

It's possible that your DHCP service changes the IP address and therefore changes the hostname possibly given one the hosts file in /etc.

If you want it remain consistent, Change the router setting to assign your computer with an IP address. Then in the hosts file you can enter:


192.168.1.XXX desired_hostname_here


You'll need to reboot the computer after doing this. The hostname should then remain constant.

May 3, 2023 06:16 AM in response to Hathor27

Name and IP address space collisions existed before Macs were invented, and especially before Dynamic Host Configuration Protocol (DHCP) became available. It required careful system administration to avoid this issue.


If your router is correctly configured to provide DHCP services and your individual Mac(s) have the correct Network settings to receive the unique DHCP assignment from your router, then there should never be a need to change the default /etc/hosts file.


Here is the unmodified /etc/hosts file from my Ventura 13.3.1 Mac:


##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost 
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost


On each Mac, there should also be a unique local hostname set in Settings > General > Sharing panel. Check and correct that where necessary.


If you are using a Virtual Private Network (VPN) to connect to an outside service, that can temporarily change your local hostname via reverse DNS to a unique service originated hostname. This reverts when you disconnect the VPN connection.

May 3, 2023 07:06 AM in response to VikingOSX

Dear VikingOSX,

you're right, and I understand what you want to tell me.

I suppose I know very well the mechanism of DNS/DHCP (it's part of my job). I double checked the network configuration, the entries of /etc/hosts, Settings>General>Sharing and the hostname command in terminal. Everthing seems to be ok.

And under certain circumstances the hostname.local changes to hostname-1.local or hostname-2.local. In one case I even found different numbers in Settings>General>Sharing and the hostname command in the terminal.


And I never had this kind of trouble before - not even with this Mac before Ventura. It's (I suppose) since I run on Ventura and so I guess it is a matter of this version of macOS... (digging further)

May 3, 2023 07:37 AM in response to Hathor27

On my home LAN, I have two Macs running Ventura 13.3.1 (a), one running Monterey 12.6.5, a 2011 Mac mini running High Sierra, a 2013 iMac still running Mojave, an iPhone 14 Max Pro, and an Apple TV 4K +. Additionally, on the Monterey iMac, I have several VM guests each with their own unique hostnames, and these Parallel's guests (including W11Pro 22H2) are not receiving DHCP addresses from the Synology RT6600AX router but rather NAT in Parallels (for now).


I simply do not have name or address space collisions resulting in host name changes with generation values (e.g. hostname-1, *-n) occuring here.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Hostname changes on iMac 21" 2019 by itself

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.