VMware Communities
C_S_S
Contributor
Contributor
Jump to solution

Assign static IP to guest with NAT Virt Network Adaptor?

I am setting up a *nix VM which I would like to provide out-bound network connectivity, but I want to make its services (e.g. MySQL) only available to my local machine.  VMWare Player with NAT assigns a DHCP address, but because it doesn't update my host's name resolution, to access a service on the guest I need to use the IP address. 

I'd like to assign a static IP on the guest so I can add a user-friendly entry into my host's host file.  I can update my guests network interfaces file to assign it no problem.  I'm worried that I may use an IP address that overlaps the VMWare's DHCP pool (and may get an address conflict if I power up a new VM), or one outside the range of the virtual switch.

Is this possible with VMWare Player, and is there something in the configuration files I might be able to modify to do this?

1 Solution

Accepted Solutions
a_p_
Leadership
Leadership
Jump to solution

By default 192.168.x.1 address is used for the virtual host adapter, 192.168.x.2 as the NAT gateway address and 192.168.x.128...254 for DHCP, which means you can assign static IP addresses between 192.168.x.3 and ...127.

However, you may instead configure a reservation in the vmnetdhcp.conf file by adding e.g.

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

right in front of the "# End" marker. Please replace "156" with your own subnet. In the example above the VM with MAC address "00:0c:29:23:b6:12" will receive IP address "192.168.156.77". Btw. the host name (in this case "LuckyLuke") does not matter, it just needs to be unique within the file.

André

View solution in original post

2 Replies
a_p_
Leadership
Leadership
Jump to solution

By default 192.168.x.1 address is used for the virtual host adapter, 192.168.x.2 as the NAT gateway address and 192.168.x.128...254 for DHCP, which means you can assign static IP addresses between 192.168.x.3 and ...127.

However, you may instead configure a reservation in the vmnetdhcp.conf file by adding e.g.

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

right in front of the "# End" marker. Please replace "156" with your own subnet. In the example above the VM with MAC address "00:0c:29:23:b6:12" will receive IP address "192.168.156.77". Btw. the host name (in this case "LuckyLuke") does not matter, it just needs to be unique within the file.

André

C_S_S
Contributor
Contributor
Jump to solution

Yes, this led me exactly to the answer I needed.  Thank you!

A few other quick points for anyone else who finds this...

The file is located here (Windows 7): C:\Documents and Settings\All Users\Application Data\VMware

If I read the file correctly, it will assign DHCP addresses from X.Y.Z.128 to X.Y.Z.254 (up to 125 VMs).  The X.Y.Z.2 was used as a name server, and X.Y.Z.1 is the virtual switch.  So X.Y.Z.3 - X.Y.Z.127 are valid static IP address ranges. 

Also, for the the change to take effect you need to restar the VMWare DHCP service (I did both DHCP and NAT, but I think DHCP would have been sufficient).  Also, the VM needs to be powered off (not just in suspended mode).

In my case, adding the following to the end of the file (before the # END tag) worked...


host HerpDerp {
hardware ethernet 00:04:29:D2:F1:20;
fixed-address 192.168.21.15;
}

And of course in the c:\windows\system32\drivers\etc\hosts file the entry

192.168.21.15       Herpderp

Reply
0 Kudos