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

      Could you have NAT’ed the VMs?

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

      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 PDT

      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 PDT

      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 PDT

      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 PST

      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 PST

      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 PDT

      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 PDT

      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 PDT

      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 PDT

      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 PDT
    14. Christopher St. John Thu, 09 Jul 2009 08:50:03 PDT

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

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

      thanks!
      worked perfectly!

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

      thank u 4 sharing this! :)

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

      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 PDT

      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 PDT

      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 PDT

      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 PST

      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 PST

      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 PST

      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 PST

      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 PST

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

    Comments