How to change the hostname of a VM using VMware

When I create VMs, my automatic hostname is localhost.localdomain. This is creating some networking issues from my VM to another Windows computer that I have (cannot ping to my VM). How can I change my hostname of my VM? Do I need to also change it inside my VM as well as in the vSphere Client?

Update: I have changed my hostname of my RHEL VM to say "MyVM" and verified this in /etc/hosts and /etc/sysconfig/network. However, I am still unable to ping to MyVM from another Windows computer on my network. Does this have anything to do with the dnsdomainname? I get dnsdomainname: Unknown host. On my vSphere Client, it still says the Host is localhost.localdomain, but from your responses below, it should not matter about what the vSphere Client says..

Any thoughts?

Thanks!!


Is your VM Linux or Windows? If Linux, edit /etc/hostname and /etc/hosts, to reflect the hostname you want. You do not need to change the name in vSphere client, it does not affect networking at all.


If you want to change the host name of the OS within the VM, you need to change it accordingly inside the VM. The "host name" for the VM in vSphere is basically a nickname and the setting is under "Virtual Machine Name." You can change it to what ever you would like it has no direct tie to the virtual machine OS host name.


You will need to change the hostname in the VM as well as in the vSphere Client.


You need to change the host name within the VM. (depending on OS: Windows under computer properties, Linux you would need to edit the /etc/hostname & /etc/hosts files) Then you can right click on the VM in the vSphere client and edit the settings > Options tab. However, in the datastore the names will not change unless you migrate the VMs off the datastore (and back on if that's where you want them.)