Vagrant private_network can’t ping

When I create Vagrant virtual machine with private networking, I can’t ping to IP address of the VM. The only way to connect the VM is by using the “vagrant ssh” command.

In my Vagrantfile, I had

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-20.04"
  config.vm.network "private_network", ip: "192.168.56.4"
end

To fix the problem, first verify you have vboxnet0 network interface with the command

ip link

If the state of the vboxnet0 network interface is DOWN, make it UP with the command

sudo ip link set vboxnet0 up

Go to VirtualBox > File > Host Network Manager or press CTRL + H

VirtualBox Host Network manager

Verify vboxnet0 is set properly. You can delete it and create it again using “Host Network Manager”, which will fix any problem with the network.

Make sure the IP you specify in Vagrantfile is in the same range set for the vboxnet0 interface in VirtualBox Host Network manager.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *