When we use VMWare Player to run guest operating systems, we sometimes want to automatically configure guest operating systems, such as, to assign fixed IP addresses to guest operating systems based on guest systems' network interfaces' MAC addresses.
This post discusses two items,
- to assign fixed IP address to interfaces of guest systems via VMWare's DHCP server
- and to change virtual subnet setting for virtual Ethernet segments using the
vmnetcfg
tool
Assigning Fixed IP Address
VMWare Player comes with a DHCP server that allows the guest systems to automatically configure their IP network settings. By configuring the DHCP server, we can achieve the auto-configuration purpose.
On Windows hosts, the configuration file of the DHCP server is located at directory
%ProgramData%\VMWare
. As an example, I show the value of
%ProgramData%\VMWare
below,
C:>echo %ProgramData%\VMWare
C:\ProgramData\VMWare
In the directory is the configuration file, i.e.,
vmnetdhcp.conf
. We can add host entries to the configuration file to assign fixed IP addresses to guest operating systems. Below is an example that assigns IP address 192.168.101.127 to MAC address 00:0c:29:22:12:4c in the virtual Ethernet segment 8.
# Virtual ethernet segment 8
# Added at 08/06/15 10:57:08
subnet 192.168.101.0 netmask 255.255.255.0 {
range 192.168.101.128 192.168.101.254; # default allows up to 125 VM's
option broadcast-address 192.168.101.255;
option domain-name-servers 192.168.101.2;
option domain-name "localdomain";
option netbios-name-servers 192.168.101.2;
option routers 192.168.101.2;
default-lease-time 1800;
max-lease-time 7200;
}
host VMnet8 {
hardware ethernet 00:50:56:10:00:01;
fixed-address 192.168.101.1;
option domain-name-servers 0.0.0.0;
option domain-name "";
option routers 0.0.0.0;
}
host Ubuntu {
hardware ethernet 00:0c:29:22:12:4c;
fixed-address 192.168.101.127;
option domain-name-servers 192.168.101.2;
option domain-name "";
option routers 192.168.101.2;
}
Changing Virtual Subnet Setting
One particular problem I often encounter is that the IP subnet setting is always changed when I upgrade or reinstall VMWare Player. For instance, in the above IP assignment example, the virtual Ethernet segment 8 is assigned a subnet of 192.168.101.0 with net mask 255.255.255.0 (i.e., 192.168.101.0/24); however, when I reinstall VMWare Player, the Ethernet segment 8's subnet assignment may become 192.168.157.0 with net mask 255.255.255.0 or some other value.
A simple method to change the Ethernet segment's subnet assignment back to the original value or any other valid value is to use the
vmnetcfg
tool.
The
vmnetcfg
tool is a part of VMWare Workstation; however, it does not come with VMWare Player. Since we can download VMWare Workstation trial version from VMWare's website, we can extract the tool from the installation package and use it with VMWare Player.
Two excellent posts that helped me and detail how one may extract the
vmnetcfg
tool from VMWare Workstation installation package and how one may use the tool to reassign a subnet to a virtual Ethernet segment are,
- Download vmnetcfg.exe & vmnetcfglib.dll for VMware Player 6.x & 7.x
- VMWare Interfaces Tutorial
For the impatient, the user interface of the
vmnetcfg
tool looks as follows,
It is obvious that one can change the subnet assignment to a selected virtual Ethernet segment.