Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guest ip is unreachable under Vagrant using private network

I have next vagrant file on my windows host

Vagrant.configure(2) do |config|  
    config.vm.provider :virtualbox do |v|
        v.customize [
            "modifyvm", :id,
            "--memory", 1024,
            "--cpus", 1,
        ]
    end
    config.vm.box = "ubuntu/trusty64"
    config.vm.network "private_network", ip: "192.168.0.101"
end

Virtual machine starts normally but is unreachable from host by "192.168.0.101" ip. /etc/network/interface on guest is

auto lo
iface lo inet loopback

source /etc/network/interfaces.d/*.cfg

#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth1
iface eth1 inet static
      address 192.168.0.101
      netmask 255.255.255.0
#VAGRANT-END

and /etc/network/interfaces.d/eth0.cfg is

auto eth0
iface eth0 inet dhcp

Additionally after each run that vagrant, the new virtual network adapter is created and inside Virtualbox UI tool I see info about that new network - real IP is diffrent and random i.e. 169.254.173.8. I had >20 virtual networks :) By that IP guest machine is pinged and from itself also. But after restart vagrant the new network will be created with new IP

How to run vagrant machine with static unchangable IP? I need to build cluster with several nodes and each node must know about IP of each one

Update: On Linux host machine all it's OK. I can ping all guests from my host and guets see each other On Windows guests can't ping other guests i.e. 192.168.0.101 can't see 192.168.0.102

like image 592
Nawa Avatar asked Sep 28 '22 21:09

Nawa


1 Answers

The private network is just that, private to the guest(s), and it's created in addition to the default NAT-ed adapter. If you have several guests, they can interact with each other on the private network.

Regarding the nodes interacting, there are a number of plugins that can help you manage that, both with actual DNS as well as more simply using /etc/hosts. I tried a few and settled on vagrant-hosts.

like image 67
Nathan Hoover Avatar answered Oct 05 '22 08:10

Nathan Hoover