- CentOS 7 VM - 10.0.2.100
- Windows Server 2012 R2 VM - 10.0.2.15
Goal - Ping each other; communicate with each other
Problem - Cannot ping each other; communicate with each other
On the CentOS VM, I have auto_config turned off because Vagrant was having trouble automatically changing the IP for me. So I made Vagrant recognize it as 10.0.2.100 and then changed the network manually on the VM.
On the Windows VM, Vagrant defaulted the IP address to 10.0.2.15.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define "master" do |master|
master.vm.box = "centos/7"
master.vm.network "private_network", ip: "10.0.2.100", auto_config: false
master.vm.box = "centos_7_v2"
master.vm.hostname = "master.local.com"
master.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
end
config.vm.define "nodeone" do |nodeone|
nodeone.vm.box = "windows_2012_r2_standard"
nodeone.vm.hostname = "nodeone.local.com"
nodeone.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
end
end
I have the configuration --natdnshostresolver1 added to both VMs, and then added the following into my own hosts file (on my Mac).
10.0.2.15 nodeone.local.com
10.0.2.100 master.local.com
I finally figured it out. Apparently, you just set the IP address to be in the same subnet and then add then follow
virtualbox__intnet: true
setting per https://www.vagrantup.com/docs/virtualbox/networking.htmlAs stated by @jeffrey-wen, the solution is to add
virtual_box__intnet: true
to the inventory file. It should be noted that in doing so, you may have trouble pinging or sshing into your Vagrant boxes which are now on a new local network (as detailed in this Ansible issue).The solution for me was to add
-c local
to any command I ran.-c
informs Ansible of the connection type to use and defaults tosmart
which sometimes doesn't work correctly.Sorry for posting this as an answer - I don't have enough reputation yet to post it as a comment ¯\_(ツ)_/¯