DHCP on VMware Fusion
VMware Fusion is a wonderful thing. I am happily running three Linux instances at once under my MacBook with 4GB of RAM (though, as best I can tell, the mobo can actually only address 3GB of RAM).
One glitch that was driving me crazy, though, was that it seemed like DHCP leases were being allocated flakily to the guest machines. When you’re doing database replication, you can’t have master/slave IP addresses changing all the time. (And you certainly don’t want two machines with the same IP address!)
Some digging around turned this up. I don’t remember exactly where — I believe snippets of it were in an official VMware forum — but it was harder to find than it should have been. Hence my posting, to add another path to help those who need it.
On OS X, the file you need to change should be in /Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf. (vmnet8 is the virtual interface for NAT networking in the guest machines.) You should have a subnet clause in it already like this:
subnet 172.16.253.0 netmask 255.255.255.0 {
range 172.16.253.129 172.16.253.254;
option broadcast-address 172.16.253.255;
option domain-name-servers 172.16.253.2;
option domain-name "localdomain";
option routers 172.16.253.2;
}
Now, for each virtual machine, set up a new host clause, e.g. :
host ubuntu64-vm {
hardware ethernet 00:0F:FF:EF:00:00;
fixed-address 172.16.253.20;
}
Be sure to assign an IP address (fixed-address) outside the range specified in the subnet clause at top.
Get the Ethernet MAC address from ifconfig eth0 inside the guest machine, or from ~/Documents/Virtual Machines/GUESTMACHINENAME/GUESTMACHINENAME.vmx (it’s the line with ethernet0.generatedAddress).
Finally, restart the requisite VMware daemons by running
sudo "/Library/Application Support/VMware Fusion/boot.sh" --restart
Theoretically Related Posts
Trackbacks
Use this link to trackback from your own site.

Could you have NAT’ed the VMs?
The VMs are NATted. That’s what the vmnet8 interface is for on the host machine; vmnet1 is for bridged. I needed DHCP reservations because I was running MySQL replication between two guest machines.
Did I understand your question correctly?
Thanks for the helpful post.
I’m in a similar position (Linux based development via VMware on a Mac Pro), and having static IPs keeps things nice and predictable.
Excellent post, very very helpful at just the right time. And since I already know ISC DHCP I can do other things (like modifying the domain name for convenience) too.
One note I had major difficulty with. I couldn’t get vmnet-dhcpd to offer static leases due to one really dumb type-o, and I bet I won’t be the only one.
The excellent example given here is good, but it doesn’t match the IP address range my VMware Fusion was using by default, and I stupidly used the same fixed addresses. Sadly, it seems ISC’s DHCPd will simply give out dynamic addresses if you try to use it to assign addresses for which it doesn’t have configured on it’s own interface.
For example, my vmnet8/dhcpd.conf had this in it:
subnet 192.168.216.0 netmask 255.255.255.0 {
range 192.168.216.128 192.168.216.254;
option broadcast-address 192.168.216.255;
option domain-name-servers 192.168.216.2;
option domain-name “localdomain”;
option routers 192.168.216.2;
}
And I was trying to follow the above example, so I did something like this:
# Static addresses for VMs - gbg, 5/24/2008
host dargo {
hardware ethernet 00:0c:29:56:74:65;
fixed-address 172.16.253.10;
}
And kept banging my head as over and over again it kept assigning a dynamic address from the 192.168.216.x range .. finally, after much debugging I finally figured out the trick:
host dargo {
hardware ethernet 00:0c:29:56:74:65;
fixed-address 192.168.216.10;
}
Now, it assigns it perfectly. Much thanks to thirdbIT for taking the time and effort to post this information, hopefully I can give something back if someone can learn from my stupid mistake.
Cheers,
Greg
Thank you Max!
It worked like a charm! You saved me from some tedious work
Cheers!
Panos.
Thanks a lot for the good explanation.
Just keep in mind that a VMWare Fusion update seems to replace the dhcpd.conf file. Your version will be copied to s.th. like dhcpd.conf.old.0
Kind regards
Marc
Thanks for this post, you just saved me a bunch of messing about to track down how Fusion assigns DHCP address details.
Much appreciated!
Adam.
Just tried this, but it did not work.
The name that goes after “host” in the definition, is this:
a) The guest name as is defined by the directory name?
b) The guest-os name in the vmx file?
c) something else?
If it is the guest name as defined in the directory, then what do you do if your guest name has spaces in it like “Solaris 10 64-bit” or something.
Thanks,
Stuart
Thanks for the info, you saved me some tedious searching!
thanks!
worked perfectly!
thank u 4 sharing this!
Not sure if I’m being a plonker but this doesn’t appear to work for me.
Whenever I restart the server I get the following errors.
/Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf line 25: expecting a parameter or declaration.
ethernet
^
/Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf line 26: expecting a parameter or declaration.
fixed
^
This is the config I have. I’ve got the host name set to what the guest host name will be and this is not what it’s called on the file system (actually I’m a bit lazy as it’s called “Windows Server 2003 Enterprise Edition” in VMWare Fusion) but I’m assuming that the name in the dhcpd.conf file is arbitrary as it’s the MAC address that’s important.
subnet 172.16.139.0 netmask 255.255.255.0 {
range 172.16.139.128 172.16.139.254;
option broadcast-address 172.16.139.255;
option domain-name-servers 172.16.139.2;
option netbios-name-servers 172.16.139.2;
option domain-name “localdomain”;
option routers 172.16.139.2;
}
host tbexcad01 {
ethernet hardware 00:0c:29:ac:55:20;
fixed address 172.16.139.100;
}
I’m using Nano as a text editor and hand typing the whole thing (i.e. no copy and pasting) to make sure no rogue tabs or carriage returns exist, not that I know if that matters.
Any help would be much appreciated.
Thanks in advance.
Scott.
Scott,
It looks like there’s a couple of typos in your vmnet8/dhcpd.conf files.
Line 25 should read “hardware ethernet”, not “ethernet hardware”; line 26 should read “fixed-address”, not “fixed address.”
Cheers,
Max
Ummm… I’ll be the red faced Microsoft Exchange Engineer sitting over in the corner.
Thank goodness Microsoft, oops I mean Apple, oops did it again, Unisys invented the point and click interface.
Imagine the damage my fumbly fingers could do if Microsoft released some powerful shell type program to manage Windows and Exchange. Boy, let’s hope that never happens.
Thanks for the quick response Max. I’m no going to go play with my working VMWare Fusion.
Thanks again.
Hi Max,
Have you come up with a good method for preserving these configurations during Fusion upgrades? My confs get stomped everytime I upgrade and they don’t even bother to preserve them. I’ve contacted them about this issue and my pleas have apparently fallen on deaf ears.
[…] Fusion can be configured to provde your instances with static IPs, which lets you make an entry in /etc/hosts for a domain like […]
I have VMWare Fusion 3 and this solution doesn’t seem to work (anymore?).
The reason is that dhcpd.conf gets recreated every time the start or restart of boot.sh is executed.
The following lines:
—————————–
# Configure networking if the ‘networking’ file is missing or
# is older than ‘vmnet-cli’, i.e. installed files.
net_time=`stat -f %c “$LIBDIR/networking” 2>/dev/null` || net_time=0
cli_time=`stat -f %c “$LIBDIR/vmnet-cli”` || cli_time=0
if [ “$net_time” -le “$cli_time” ]; then
pushd “$LIBDIR”
“$LIBDIR/vmnet-cli” –configure
popd
fi
———————-
Make that “vmnet-cli –configure” gets executed each time the VMWare services start.
After commenting that line out, the dhcpd.conf file does not longer get overwritten, but I don’t know what the possible consequences are:
—————————–
# Configure networking if the ‘networking’ file is missing or
# is older than ‘vmnet-cli’, i.e. installed files.
net_time=`stat -f %c “$LIBDIR/networking” 2>/dev/null` || net_time=0
cli_time=`stat -f %c “$LIBDIR/vmnet-cli”` || cli_time=0
if [ “$net_time” -le “$cli_time” ]; then
pushd “$LIBDIR”
#”$LIBDIR/vmnet-cli” –configure
popd
fi
———————-
[…] are a couple of helpful blog posts (Nilesh Kapadia and Max Newell deserve a shout-out here) which help you with changing the DHCP settings given to your NAT or host […]
Eric: just came across this problem myself; the answer is to edit the ‘networking’ control file. See my post at http://craig.dubculture.co.nz/blog/2009/11/10/how-do-i-change-the-dhcp-subnet-for-nat-on-vmware-fusion-3-0/ for the details.
[…] whenever I need to nuke a box. So in case anyone else needs to do it, here’s how to give a static IP to a guest OS in VMWare Fusion. […]
[…] DHCP configuration article from the ThirdbIT blog […]
[…] DHCP on VMware Fusion | thirdbIT (tags: vmware fusion ip networking dhcp configuration) […]
[…] Shared DHCP on VMware Fusion | thirdbIT. […]
[…] Shared DHCP on VMware Fusion | thirdbIT. […]
[…] is set by VMWare’s dhcp server, and we can tell this server to always use the same address. [http://www.thirdbit.net/articles/2008/03/04/dhcp-on-vmware-fusion/] and聽 [http://www.nileshk.com/vmware-fusion-nat-dhcp-and-port-forwarding] B) Once the VM is set up […]