Skip to content

Instantly share code, notes, and snippets.

@meash-nrel
Created October 23, 2014 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meash-nrel/c186fbe7e5eadf768eda to your computer and use it in GitHub Desktop.
Save meash-nrel/c186fbe7e5eadf768eda to your computer and use it in GitHub Desktop.
Assigning static IP address to VM in VMWare Fusion on Mac OSX Mavericks

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

1. Determine the MAC address of your guest machine

Let's say you have a guest machine with the name nrel-dev-centso6 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/nrel-dev-centos6.vmwarevm/*.vmx | grep ethernet0.generatedAddress

Copy the MAC address, e.g. 00:0c:29:59:6a:d0.

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

Open /Library/Preferences/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 192.168.234.0 netmask 255.255.255.0 {
	range 192.168.234.128 192.168.234.254;
	option broadcast-address 192.168.234.255;
	option domain-name-servers 192.168.234.2;
	option domain-name localdomain;
	default-lease-time 1800;                # default is 30 minutes
	max-lease-time 7200;                    # default is 2 hours
	option netbios-name-servers 192.168.234.2;
	option routers 192.168.234.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 nrel-dev-centos6 {
    hardware ethernet 00:0c:29:59:6a:d0;
    fixed-address 192.168.234.100;
}

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:

192.168.234.100   nrel-dev-centos

4. Restart the VMWare daemons

Last thing to do is restart your VMWare daemons:

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

If you are using VMWare Fusion 6, services.sh is in a different location.

sudo /Applications/VMware\ Fusion.app/Contents/Library/services.sh --stop
sudo /Applications/VMware\ Fusion.app/Contents/Library/services.sh --start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment