Skip to content

Instantly share code, notes, and snippets.

@HoriLiu
Forked from mrbuk/README.md
Created April 4, 2017 02:24
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 HoriLiu/6eea94bb9749b383ba8467e5f9e4dac1 to your computer and use it in GitHub Desktop.
Save HoriLiu/6eea94bb9749b383ba8467e5f9e4dac1 to your computer and use it in GitHub Desktop.
Sticky IP addresses with VMWare Fusion

It is possible in VMWare Fusion to ensure that a VM will always be assigned the same IP address - this is more convenient than making the VM use static IP via config of the Linux box it uses. The simplest way to achieve this is as follows (all performed on the Mac host, not the Linux guests)

sudo vim /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf

At the bottom of the file, after the following line:-

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

Before changing the configuration file it is recommended to put the vmnet service into config mode so that the file is not overwritten by Fusion itself. To do so run

sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start

You can add a section for each VM, the format is as follows:-

host {vm-name} { hardware ethernet {VM MAC Address}; fixed-address {Desired ip address}; }

By default DHCP allocates the range ...128 to ...254 automatically so for sticky IPs it is recommended to avoid this range. You can see the exact range in the subnet section earlier in the file.

I tend to use ...10x for ingestion VMs and ...11x for distribution VMs, as an easy to remember approach, but obviously it's a matter of choice. Doing this should mean that you can be confident your ips won't change (and also if desired that in your host you can use naming rather than just numeric addresses for communicating with your VMs).

Once you're satisfied with your edits to the file, you can stop the vmnet service using

sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop

and start it using

sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --configure

after that you should be able to renew the DHCP lease inside your guest system using e.g. /etc/init.d/network restart. If that does not work for you, you will need to reboot your Mac (not just restart VMWare Fusion, as I hoped).

Source for this: http://socalledgeek.com/blog/2012/8/23/fixed-dhcp-ip-allocation-in-vmware-fusion

As a heads-up (as I found out last night) - if you install the VMWare Fusion plugin for vagrant, this file will be backed up to dhcpd.conf.bak and your changes will be overwritten, so you will need to reapply them from the .bak file and reboot.

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