Vagrant makes too many network interfaces

856 views
Skip to first unread message

Thomas Qvidahl

unread,
Jan 7, 2019, 10:22:36 AM1/7/19
to Vagrant
Hi all!
I've stumbled on something that looks like a bug, and I'm having trouble figuring out what's happening, and thus I've been unable to determine if this is a known error or something I've fumbled up.

In short, I have a multi machine Vagrant file. It (currently) generates six Virtualbox vm's for me, where each should have the following NIC configuration:

eth0 - NAT - 10.0.2.15
eth1 - Bridged to 'eno2' - DHCP provided address from my local network
eth2 - NatNetwork - static IP from Vagrantfile

but as the deployment runs, I notice that each new VM gets one MORE nic than the previous, as if they've ran in a nested loop of sorts!

After deployment it looks like this:
VM1:
eth0 - NAT - 10.0.2.15
eth1 - Bridged to 'eno2' -  no IP
eth2 - Internal Network -  static IP from Vagrantfile

VM2:
eth0 - NAT - 10.0.2.15
eth1 - Bridged to 'eno2' -  no IP
eth2 - Bridged to 'eno2' -  no IP
eth3 - Internal Network -  static IP from Vagrantfile

VM3:
eth0 - NAT - 10.0.2.15
eth1 - Bridged to 'eno2' -  no IP
eth2 - Bridged to 'eno2' -  no IP
eth3 - Bridged to 'eno2' -  no IP
eth4 - Internal Network -  static IP from Vagrantfile

VM4:
eth0 - NAT - 10.0.2.15
eth1 - Bridged to 'eno2' -  no IP
eth2 - Bridged to 'eno2' -  no IP
eth3 - Bridged to 'eno2' -  no IP
eth4 - Bridged to 'eno2' -  no IP
eth5 - Internal Network -  static IP from Vagrantfile

...and so on...

Vagrantfile excerpt here:
Vagrant.configure("2") do |config|
# Hostmanager updates hosts files of all the machines with all hostnames and IP addresses.
config.hostmanager.enabled = true
config.hostmanager.manage_guest = true
config.hostmanager.include_offline = true

config.vm.network :forwarded_port, guest: 22, host: 2222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true
hosts = {
"vm1" => "10.55.13.8",
"vm2" => "10.55.13.9",
"vm3" => "10.55.13.10",
"vm4" => "10.55.13.11",
"vm5" => "10.55.13.12",
"vm6" => "10.55.13.13"
}

(hosts).each do |name, ip|
config.vm.define "#{name}" do |node|
node.vm.box = "rhel6-base"
node.vm.network "private_network", ip: "#{ip}",
virtualbox__intnet: "NatNetwork"
config.vm.network "public_network", bridge: "eno2"
node.vm.hostname = "#{name}"
node.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
end
end
end

All network interfaces are UP. All interfaces have unique MAC-addresses. All Vagrant communication works. I am unable to use straight SSH to log in to the VM's.

Vagrant version 2.2.2
I'm on Ubuntu 16.04 LTS.
VM's are RHEL 6.9

Anyone seen this before? Anyone able to repro?

All the best,
Thomas Qvidahl

Alvaro Miranda Aguilera

unread,
Jan 7, 2019, 4:17:04 PM1/7/19
to vagra...@googlegroups.com
hello

you have a config in the node repo, may be that is what causing the incremental issue

can you replace

config.vm.network "public_network", bridge: "eno2"

with

node.vm.network "public_network", bridge: "eno2"


for the ip part

does eno2 is a wired card ? if yes, does the dhcp have any restriction on ips per port?

afe you in a home router? company/corporate setup?

if you create vms manually, like you want to do here say 3 bridge to eno2, you get 3 ips on the VM?

thanks
alvaro


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/5a67e37b-8b25-4301-bfa1-784dc4e98adb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Alvaro

Thomas Qvidahl

unread,
Jan 8, 2019, 4:15:27 AM1/8/19
to Vagrant
Alvaro,
A Big Thank You!
Of course that was the problem! I don't know how I missed that! Even my rubber duckie didn't point it out, or maybe she did but I didn't get it.. ;)
I'm just beginning to grasp how the Vagrantfile does it's "magic" and this is definitely something I'll look out for! :)

Now the correct number of interfaces are being deployed, and I found that I need to parameterize the "eno2" interface, as it's not the same for all of us using the deployment script. When I give the correct interface to bridge to, I get all the addresses I need.

Thank you so much for your pointer, it made me revisit assumptions and solved the problem completely!

Now on to the next problem! :D

Best regards,
Thomas Qvidahl

Alvaro Miranda Aguilera

unread,
Jan 8, 2019, 5:04:25 AM1/8/19
to vagra...@googlegroups.com
Hi there

happy to help!


So one question.
How you plan to use the public ip?
since is DHCP how do you know to what IP to connect?

How you will be using that interface/ip?

generally speaking, for  a dev to connect to the machine you use static ip as your have done.

and the VM always have internet access over the nat.

so maybe the public_network is not needed and will make things easier.

Thanks
Alvaro.


For more options, visit https://groups.google.com/d/optout.


--
Alvaro

Thomas Qvidahl

unread,
Jan 8, 2019, 6:05:24 AM1/8/19
to Vagrant
Hi again!
This setup is done with Vagrant, but after Vagrant is done, Ansible runs a whole barrage of application scripts on the vm's.. These scripts gather IP-addresses and update DNS and set firewall rules so as to build a complete, locally-hosted and down-scaled developer's version of a much larger system.
Down-scaled to five VM's.. :) In production this system runs distributed across 15-20 nodes in two separate data centers.. :)

The idea is that Vagrant can be replaced with AWS, Azure or whatever, to build and scale any dev/test environment as needed. In such environments there are quite different demands.. :)

Thanks again!
Thomas
Reply all
Reply to author
Forward
0 new messages