02 March 2015

Can't SSH Connect to Packer or Vagrant

Unable to connect over SSH?

When building vagrant boxes with packer last week, I had an odd problem with packer being totally unable to connect to the new VMWare image over SSH.

When a new VM comes up in VMWare, it's given two network interfaces by default - a NAT (vmnet8) and a host-only connection (vmnet1). DHCP leases are set for these and added to a couple of local files; packer and vagrant then query these files to determine where to connect when the VM starts.

The solution was to just delete these lease files, and then restart VMWare. You'll want to make sure that no VMs are running at the time! This will probably also fix any other "unable to connect" problems with vagrant1.

sudo rm -f /var/db/vmware/vmnet-dhcpd-vmnet*

Configuring the vmnet subnet addresses yourself

Ever wondered why some machines will feature vmnet1 in the 192.168.x.x range, and some in the 172.16.x.x range? I did. You can configure the subnets for VMWare DHCP yourself.

Edit /Library/Preferences/VMware Fusion/networking, and modify VNET_1_HOSTONLY_SUBNET and VNET_8_HOSTONLY_SUBNET2.


Tagged in devops vmware packer vagrant