Question

What is the best way to have a virtual operating system have a static IP address in VMWware. I would like to keep the IP address static since it is a virtual server.

Was it helpful?

Solution

Assuming you're not using NAT-based VMWare networking, the answer isn't any different for a virtual (guest) server than for a real one. You can:

  • Assign a static IP via whatever mechanism the guest operating system supports.
  • Configure the guest operating system to get its IP address from a DHCP server, and configure the DHCP server to return a static IP address for the VMWare instance's MAC address.

OTHER TIPS

You can configure VMware DHCP server [which runs on host OS] to assign a fix IP address to a VM each time.

According to vmware docs, configuration is stored at the following locations:

Windows XP

C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf

Windows Vista or Windows 7

C:\ProgramData\VMware\vmnetdhcp.conf

Linux (host-only)

/etc/vmware/vmnet1/dhcp/dhcp.conf

Linux (NAT)

/etc/vmware/vmnet8/dhcp/dhcp.conf

VMWare Fusion for Mac (host-only)

/Library/Preferences/VMware Fusion/vmnet1/dhcpd.conf

VMWare Fusion for Mac (NAT)

/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf

Static IP and DNS name by MAC example:

host ubuntu {
    hardware ethernet 00:0c:29:c0:2c:58;
    fixed-address 192.168.118.3;
} 

For more details on this please see this blog post.

If you want the VM slice / VM machine (guest) to have a static IP, assign it to the VM slice. Then on the VM Server select "Bridged" for the network adapter settings. This tells VMWare to use what ever IP settings you have established on the guest.

This works on my machine

Follow these simple steps. Takes just 5 minutes.

1. Note the MAC of the VM
2. On the host machine open C:\ProgramData\VMware\vmnetdhcp.conf
    a. Or C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf 
    b. These 2 files are auto synced or mirrored. 
    c. Open the editor in Administrator mode. Eg notepad++. Otherwise you will get access denied message
3. Add a new entry at bottom of the configuration file, right before the "# End" marker. MyGuestVM is any unique name. Example below

host sunilW2008Server {
hardware ethernet 00-0C-29-05-2B-A0;
fixed-address 192.168.63.222;
}

3. Shutdown the VM and close the Workstation
4. Re-start the VMWare DHCP and NAT services for changes to take effect (From services.msc)

Notes: the below folders are at sync automatically.. change at one place and the same will be reflected on the other folder

C:\ProgramData\VMware C:\Documents and Settings\All Users\Application Data\VMware

A simple workaround, configure the vmware dhcp server to use longer leases. In the vmware config folder (on windows 7 -- C:\ProgramData\vmware) edit the file vmnetdhcp.conf and change the values of default-lease-time and max-lease-time to something bigger say 4 months (4mo*30days*24hours*60min*60sec = 10368000). Then restart the vmware dhcp server. Then release and renew the lease on the guest. Now your guest IP is static for next four months.

If you prefer to leave the VM host configuration as default, it is also possible to configure the guest machine to request a fixed address for dhcp. This will work even for the NAT network. In the case of Ubuntu and dhclient, this is achieved by the following block in dhclient.conf:

interface "eth0" {
    send dhcp-requested-address 192.168.1.222;
}

Source: https://serverfault.com/a/381137

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top