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
Popularity: 100% [?]
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. [...]
Hi Max,
I have 3 development environments running under vmware fusion (2.0.7).
I’ve only just came across your article so I decided to try it out.
After making the required changes and restarting the vm services, the vm’s each come up with the correct ip, the ports are forwarded correctly, I can ssh into them from the host (i.e. host can see ubuntu guest) but for whatever reason I no longer have external network connectivity. i.e. I can no longer ping the gateway (i.e. the host) from within the guest. dns resolution fails also. I’m pretty stumped at this point. If i revert my changes, restart vmware services, reboot host and restart networking things are back to normal (i.e. ip from vmware dhcpd, can see gateway and can ping google). I’ve tried this dance a number of times and I’m seeing the same behaviour every time…
my nat.conf :http://pastebin.com/UDaLQDYR
my dhcpd.conf: http://pastebin.com/58KQb2hS
Do you have clue as to why I’m seeing this behaviour or how I can go about debugging this?
Very sorry to bother you like this but I’m desperate at this point (tried google, irc, vmware support forums)..
Thanks for reading,
Saimon
[...] 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 [...]
Glad I found this post – quick question: I need to set up a VIP for the Oracle SCAN address. The VIP needs 3 IP’s, what is the syntax I need to use to create one? I’m going to try a few, but if you know off-hand that would save me a lot of time. Thanks!
Is it just me, but when I try and restart my services, I keep getting the error “failed to start DHCP services on VMNET8″. This seems to not fix my ip on what I set it to be. Anyone have a solution on how to restart my services successfully. I have been able to do this in the past, but every one and then I struggle to successfully restart everything.
I found getting the Ethernet MAC address from ifconfig eth0 inside the guest machine
versus
the the line with ethernet0.generatedAddress in ~/Documents/Virtual Machines/GUESTMACHINENAME/GUESTMACHINENAME.vmx
is preferable as the ethernet0.generatedAddress value may be different than what guest machine is generating…
-Michael
Beautiful! Worked like a charm. Really struggled to find how to do this.
Thank you very much, I found similar information on the net, but since I’m new to linux web hosting (trying out in VM first), I couldn’t make sense of the information I saw, until I got here.
Very cool stuff. Works the same in Ubuntu, except for the following:
* dhcpd.conf is in /etc/vmware/vmnet8/dhcpd/dhcpd.conf
* restart vmware daemons with /etc/init.d/vmware restart
Works with vmplayer too!!
Thanks!!!!