Unable to ping 2 vms hosts under vagrant

Hi all,
I was wondering if anyone could help me with an issue I am having.

I created two windows vagrant vms (vagrant is using virtualbox as a provider), vm1 , vm2 in different folders.

I want to create a local private network between the vm1 and the vm2 so in the configuration file i added this section :

for vm1 :

config.vm.network "private_network", ip: "192.168.15.10"

for vm2 :

config.vm.network "private_network", ip: "192.168.15.11"

so , when I tried to ping each vm from one to the other, i am not getting any reply from the pinged machine.

Here is one example:

cd vm1

vagrant ssh

ping 192.168.15.11

i got no reply from the vm2 and it is the same for the vm2 , i got no reply from the vm1.

so please if anyone can help me in fixing that it will be handy. i need vm1 and vm2 in the same network (so i would like to be able to ping between vm1 and vm2) please. Any little info will help.

Regards,
Toto

I use virtualbox in Fedora Linux 36, and tried to setup like your setup vagrant vm in different folder and with ip private network. and is working well and normal, my vagrant vm centos1 can ping vm centos2, and vice versa. look at my SS below

1 Like

Hi mate,
thanks again. could you share you vagrant configuration files for the 2 vms please?
We tried again yesterday to put everything under a single file but for some reason the private ip addresses we set up don’t get created. Maybe if you have a chance you can look it up with us?

My Vagrantfile is default like default everybody run vagrant init in the terminal. I just uncomment private network and change same with your private network in vagrant. But did you know if virtualbox only allow private ip address in range 192.168.56.0/26? if you don’t know you can read this official article form virtualbox for networking in host only network.

https://www.virtualbox.org/manual/ch06.html#network_hostonly

If in /etc/vbox/networks.conf doesn’t exist, you can create one sudo vim /etc/vbox/networks.conf then your desired ip private network example:

  • 192.168.15.0/24

save and exit

restart virtualbox
sudo systemctl restart vboxdrv.service

then try to run vagrant up --provider=virtualbox or vagrant reload

This is my private network ip configuration in vagrantfile, Look my SS below

Did you know vagrant can use all kind of type available network like you use virtualbox as guest VM? vagrant can use host only networking, bridge networking and NAT networking which is use port forwarding in vagrant.
if you want use bridge network in vagrant virtual box you can use this:
config.vm.network “public_network”, :bridge => ‘br0’, :dev => ‘br0’, ip: “192.168.1.10”
br0 is your bridge network in your host OS. So if you vagrant up or reload you can access your vagrant vm with virtualbox provier from other host/computer/laptop in the same network or LAN.