Valid for VMware Server and Workstation for Linux:

Assalam-u-alaikum,

A few days back, a friend of mine gave me some VMware bare metal machines to play with. I was experimenting with with my new HPC cluster in VMware and decided to use those images as images for my compute nodes. I imported those VMware machines images into my VMware server 2.0, which I was running on Linux. After setting up a management node, with DHCP server, in the same virtual environment, I rebooted the compute nodes. I kept waiting, looking at PXE boot attempt on each comput node, trying to find a DHCP and TFTP server, but failed. The nodes could not find DHCP server! I was at my home at that time, with no other physical PC available to me, nor a physical network switchat my disposal. After a couple of service checks here and there on the management node and watching the log files, including tcpdump on a separate terminal, I figured out that no requests reaching the management node’s network interface. I tried giving a static IP to my eth0 interface on my laptop, and tried bringing it up manually, with something like this,

# ifconfig eth0 10.1.1.1 netmask 255.0.0.0 up

, but no progress. The packets could not reach the management node. I looked around in my junk to find RJ-45 loop-back adapter I made a couple of months ago. Luckily I found it! Plugged it in to the ethernet jack and whispered to my self, “this should do it”. But it did not. The mii-tool told me that the interface is still down. Ahhh! So I started checking various settings in my VMware server. I noticed that all my virtual machines were using bridged networking. No wonder they are not reaching the management node. Of-course they are looking for a real switch outside the physical PC /laptop. This is because in bridged networking, your machines, assume that the host computer is connected physically to some network switch. And all the packets from all virtual machines will travel to/fro the switch, in order to communicate with each other.

This made sense,of-course, so I decided to use a host only network within my host machine, which would have nothing to do with the external world or any other physical requirements. Changed network settings of all virtual machines, including the management node, in VMware server interface. I temporarily connected two other virtual machines to this host-only network, to see if this worked. They already had a small footprint installation of CENTOS on them. During their boot time, they acquired IP automatically from the DHCP server. But these IPs were different than the ones I expeted! Also I noticed “unknown lease” in my management node’s /var/log/messages file. Then from where did those machines get an IP? ! Checked /var/log/messages of my host machine and found out that this machine has given out IPs , where as I was not running a DHCP server on it. I wondered what was going on. So I checked internet and found out that VMware workstation and server have a built in DHCP server, which is run for NAT and host-only networks. This is not what I want ! So I started looking around on the internet to disable vmware’s built in DHCP server.

One of the solution was to use bridged networking, but not on your physical interface. Instead configure a bridged network on the loopback interface. This wayvmware will not start it’s own DHCP server. And at the same time you can still make allvirtual machines communicate with each other, without any need to connect to a physical network. This is not a big deal actually. You just need to re-run the vmware-config.pl script as root and define an additional virtual network as described above.

However, I was looking for some proper solution. After spending a couple of more days on the internet, I found an article who suggested to make changes in a particular script file, belonging to vmware. Doing the changes would basically skip the DHCP startup on all of the NAT and host-only networks on a VMware machine. Here is how to do it:-

Shutdown vmware service, by using:

# service vmware stop

Then, look for this file: /usr/lib/vmware/net-services.sh and make a copy of it, so you can revert back the changes.

# cp /usr/lib/vmware/net-services.sh /usr/lib/vmware/net-services.sh.orig

Then, edit the file:

# vi /usr/lib/vmware/net-services.sh

, and find the sections starting with: “vmware_start_dhcpd() {“ , and “vmware_stop_dhcpd() {“

Change these two sections as shown below. Disable or comment the lines as I have. :

# Start a DHCP server on a private IP network
vmware_start_dhcpd() {
local vHostIf=”$1” # IN

# The daemon already logs its output in the system log, so we can safely
# trash it

## commented by kamran to disable DHCP on 20090128 :-

##   cd "$vmdb\_answer\_BINDIR" && "$vmdb\_answer\_BINDIR"/"$dhcpd" \\\\  
##      -cf "$vmware\_etc\_dir"/"$vHostIf"/dhcpd/dhcpd.conf \\\\  
##      -lf "$vmware\_etc\_dir"/"$vHostIf"/dhcpd/dhcpd.leases \\\\  
##      -pf /var/run/"$dhcpd"-"$vHostIf".pid "$vHostIf"  
}

# Stop a DHCP server on a private IP network

vmware_stop_dhcpd() {
local vHostIf=”$1” # IN

## commented by kamran to disable DHCP on 20090128 :-

##   if vmware\_stop\_pidfile /var/run/"$dhcpd"-"$vHostIf".pid; then  
##      rm -f /var/run/"$dhcpd"-"$vHostIf".pid  
##   fi  
}

That’s it. Restart your VMware server or workstation service:-

service vmware restart

Now you can safely create your totally isolated NAT or host-only networks in VMware, which would not have a DHCP server running. Now, you can run your own DHCP server in those networks if you want. I had to use my management node’s DHCP server to boot off the compute nodes properly. So this of-course solved my problem.

By the way, you can run the “vmware-config.pl”as many times as you want, to define additional virtual networks in your host machine.

I hope this article would prove useful to people in similar situations.

Below are some related links:-

http://communities.vmware.com/message/364991

http://kb.vmware.com/selfservice/viewContent.do?externalId=2012&sliceId=2

Tahiati, (Regards),

Kamran