VMware Communities
Viki7712
Contributor
Contributor
Jump to solution

how to give guest a static ip address

i am using vmware station 7.1.2. I have windows 7 and installed ubuntu 10.04 as guest.

The guest is using NAT and its ip address kept changing. is there a way i can give this guest a static IP address (192.168.21.133).

feelexit@ubuntu:/etc$ ifconfig

eth0 Link encap:Ethernet HWaddr 00:0c:29:2c:70:38

inet addr:192.168.21.133 Bcast:192.168.21.255 Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fe2c:7038/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:634 errors:0 dropped:0 overruns:0 frame:0

TX packets:41 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:46372 (46.3 KB) TX bytes:5892 (5.8 KB)

Interrupt:19 Base address:0x2024

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
WoodyZ
Immortal
Immortal
Jump to solution

In addition to what I've already said if you are looking to assign a specific IP Address to a specific VM via the dhcp.conf file on the Host this can be done by adding the following to the target dhcp.conf file. Note that the VM should be shutdown, not suspended and the VMware Network Services should be stopped before making the edit and then restarted.

Example:

host Fedora13 {
hardware ethernet 00:0c:29:c1:90:02;
fixed-address 192.168.70.20;
}

In the example above "host Fedora13" actually refers to the Guest's .vmx configuration file name without any spaces in even though the actual name of the .vmx configuration file on my system is "Fedora 13.vmx" and "hardware ethernet 00:0c:29:c1:90:02;" contains the MAC Address that was assigned to the VM in the target .vmx configuration file in the "ethernet0.generatedAddress" parameter. I added this to the dhcp.conf file for vmnet8 on my system and when the VM is running and the Guest OSes Network Adapter is configured for DHCP it always gets assigned the address above along with the proper subnet mask, Gateway IP Address and DNS Servers for VMnet8.

==========

The following information I have in my notes although IIRC it came from a VMware KB Article or Document.

Address Use on a Host-Only Network

Range

Address Use

Example

<net>.1

Host Machine

192.168.0.1

<net>.2 - <net>.127

Static Addresses

192.168.0.2 - 192.168.0.127

<net>.128 - <net>.253

DHCP Assigned

192.168.0.128 - 192.168.0.253

<net>.254

DHCP Server

192.168.0.254

<net>.255

Broadcasting

192.168.0.255

Address Use on a NAT Network

Range

Address Use

Example

<net>.1

Host Machine

192.168.0.1

<net>.2

NAT Device

192.168.0.2

<net>.3 - <net>.127

Static Addresses

192.168.0.3 - 192.168.0.127

<net>.128 - <net>.253

DHCP Assigned

192.168.0.128 - 192.168.0.253

<net>.254

DHCP Server

192.168.0.254

<net>.255

Broadcasting

192.168.0.255

View solution in original post

0 Kudos
16 Replies
WoodyZ
Immortal
Immortal
Jump to solution

This is not to say that it can't be done on the Host by manually editing various files as it can however I suspect you're referring to the normal method one takes under any OS and to that extent this really isn't a VMware Workstation issue per se. In other words assigning a Static IP Address in a Guest OS is a Guest OS issue and as such you should consult the documentation for the Guest OS you're using.

Keep in mind though that you need to assign proper information that corresponds to the Subnet Address, etc. that you're using and that the IP Address should be outside the scope of the DHCP Server IP Address Pool and typically with VMware Desktop Products the last octet can be between 3 and 127 on an IPv4 Address.

For Ubuntu 10.4 have a look at:

Ubuntu Documentation > Ubuntu 10.04 > Internet and Networks > Ways of Connecting > Wired (LAN)

Or

Ubuntu Documentation > Ubuntu 10.04 > Ubuntu Server Guide > Networking > Network Configuration

0 Kudos
joehecht
Enthusiast
Enthusiast
Jump to solution

I suspect that you are asking if the VM Nat system can support a reserved address. This is where a given network device (with a given network name or mac address) is always given the same IP address?

I am unaware of such support, however, I too have wished for this, and if itr does not exist in the VMNet system, feel that the lack of this ability would be a bit shortsighted.

I have had to do a lot of work to get around this problem.

I would love to hear from anyone that can point me to any docs for providing a reserved IP under the VM NAT system.

Joe

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

In addition to what I've already said if you are looking to assign a specific IP Address to a specific VM via the dhcp.conf file on the Host this can be done by adding the following to the target dhcp.conf file. Note that the VM should be shutdown, not suspended and the VMware Network Services should be stopped before making the edit and then restarted.

Example:

host Fedora13 {
hardware ethernet 00:0c:29:c1:90:02;
fixed-address 192.168.70.20;
}

In the example above "host Fedora13" actually refers to the Guest's .vmx configuration file name without any spaces in even though the actual name of the .vmx configuration file on my system is "Fedora 13.vmx" and "hardware ethernet 00:0c:29:c1:90:02;" contains the MAC Address that was assigned to the VM in the target .vmx configuration file in the "ethernet0.generatedAddress" parameter. I added this to the dhcp.conf file for vmnet8 on my system and when the VM is running and the Guest OSes Network Adapter is configured for DHCP it always gets assigned the address above along with the proper subnet mask, Gateway IP Address and DNS Servers for VMnet8.

==========

The following information I have in my notes although IIRC it came from a VMware KB Article or Document.

Address Use on a Host-Only Network

Range

Address Use

Example

<net>.1

Host Machine

192.168.0.1

<net>.2 - <net>.127

Static Addresses

192.168.0.2 - 192.168.0.127

<net>.128 - <net>.253

DHCP Assigned

192.168.0.128 - 192.168.0.253

<net>.254

DHCP Server

192.168.0.254

<net>.255

Broadcasting

192.168.0.255

Address Use on a NAT Network

Range

Address Use

Example

<net>.1

Host Machine

192.168.0.1

<net>.2

NAT Device

192.168.0.2

<net>.3 - <net>.127

Static Addresses

192.168.0.3 - 192.168.0.127

<net>.128 - <net>.253

DHCP Assigned

192.168.0.128 - 192.168.0.253

<net>.254

DHCP Server

192.168.0.254

<net>.255

Broadcasting

192.168.0.255

0 Kudos
joehecht
Enthusiast
Enthusiast
Jump to solution

Ok WoodyZ!

I owe ya dinner for this one! If you ever find yourself in the NW Florida Panhandle, please stop by and collect!

Specifically, I found:

The host name given does not seem to matter (although it should probably be unique, probably contain no spaces, and in good practice should try to identify the VM).

The dhcp.conf file (for me under Winx64) was in:

C:\ProgramData\VMware\vmnetdhcp.conf

You can probably add the host lines anywhere, but I placed mine after the ending curly for the vm netcard entry I was using (host VMnet8 in my case)

Making the edit, then calling the following two lines from a batch file, and refreshing the net adapter in the VM was all it took:

net stop VMnetDHCP

net start VMnetDHCP

Your suggestion to stop the net service and the VM before making the change is no doubt good practice, but non the less, like most good routers, it does seem to work "live" (given that there are no conflits in the live edit).

Now, if you could just tell me the settings for getting a single VM to fit itself into non-swappale RAM on a Windows host...

Thanks again!

Joe

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

The host name given does not seem to matter (although it should probably be unique, probably contain no spaces, and in good practice should try to identify the VM).

Yes the host name in this case is just an identifier and must not contain any spaces. The IP Address is assigned to the specified "hardware ethernet" AKA the MAC Address. So the VM with the assigned MAC Address will get the assigned IP Address.

You can probably add the host lines anywhere, but I placed mine after the ending curly for the vm netcard entry I was using (host VMnet8 in my case)

Making the edit, then calling the following two lines from a batch file, and refreshing the net adapter in the VM was all it took:

I place it after the " ... End of "DO NOT MODIFY SECTION" ... " line.

Your suggestion to stop the net service and the VM before making the change is no doubt good practice, but non the less, like most good routers, it does seem to work "live" (given that there are no conflits in the live edit).

As a general rule I always stop services before modifying the configuration in a case like this and usually shutdown, not suspend and close the VMware Desktop product. Now I don't always however understand that depending on the actual product/version/host/guest it can actually be a requirement as the changes could actually be overwritten otherwise depending on the actual product/version/host/guest. Now if you are totally sure of all the idiosyncrasies of the products your using then obviously you are at liberty to not follow directions verbatim. This has probably has been a issue more so with VMware Fusion in the past then VMware Workstation and since I use both as well as other VMware products I tend to give directions in what I consider a safer more logical flow but I don't always follow my own directions either. Smiley Wink

0 Kudos
joehecht
Enthusiast
Enthusiast
Jump to solution

I place it after the " ... End of "DO NOT MODIFY SECTION" ... " line.

Apparently, they left out of ours. Checking one of my client's installs, they left it out for them too...

If it is not a stock item, where can I pick one up?

Are they available at an aftermarket shop, or is thiis some sort of clandestine add-on, and only available under the table?

J

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Under Linux and Mac OS X that line is there. Attach is an example VMnet8 dhcp.cong from the Linux version of VMware Workstation 7.1.2.

0 Kudos
Viki7712
Contributor
Contributor
Jump to solution

where is this dhcp.conf file. I only find this file "VMnetDHCP.exe", coudn't find any files end with .conf

I have windows 7 32 bits installed.

here's my vmware folder "C:\Program Files\VMware\VMware Workstation"

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

where is this dhcp.conf file

Sorry it's dhcp.conf on Linux and Mac OS X and there is a separate file for each VMnet above 0 and on Windows there is just one.

On Window 7 Host it should be at: C:\ProgramData\VMware\vmnetdhcp.conf

0 Kudos
Viki7712
Contributor
Contributor
Jump to solution

WoodyZ, thank you.

but I dont have programData folder, mine is "C:\Program Files\VMware\VMware Workstation", there's no "vmnetdhcp.conf", i only see "vmnetdhcp.exe" file there.

I also checked "C:\Program Files\VMware\" folder, nothing there neither, only one folder there "VMware Workstation"

0 Kudos
joehecht
Enthusiast
Enthusiast
Jump to solution

You might want to search your hard drive for vmnetdhcp.conf.

It is not going to be in program files.

What verison of Windows are you running?

J

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

What verison of Windows are you running?

In the very first line at the start of this thread the OP states "i am using vmware station 7.1.2. I have windows 7 and installed ubuntu 10.04 as guest." Smiley Wink

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

but I dont have programData folder

You stated in the opening of this thread that you are using Windows 7 as the Host so you do indeed have a C:\ProgramData folder however keep in mind that this is a hidden folder and by default you cannot see hidden folders.

0 Kudos
joehecht
Enthusiast
Enthusiast
Jump to solution

with 11,943 posts

**Eleven Thousand Nine Hundred Fourty Three and 00/100*** posts

Scribes:

In the very first line at the start of this thread the OP states 😉

Thanks for the double post reminder. I'm getting fogetfull in my old age.

Smiley Wink back at ya sailor!

0 Kudos
Viki7712
Contributor
Contributor
Jump to solution

Woodyz, you are right, its hidden folder.

here's the code that in that file.

host VMnet8 {

hardware ethernet 00:50:56:C0:00:08;

fixed-address 192.168.21.1;

option domain-name-servers 0.0.0.0;

option domain-name "";

option routers 0.0.0.0;

}

  1. End

Ichanged 192.168.21.1 to "192.168.21.134", restart vmware. everythign works.

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

If you are trying to do what you asked in the subject of this thread you started, "how to give guest a static ip address", then why are you messing around with modifying the IP Address of the Host's VMnet8 Virtual Network Adapter and placing in in a range that by default is in the DHCP Servers IP Address Pool?

You said you wanted was to give a Guest a Static IP Address and what you've done is modify the the Host's VMnet8 Virtual Network Adapter's IP Address and you doing this is not what you originally said you wanted to do!

0 Kudos