Multi-Machine shared host-only network - keeps creating more adapters

16 views
Skip to first unread message

Ian Koenig

unread,
May 25, 2017, 11:34:46 AM5/25/17
to Vagrant
I'm attempting to setup a host-only network that is shared between multiple VMs as part of the configuration of the environment.  

As such the end goal is that each VM has its required NAT network on adapter 1 and then has an adapter that is on a host-only shared network that they can all talk over.   On this then I can set IPs as needed to do other simple configurations successfully in a set network design.   

Every time I end up destroying and re-creating the environments I have another new host-only adapter created.    Right now in my testing I'm up around 15 Host-only adapters in my system which is a tad much.

Is there any way to say "use the first/second or third" private_network (Host-Only Adapter) so vagrant doesn't keep creating new adapters?

Example Vagrantfile:


# -*- mode: ruby -*-
# vi: set ft=ruby :
# Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search.


BOX_IMAGE
= "centos/7"
NODE_COUNT
= 1
Vagrant.configure("2") do |config|  
 config
.vm.define "master" do |subconfig|    
 subconfig
.vm.box = BOX_IMAGE    
 subconfig
.vm.hostname = "master"    
 subconfig
.vm.network :private_network, ip: "10.0.0.10"  
 
#subconfig.vm.network :public_network
 
end    


 
(1..NODE_COUNT).each do |i|    
 config
.vm.define "node#{i}" do |subconfig|      
 subconfig
.vm.box = BOX_IMAGE      
 subconfig
.vm.hostname = "node#{i}"      
 subconfig
.vm.network :private_network, ip: "10.0.0.#{i + 10}"    
 
end  
 
end  
end

Ian Koenig

unread,
May 25, 2017, 12:45:27 PM5/25/17
to Vagrant
I figured out that for whatever reason why I am using subnet 192.168.233.0/24 virtualbox can't appear to save that configuration properly so the Network adapters come up with a 169.254 definition for the address.   When I changed my subnet over to any other subnet, it starts working as you'd expect.  Find a Host-Only that matches that subnet and use it, otherwise create it.  
Reply all
Reply to author
Forward
0 new messages