Adding a new entry to /etc/hosts file when a Linux VM is customized to DHCP IP
search cancel

Adding a new entry to /etc/hosts file when a Linux VM is customized to DHCP IP


Article ID: 303157


Updated On:


VMware vCenter Server


This article provides information about a new entry like newFQDN newHostname being added to the /etc/hosts file in the Linux guest running in a customized VM and how to avoid it if this entry breaks any services.

Note: When a VM with Linux guest is customized with DHCP IP and a new hostname but with no loopback entry like 127.*.*.* FQDN Hostname (127.*.*.* is usually present in its /etc/hosts file, a new entry like newFQDN newHostname will be added to the /etc/hosts file inside the guest.

However, when an entry like FQDN Hostname exists in /etc/hosts inside the guest before customization, customizing the VM with static IP will modify existing loopback entry to newFQDN newHostname and also add a static IP entry like aaa.bbb.ccc.ddd newFQDN newHostname to /etc/hosts file. This may break services that rely on FQDN or Hostname to get IP address.


This behavior is as per design.

To work around this issue, use one of these options to avoid FQDN Hostname to be added by guest customization:
  • Customize the Linux VM to the static IP aaa.bbb.ccc.ddd directly, then only the static IP entry aaa.bbb.ccc.ddd FQDN Hostname will be added to /etc/hosts file.
  • Customize the Linux VM by cloud-init based guest customization to either DHCP IP or static IP. In this case, no FQDN Hostname entry will be added.