DHCP on VMware Fusion

Posted by max on March 04, 2008

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
  • Airport Extreme is a big disappointment. Or, (10?) Things I Hate About Apple
  • Trackbacks

    Use this link to trackback from your own site.

    Comments

    Leave a response

    1. john Tue, 04 Mar 2008 20:13:19 UTC

      Could you have NAT’ed the VMs?

    2. max Tue, 04 Mar 2008 20:14:59 UTC

      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?

    3. Steven Jackson Wed, 26 Mar 2008 11:55:41 UTC

      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.

    4. Pete Hartman Wed, 09 Apr 2008 17:09:53 UTC

      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.

    5. Greg Gallagher Sun, 25 May 2008 09:51:04 UTC

      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

    6. Quasar Fri, 30 Jan 2009 12:30:21 UTC

      Thank you Max!

      It worked like a charm! You saved me from some tedious work :)

      Cheers!
      Panos.

    7. Sigurd Foshaug Thu, 05 Feb 2009 12:10:28 UTC

      Thanks a lot for the good explanation.

    8. Kramer auto Pingback[...] DHCP on VMware Fusion | thirdbIT » Notes on manually configuring the DHCP servers in VMware Fusion. [...]

    9. Marc Tinnemeyer Wed, 08 Apr 2009 06:53:45 UTC

      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

    10. Adam Shand Fri, 01 May 2009 22:18:04 UTC

      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.

    11. Stuart Fri, 08 May 2009 11:49:40 UTC

      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

    12. planet Tue, 12 May 2009 22:56:40 UTC

      Kramer auto Pingback[...] How did I not hear of this before? Posted Sat 09 May 2009 07:06:53 AM EDT delicious Configuring DHCP on VMware Fusion A great article on where to find the dhcpd.conf file which VMware uses to manage IP assignments [...]

    13. pub:vmware-fusion [Stever.org.uk] Tue, 09 Jun 2009 05:36:01 UTC
    14. Christopher St. John Thu, 09 Jul 2009 08:50:03 UTC

      Thanks for the info, you saved me some tedious searching!

    15. Ben Fitzhardinge Sun, 16 Aug 2009 23:48:02 UTC

      thanks!
      worked perfectly!

    16. enrico Sat, 22 Aug 2009 10:31:38 UTC

      thank u 4 sharing this! :)

    17. Scott Tue, 25 Aug 2009 09:24:24 UTC

      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.

    18. max Tue, 25 Aug 2009 09:29:30 UTC

      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

    19. Scott Tue, 25 Aug 2009 09:43:40 UTC

      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.

    20. Tyler Bye Wed, 30 Sep 2009 10:32:56 UTC

      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.

    21. [...] Fusion can be configured to provde your instances with static IPs, which lets you make an entry in /etc/hosts for a domain like [...]

    22. Eric Van der Schilden Mon, 02 Nov 2009 16:02:15 UTC

      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
      ———————-

    23. [...] 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 [...]

    24. Craig Box Tue, 10 Nov 2009 05:47:30 UTC

      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.

    25. 百度搜索_No subnet declaration for VMnet8 Fri, 20 Nov 2009 00:53:11 UTC

      Kramer auto Pingback[...] segment to which interface…bbs.lampchina.net/thread-63173-1-1.html 20K 2009-4-27 – 百度快照 DHCP on VMware Fusion | thirdbIT For example, my vmnet8/dhcpd.conf had this in it: subnet 192.168….Fusion/vmnet8/dhcpd.conf line [...]

    26. [...] 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. [...]

    27. VMware Fusion - nat config in Fusion 3 Mon, 01 Feb 2010 08:59:40 UTC

      Kramer auto Pingback[...] make any changes to it. I finally found a clue on a comment left by someone on this blog post: http://www.thirdbit.net/articles/2008/03/04/dhcp-on-vmware-fusion/ There seems to be a bug in the way that boot.sh works on my system and I had to comment out the [...]

    28. [...] DHCP configuration article from the ThirdbIT blog [...]

    29. links for 2010-02-24 | kerstins kleiner blog Wed, 24 Feb 2010 22:04:27 UTC

      [...] DHCP on VMware Fusion | thirdbIT (tags: vmware fusion ip networking dhcp configuration) [...]

    30. [...] Shared DHCP on VMware Fusion | thirdbIT. [...]

    31. [...] Shared DHCP on VMware Fusion | thirdbIT. [...]

    32. Kramer auto Pingback[...] 鐣剁劧锛屾垜閭勬槸鍙互鎶婂晱椤岀暀钁楋紝閫忛亷鐩存帴瑷畾渚嗚畵绯荤当鍙互璺戣捣渚嗭紝鍙槸锛屾矑鏈夎嚜鍕曞寲鐨勬劅瑕虹湡鐨勪笉鏄偅妯g殑濂藉晩銆傛墍浠ユ壘浜嗘壘锛屾灉鐒惰畵鎴戞壘鍒颁簡瑙f硶銆傚鏋滀綘鎳跺緱鐪嬭嫳鏂囷紝ok锛屽氨鐪嬫垜绨$煭鐨勬柟娉曪紝濡傛灉浣犻倓瑕佹洿澶氭柟娉曪紝閭e氨鍘荤湅鐪嬪垾浜烘庨杭瑾槏銆 [...]

    33. Saimon Moore Fri, 11 Jun 2010 20:39:52 UTC

      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

    34. [...] 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 [...]

    35. Marly Fri, 13 Aug 2010 10:36:32 UTC

      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!

    36. Kramer auto Pingback[...] explained by this blog entry you can edit the dhcpd.conf file to configure VMWare Fusion’s DHCP server to assign specific [...]

    37. Kramer auto Pingback[...] References:聽http://www.thirdbit.net/articles/2008/03/04/dhcp-on-vmware-fusion/ and聽http://communities.vmware.com/message/829060#829060 Blog this! Bookmark on Delicious Recommend on Facebook Tweet about it Share on xing Subscribe to the comments on this post Print for later Bookmark in Browser Tell a friend [...]

    38. VMware Communities: nat config in Fusion 3 Sat, 19 Mar 2011 19:27:07 UTC

      Kramer auto Pingback[...] make any changes to it.  I finally found a clue on a comment left by someone on this blog post:http://www.thirdbit.net/articles/2008/03/04/dhcp-on-vmware-fusion/ There seems to be a bug in the way that boot.sh works on my system and I had to comment out [...]

    39. 192.168.216.0 - Virgilio Ricerca Web Wed, 23 Mar 2011 17:17:38 UTC

      Kramer auto Pingback[...] risultati per 192.168.216.0Anteprime disattivateDHCP on VMware Fusion | thirdbIT4 Mar 2008 … subnet 192.168.216.0 netmask 255.255.255.0 { range 192.168.216.128 192.168. 216.254; [...]

    40. Mike Fri, 22 Apr 2011 08:41:53 UTC

      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.

    41. Michael Fri, 22 Apr 2011 11:21:23 UTC

      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

    42. User:SteveB - MindTouch Community Portal Fri, 22 Apr 2011 12:56:58 UTC

      Kramer auto Pingback[...] DHCP on VMware Fusion [...]

    43. Kramer auto Pingback[...] This pretty much explains the problem I'm having: http://www.thirdbit.net/articles/2008/03/04/dhcp-on-vmware-fusion/ [...]

    44. Kramer auto Pingback[...] This pretty much explains the problem I'm having: http://www.thirdbit.net/articles/2008/03/04/dhcp-on-vmware-fusion/ [...]

    45. Rohit Nair Mon, 25 Apr 2011 19:45:15 UTC

      Beautiful! Worked like a charm. Really struggled to find how to do this.

    46. Glenn Nilsson Mon, 02 May 2011 13:09:30 UTC

      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.

    47. Kramer auto Pingback[...] DHCP configuration article from the ThirdbIT blog [...]

    48. Donnie Tue, 06 Mar 2012 04:23:51 UTC

      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!!!!

    Comments