2

My experience with vagrant is very little as most of the time is seems to work. In this case however, I have not been able to get the desired behaviour.

I am trying to work on a rails application and it comes with its own Vagrantfile. While I can acess the machine via ssh I am unable to ping the machine or access the rails application running on port 80 on the vm.

Btw, I am running Vagrant 1.6.3 and VirtualBox 4.1.3 on an archlinux machine. I would really appreciate it if someone can point me in the right direction.

2

Looking at the Vagrantfile, it seems that vagrant is creating a private network, and assigning an IP to the box using DHCP.

To know which IP is using, just login on your box with vagrant ssh and find out the IP with the help of ifconfig.

You should then be able to ping the machine using that IP.

Keep in mind that you could also tell vagrant to assign a static IP to the box. Just update the Vagrantfile line:

config.vm.network :private_network, type: :dhcp

To:

config.vm.network :private_network, ip: "192.168.32.10"
0

To ping your vagrant box from your local machine, you have to enable port-forwarding through your Vagrantfile.

uncomment the following line in your Vagrantfile,

  config.vm.network "forwarded_port", guest: 80, host: 8080

you can then ping vagrant box using ping localhost:8080

  • By default vagrant does port forwarding for ssh; you are forwarding host port 8080 to guest port 80, which is an addition -- not a necessity. Also unless you assign a IP address (or use DHCP) you wont be able to do ICMP ping. – heemayl Dec 25 '16 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.