Setting Static IP on VMWare Fusion 10
July 16, 2018 ยท View on GitHub
Note: this guide last updated 20 June 2018, VMWare Fusion Professional Version 10.1.2 (8502123) on macOS High Sierra 10.13.5 (17F77)
Based on: http://henokmikre.com/blog/2015/09/vmware-static-ip
Beaker expects hosts to be accessible by hostname with passwordless root access via SSH. This guide covers setting a static IP and local hostname on a VMWare Fusion guest.
Basics
VMWare Fusion network configuration files are stored in:
/Library/Preferences/VMware Fusion/
These configurations are divided into folders by virtual networking device. In the base configuration, without any custom networking devices defined, the directory structure looks like this:
VMware Fusion/
thnuclnt/ # virtual print server configuration
.thnumod
manifest
thnuclnt
thnuclnt.conf
thnuclnt.convs
thnuclnt.types
thnucups
thnusetup.sh
vmnet1/
dhcpd.conf # dhcp daemon configuration
vmnet8/
dhcpd.conf # dhcp daemon configuration
nat.conf # nat configuration
nat.mac # list of used VM mac addresses
lastLocationUsed # path to "VMWare Fusion.app" last run
license-fusion-100-e4-201704 # license file
networking # network configuration check file
Virtual networks are called vmnet<num>:
vmnet1:
- is the default private (host-only) network
- called "Private to my Mac" in VM > Network configuration
- DHCP range 172.16.233.128 to 172.16.233.254
vmnet8:
- is the default public (NAT-enabled) network
- called "Share with my Mac"
- DHCP range 192.168.176.128 192.168.176.254
Every VMWare-generated dhcpd.conf file is auto-generated and contains a clearly labeled section for private use, with instructions for custom configuration. Here's an example:
# Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
#
# This file was automatically generated by the VMware configuration program.
# See Instructions below if you want to modify it.
#
# We set domain-name-servers to make some DHCP clients happy
# (dhclient as configured in SuSE, TurboLinux, etc.).
# We also supply a domain name to make pump (Red Hat 6.x) happy.
#
###### 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: 06/20/2018 14:34:59
allow unknown-clients;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours
subnet 192.168.176.0 netmask 255.255.255.0 {
range 192.168.176.128 192.168.176.254;
option broadcast-address 192.168.176.255;
option domain-name-servers 192.168.176.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.176.2;
option routers 192.168.176.2;
}
host vmnet8 {
hardware ethernet 00:50:56:C0:00:08;
fixed-address 192.168.176.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" #######
Modifying dhcpd.conf
These configuration files can contain customizations. All custom configuration lines should be written outside of the clearly labeled private section. It's not clear if they can safely be placed above this section, so I recommend only placing them below it.
You shouldn't try to override the subnet configuration directive. See Modifying the DHCP settings of vmnet1 and vmnet8 in Fusion (1026510)
. Tl;DR: change settings in the private area (e.g. netmask and subnet) by modifying networking.
You can, however, provide new host directives. This is what we want to do. As far as I can tell, the syntax is like such:
host <host id> {
<command with args>;
}
Known configuration directives:
hardware ethernet <mac address>;
fixed-address <ipv4 address>;
option domain-name-servers <ipv4 address>;
option domain-name "string";
option routers <ipv4 address>;
Setting a Static IP for a VM
- Gather VM configuration information
- Hostname: VM > Settings > General > name. I don't know what restrictions there are on VM names, so recommend the safe approach of ensuring that you set the VM name only once, upon creation, and only use safe characters like
[a-z0-9\-]. If you have special characters or spaces, it may be possible to quote the hostname but I haven't tested that. According to this VMWare forum post, spaces should be stripped. E.g. "Windows 8" becomes "Windows8". - Virtual network name: VM > Settings > Network. "Share with my Mac" is
vmnet8, "Private to my Mac" isvmnet1. - MAC address: VM > Settings > Network > Advanced
- Hostname: VM > Settings > General > name. I don't know what restrictions there are on VM names, so recommend the safe approach of ensuring that you set the VM name only once, upon creation, and only use safe characters like
- Edit the appropriate
dhcpd.confin/Library/Preferences/VMware Fusion/<virtual network name>/dhcpd.conf. Take note of the line that looks like (last checked: line 27):
As this specifies the DHCP reservation range. We must select an IP outside of this range. Add the following:range 192.168.176.128 192.168.176.254;host <hostname> { hardware ethernet <host mac>; fixed-address <static ip>; } - Regenerate the configuration files and restart the virtual networking stack:
Note: pretty sure VMWare and even the target VM can be running while you do this.$ sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --configure $ sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop $ sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start
Complete example, to set fixed IP address of 192.168.176.127 on host ubuntu-1604-64 with MAC 192.168.176.127:
$ sudo tee -a "/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf" <<EOF
host ubuntu-1604-64 {
hardware ethernet 00:0C:29:C5:28:82;
fixed-address 192.168.176.127;
}
EOF
$ sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --configure
$ sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop
$ sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start
Debugging
If your VMs don't get DHCP leases and VMWare Fusion > Preferences > Network settings is greyed out (and you don't want to restart your machine).
- Quit Fusion
- Stop networking from the CLI
- Look for any leftover processes to kill
# Quit VMWare Fusion from the GUI first, then:
$ sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop
$ ps aux | grep vm
root 90722 0.0 0.0 4377632 3096 ?? Ss 2:15PM 0:00.44 /Library/PrivilegedHelperTools/com.vmware.KextControlHelper
root 90721 0.0 0.0 4377632 3140 ?? Ss 2:15PM 0:00.22 /Library/PrivilegedHelperTools/com.vmware.VMMonHelper
root 90589 0.0 0.0 4387172 840 ?? S 2:15PM 0:00.06 /Applications/VMware Fusion.app/Contents/Library/vmnet-bridge
dakota.schneider 11615 0.0 0.0 4267768 1024 s011 S+ 10:30AM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn vm
$ sudo kill -9 90589
Now restart Fusion. If you can access VMWare Fusion > Preferences > Network list (it's not greyed out), then your VMs should get DHCP without having to manually restart vmnet after boot or resume.
Edit /etc/hosts
The acceptance tests rely on using hostnames. We need one machine beaker-ubuntu.local and one beaker-ubuntu2.local, or whatever matches the hostnames in acceptance/config/nodes/test-nodes.yml.