VMWare - Virtual operating system static IP address
Asked Answered
T

6

15

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.

Tail answered 14/1, 2009 at 19:14 Comment(1)
I think it should be moved to SuperUser.Niece
E
17

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.
Eisenhower answered 14/1, 2009 at 19:19 Comment(0)
G
22

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.

Greek answered 24/4, 2013 at 10:12 Comment(1)
Worked great for me. Incase you vmx file has spaces in the name like: "Documents\Virtual Machines\CentOS 7 64-bit\CentOS 7 64-bit.vmx" you should use host 'CentOS 7 64-bit' {Scaffolding
E
17

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.
Eisenhower answered 14/1, 2009 at 19:19 Comment(0)
D
3

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.

Diatom answered 15/1, 2009 at 0:45 Comment(0)
B
3

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

Betwixt answered 13/2, 2014 at 5:47 Comment(0)
C
2

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.

Camelback answered 18/1, 2011 at 19:27 Comment(1)
No--this is not a static IP and I this is just bad advice. "Static IP" means that the IP will never change--not that it changes after a long time. Most reasons for using a static IP require the IP address to map to a particular machine on a network and sometimes those IP references are hardcoded into shortcuts, batch jobs, etc. Your strategy would wreak havoc should the lease expire.Exchequer
D
0

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

Dominus answered 27/9, 2016 at 8:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.