Based on the output provided, the box has 2 network interfaces, 1 is the default NAT and the other private – ask you said.
The reason why you are not able to access the web site hosted within the VM thru the private interface: it could be that host eth0
or wlan0
IP address is not in the same network as the private interface -> 192.168.50.4/24
and there is no route.
To access the the site hosted by the web server within the guest, you have the following options:
1. NAT port forwarding
Forward the web port, e.g. 80 to host’s 8080 (you can’t use 80 because it is a privileged port on *NIX). Add the following
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 8080,
auto_correct: true
end
NOTE: auto_correct will resolve port conflicts if the port on host is already in use.
DO a vagrant reload
and you’ll be able to access the site via http://localhost:8080/
2. Public Network (VirtualBox Bridged networking)
Add a public network interface
Vagrant.configure("2") do |config|
config.vm.network "public_network"
end
Get the IP of VM after it is up and running, port forwarding does NOT apply to bridged networking. So you’ll be accessing the site by using http://IP_ADDR
, if within the VM it binds to 80, otherwise specify the port.