Skip to content

Hosts file management

Hosts file management involves the manual configuration of hostname-to-IP address mappings on local machines to facilitate network communication within a virtualized or isolated environment.^[600-developer-tools-vscode-vmware.md]

Windows hosts file

On Windows systems, the hosts file is located at a specific system path and requires administrative privileges to modify^[600-developer-tools-vscode-vmware.md].

  • File Location: C:\Windows\System32\drivers\etc^[600-developer-tools-vscode-vmware.md]

Common entries map specific IP addresses to easy-to-remember aliases (hostnames). For example, in a cluster of machines (w10–w29), entries would follow this format^[600-developer-tools-vscode-vmware.md]:

192.168.79.10 w10
192.168.79.20 w20
192.168.79.21 w21
...
192.168.79.29 w29

Linux hosts file

On Linux systems (such as CentOS or RHEL), the hosts file is located at /etc/hosts.^[600-developer-tools-vscode-vmware.md] The standard localhost definitions are usually pre-configured, but manual entries must be added for network nodes^[600-developer-tools-vscode-vmware.md].

To edit the file and map a hostname (e.g., w20) to an IP (e.g., 192.168.79.20), one would append the respective lines to the file^[600-developer-tools-vscode-vmware.md].

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.79.10 w10
192.168.79.20 w20
...
192.168.79.29 w29

Hostname configuration

Simply editing the hosts file does not change the system's actual hostname. On Linux distributions, the hostnamectl command is used to set the system identity^[600-developer-tools-vscode-vmware.md].

  • Command: hostnamectl set-hostname <new-hostname>^[600-developer-tools-vscode-vmware.md]

After running this command, a re-login is typically required for the changes to take full effect in the shell session^[600-developer-tools-vscode-vmware.md].

Verification

Once the hosts file and hostnames are correctly configured, communication between nodes can be verified using standard network tools.^[600-developer-tools-vscode-vmware.md]

For instance, pinging a hostname (e.g., w10) should resolve to the mapped IP address and result in a successful ICMP reply^[600-developer-tools-vscode-vmware.md].

  • [[Network configuration]]
  • [[Static IP]]
  • [[Virtualization]]

Sources

  • 600-developer-tools-vscode-vmware.md