So Called Geek

​The ramblings of a so called geek

Fixed DHCP IP allocation in VMware Fusion

There comes a point when using NAT for your VM's, that having a predictable IP address just makes sense. If you are running any sort of server inside your VM, you don't want to go around hunting for the current address each time, or worse still have to modify the configuration of the server itself.

Luckily we can fix this through a modification to the DHCP configuration file for the vmnet8 interface used for NAT. I'm currently using VMware Fusion 5 and the configuration file can be located at: /Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf.

(I'm fairly sure the same location applies to Fusion 4, however with earlier versions you may find it located at: /Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf)

Delving into the Fusion DHCP server configuration reveals that the default lease time is 30 minutes, making it no surprise that we end up with a different IP address each time. 

###### VMNET DHCP Configuration. Start of "DO NOT MODIFY SECTION" #####
# Modification Instructions: This section of the configuration file contains
# information generated by the configuration program. Do not modify this
# section.
# You are free to modify everything else. Also, this section must start
# on a new line
# This file will get backed up with a different name in the same directory
# if this section is edited and you try to configure DHCP again.

# Written at: 08/23/2012 07:47:20
allow unknown-clients;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours

subnet 192.168.247.0 netmask 255.255.255.0 {
range 192.168.247.128 192.168.247.254;
option broadcast-address 192.168.247.255;
option domain-name-servers 192.168.247.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.247.2;
option routers 192.168.247.2;
}
host vmnet8 {
hardware ethernet 00:50:56:C0:00:08;
fixed-address 192.168.247.1;
option domain-name-servers 0.0.0.0;
option domain-name "";
option routers 0.0.0.0;
}
####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######

In order to make a reservation for our host we are going to create the following entry preceding the "DO NOT MODIFY SECTION" and then change it's values to reflect those of our VM.

host vm-hostname {
hardware ethernet 00:0F:FF:EF:00:00;
fixed-address 192.168.247.127;
}

vm-hostname - this should be the host name of the VM for which you are creating the entry.
hardware ethernet - the MAC address of the VM.
fixed-address - this is used to specify the IP address you would like to assign to the VM

(An important thing to note is the IP address you choose for your fixed-address should be outside the range specified in the subnet block of the "DO NOT MODIFY SECTION". In my configuration above the range to avoid is between 192.168.247.128 and 192.168.247.254, therefore I have picked the first IP preceding that which will be 192.168.247.127)

The final thing we need to do is restart the boot.sh service and then start our VM.

Fusion 4 / 5

If you are using Fusion 4 / 5 like me then just restart Fusion if you have it open.

Fusion 3 and earlier

If you are using Fusion 3 or earlier then either reboot your machine or follow the steps, which I have copied from the VMware Knowledge Base article 1004023.

    1. Open Terminal from /Applications/Utilities.
    2. Copy and paste this command in Terminal:

      sudo /Library/Application\ Support/VMware\ Fusion/boot.sh --restart

    3. Press Return.

      You are prompted you to enter your Mac administrator password. 

    4. Enter your Mac administrator password to authenticate the action. 

      Note: Your password is not echoed (repeated on the screen as you type), for security purposes.