Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save pjkelly/1068716 to your computer and use it in GitHub Desktop.
Save pjkelly/1068716 to your computer and use it in GitHub Desktop.
VMWare Fusion Images with a static IP Address on Mac OS X Snow Leopard

How to setup your VMWare Fusion images to use static IP addresses on Mac OS X

At Crush + Lovely, we use Railsmachine's Moonshine to automate the configuration of our servers. When writing our deployment recipes, VMWare Fusion's ability to take snapshots and rollback to these snapshots is a huge timesaver because it takes just seconds to roll a server image to it's original state.

When you're just configuring a single server, having a static IP address for your server image isn't too important, but when you're configuring multi-server setups, it can be useful to duplicate a number of server images and give each a static IP address so you can consistently deploy to them. While not documented well at all, it turns out that this is relatively easy to accomplish in four simple steps.

1. Determine the MAC address of your guest machine

Let's say you have a guest machine with the name ubuntu-lucid-lynx-base and you keep your guest machine images in ~/Documents/Virtual\ Machines/. To determine the MAC address for this VM, you can run:

cat ~/Documents/Virtual\ Machines/ubuntu-lucid-lynx-base.vmwarevm/ubuntu-lucid-lynx-base.vmx | grep ethernet0.generatedAddress

If more than one line is returned, you're looking for the one with the value like 00:0c:29:9d:2a:38.

2. Add your static IP address to VMWare's dhcpd.conf

Open /Library/Application\ Support/VMware\ Fusion/vmnet8/dhcpd.conf. vmnet8 is the virtual interface for NAT networking in VMWare the guest machines. In this file, you'll see a subnet clause that looks something like this:

subnet 172.16.179.0 netmask 255.255.255.0 {
	range 172.16.179.128 172.16.179.254;
	option broadcast-address 172.16.179.255;
	option domain-name-servers 172.16.179.2;
	option domain-name localdomain;
	default-lease-time 1800;                # default is 30 minutes
	max-lease-time 7200;                    # default is 2 hours
	option routers 172.16.179.2;
}

Take note of the line starting with range. The IP addresses you will assign your guest machines will need to fall outside that range. Find the line that looks like this:

####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######

Below that line, add a clause for your guest machine. It should look like this:

host ubuntu-lucid-lynx-base {
    hardware ethernet 00:0c:29:9d:2a:38;
    fixed-address 172.16.179.102;
}

Make sure the hardware ethernet value matches the MAC address you found in step one, and the fixed-address is an IP outside the range listed in the subnet clause.

3. Optional: Update your /etc/hosts file

If you want to assign a fancy local hostname that refers to your guest machine, you can do so by editing your /etc/hosts file. For instance, to assign the hostname ubuntu.local to the guest machine we just setup, we could add the following line to our /etc/hosts file:

172.16.179.102 ubuntu.local

4. Restart the VMWare daemons

Last thing to do is restart your VMWare daemons:

sudo "/Library/Application\ Support/VMware\ Fusion/boot.sh" --restart
@jhalterman
Copy link

Restarting w/VMWare Fusion 7

sudo /Applications/VMware\ Fusion.app/Contents/Library/services/services.sh --stop
sudo /Applications/VMware\ Fusion.app/Contents/Library/services/services.sh --start

@skplunkerin
Copy link

thank you @bryancallahan that's exactly the piece I was missing, now everything works as it should :)

@sjbylo
Copy link

sjbylo commented Jan 29, 2018

I was having a problem finding the correct "VM name" as I thought it was the name of the VM itself. Then I discovered the actual name that the DHCP Client was sending to the virtual DHCP Server was the system hostname, e.g. the output of the command hostname. To verify which name the system is using, look into the DHCP Client configuration.

ps -ef | grep dhc

In the output, find the name of the .conf file and look into it.

cat /var/lib/NetworkManager/dhclient-ens33.conf
...
send host-name "master";
...

The line shown shows you the exact hostname to use in Fusion's vmnet8/dhcpd.conf file as described above. Hope that helps.

@aelkz
Copy link

aelkz commented Aug 19, 2020

VMWare Fusion 11.0.2 w/ OSX 10.14:

sudo /Applications/VMware\ Fusion.app/Contents/Library/services/services.sh --stop
sudo /Applications/VMware\ Fusion.app/Contents/Library/services/services.sh --start

@trevorh
Copy link

trevorh commented Feb 10, 2021

For Windows hosts (at least tested with 10 and Fusion 12.1), you need to ensure that in the dhcp.conf the hostname is the Windows Computer Name as given in a cmd window by the hostname command.

      image

host SQLServer-W10x64 {
    hardware ethernet 00:0c:29:9d:2a:38;
    fixed-address 172.16.179.102;
}

You might also need to delete the DHCP leases entry in /var/db/vmware/vmnet-dhcpd-vmnet1.leases or /var/db/vmware/vmnet-dhcpd-vmnet8.leases depending on whether you're dealing with the private/Host-only or NAT DHCP server.

There seem to be issues with Big Sur but I haven't upgraded yet. See here and here. Seems Big Sur doesn't allow Fusion to have its own DHCP servers and therefore manages it for Fusion.

@zarinfam
Copy link

zarinfam commented Jan 4, 2023

Very helpful, especially the comments thanks.

@therealevanhenry
Copy link

This was the best resource I found online to help me configure a guest VM with a static IP on MacOS. It's kind of surprising VMWare doesn't have better documentation for Fusion's networking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment