Skip to content

Static IP configuration in VMware

Configuring a static IP within a VMware environment typically involves defining the address on the guest operating system (specifically Linux/CentOS in the provided context) while the VMware network adapter is set to a NET mode (often bridged or NAT).^[600-developer-tools-vscode-vmware.md]

Linux network configuration

To configure a static IP on a Linux system (e.g., ens33), you must modify the network interface configuration file.^[600-developer-tools-vscode-vmware.md] The primary differentiator for a static configuration is setting BOOTPROTO to static.^[600-developer-tools-vscode-vmware.md]

A typical static configuration file includes the following parameters^[600-developer-tools-vscode-vmware.md]:

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=ens33
DEVICE=ens33
ONBOOT=yes
PREFIX=24
IPADDR=192.168.79.20
GATEWAY=192.168.79.1
NETMASK=255.255.255.0
DNS1=192.168.79.1

For comparison, a DHCP configuration simply uses BOOTPROTO=dhcp and omits the specific IPADDR and GATEWAY lines^[600-developer-tools-vscode-vmware.md]. This allows the DHCP server to automatically assign network parameters^[600-developer-tools-vscode-vmware.md].

Hostname and Hosts configuration

After setting the IP, it is common practice to update the system's hostname and map it locally.

Setting the Hostname

The hostname can be changed using the hostnamectl command^[600-developer-tools-vscode-vmware.md]. For example:

hostnamectl set-hostname w20

You must re-login for the changes to take effect^[600-developer-tools-vscode-vmware.md].

Editing /etc/hosts

To ensure the system can resolve its own hostname and those of other nodes on the network, the /etc/hosts file should be edited^[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.21 w21
192.168.79.22 w22
# ... additional mappings

This allows for connectivity between nodes using their hostnames (e.g., ping w10)^[600-developer-tools-vscode-vmware.md].

Client-side configuration

Configurations on the host machine (e.g., Windows) are also necessary for name resolution.

Windows hosts file

On a Windows host, the hosts file is located at C:\Windows\System32\drivers\etc^[600-developer-tools-vscode-vmware.md]. Similar to the Linux guest, entries should be added to map IP addresses to hostnames^[600-developer-tools-vscode-vmware.md].

192.168.79.10 w10
192.168.79.20 w20
# ...

Sources

^[600-developer-tools-vscode-vmware.md]