VMWare Workstation - Assign a static IP address

A virtual DHCP server, included with the installation of VMWare Workstation, assigns IP addresses in Host-Only and NAT network configurations. DHCP follows certain conventions when allocating IP address and sets aside a pool of addresses that it doesn’t assign. An IP address from this static pool can thus be assigned manually to a virtual machine, giving the VM a static IP address.

Why static IP?

Static IP address is a must have requirement if you are planning to setup an Active Directory domain. Server acting as domain controller must have static IP so that VMs, joined to the domain, can connect to the domain controller all the time. If the domain controller is set to get a dynamic address from DHCP then its IP address will change. This change in address doesn’t propagate to VMs joined to the domain, resulting in domain connection failure.

DHCP IP address pool

Following table outlines the conventions used by VMWare DHCP when allocating an IP address. The net value is the network number assigned to the host-only or NAT network. In below table, net value is 0.

To view the DHCP settings on your installation of Workstation, go to “Workstation --> Edit --> Virtual Network Editor --> Select Host-Only (VMnet1) or NAT (Vmnet8)”.

Assign a static IP address

There are two ways to assign the static IP address – by changing the IPv4 network settings of guest VM or by adding a configuration file entry to VMWare DHCP configuration file “vmnetdhcp.conf”.

Settings IP address on guest VM

You can assign a static IP address to VM by manually modifying its IPv4 network settings.

  • Find “net” value of your installation of Workstation by going to “Workstation --> Edit --> Virtual Network Editor --> VMnet1 (Host only) or VMnet8 (NAT) --> Note the “net” value e.g. net for my installation is 21 for host-only and 201 for NAT.
  • Select a static IP address from within the range of 192.168.net.3 – 192.168.net.127 for NAT network and 192.168.net.2 – 192.168.net.127 for Host-only.
  • Open the IPv4 network settings on guest VM by going to “Control Panel\Network and Internet\Network and Sharing Center\ --> Ethernet --> IPv4 --> Properties” and change:
    • IP address to static IP you choose
    • Default gateway to address of NAT device i.e. 192.168.net.2
    • Subnet mask: 255.255.255.0
    • DNS server to IP of NAT device

Remember in VMWare, NAT device also acts as a DNS server (or DNS proxy server that forwards the DNS requests to your actual Internet DNS server) and is your default gateway so make sure you set the NAT device IP (192.168.net.2) address in default gateway and preferred DNS server box.

Setting IP address in DHCP configuration file (Recommended)

All Windows Operating Systems by default are configured to get their IP settings from a DHCP. This setting works best and by changing them manually as outlined in above section is both cumbersome and difficult to maintain.

Consider a case where you have many VMs with static IP manually assigned. Over time, it becomes difficult to determine which static IP address is assigned to which VM. Answer to this problem is to keep the default settings in guest VMs i.e. to obtain IP from DHCP. But change the DHCP configuration file so that DHCP assigns the same IP address to guest VM every time, giving it a static IP.

Follow the steps below to change the DHCP configuration file. Make sure to create a backup before you make any changes.

  • Find out the MAC address of your VM by running “Run --> CMD --> ipconfig /all”.
  • Open the DHCP configuration file in Notepad by going to
    • For Windows XP: C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf“
    • For Vista and above: C:\ProgramData\VMware\vmnetdhcp.conf
  • Add a new entry at bottom of the configuration file, right before the "# End" marker. Replace the bold values with your VM; MyGuestVM is any unique name.

host MyGuestVM {
hardware ethernet 00:0c:29:23:b6:12;
fixed-address 192.168.201.3;
}

  • Shutdown the VM and close the Workstation
  • Re-start the VMWare DHCP and NAT services for changes to take effect

References

Comments

Popular posts from this blog

SharePoint 2013 Search Service Activation Error

Hybrid Apps using Cordova/PhoneGap: Ditch JQuery Mobile