How can I access a roaming guest from another guest of a virtual camera?

The scenario is that my dev environment is in a Vagrant box on my laptop (host) and I would like to do a browser check in vitualbox vm, so I need to see one vm from another.

Firewall port: 8080, which is forwarded to the host on the same port: 8080. Therefore, I can see the server from the host to localhost: 8080

What address should I use to test the vm browser?

Testing vm default gateway? Rogue vm ip? Virtual host network ip?

And do I need to use NAT or the host adapter only to check the vm browser?

This creates many combinations, all of which, I believe, have been tried. What else do I need to understand here?

+8
vagrant virtualbox
source share
3 answers

In your use case, you should use Bridged networking (Public Network in Vagrant). If the virtual machines are on the same host, you can even use internal (Private Network in Vagrant).

When using a public VM network, the 2nd network adapter will be able to obtain an IP address from a DHCP server on your network (for example, a home router).

Just add the following code to your Vagrantfile and do vagrant reload

 Vagrant.configure("2") do |config| config.vm.network "public_network" end 

You can get the IP address using vagrant ssh and ifconfig / ip addr show .

+11
source share

If you do not want to go with public_network in the same way as me, then you should do below using private_network :

  • Open Vagrantfile from the Project Root
  • Search for config.vm.network
  • Add this line config.vm.network "private_network", ip: "192.168.33.10" . Remember that this is not the IP address of your base machine, this is the IP address of the virtual box, and your device IP address must be different. You can say that this is a fake IP address, so change it to something else, like 192.168.30.20 .
  • Reboot your stroller using vagrant reload .
  • Now go to another virtual guest, in my case it is Windows Guest 2 . My Linux Mint Stray Box database is on Ubuntu Guest 1 . Open the C:\Windows\System32\drivers\etc\hosts file as an administrator and make the above IP entry there, like 192.168.33.10 local.youralias.com . And save the file, after which you can now browse the site at http://local.youralias.com/ .
  • If your guest 2 is also Linux, just edit this sudo vi /etc/hosts and add this line on top of it 192.168.33.10 local.youralias.com . Now save and exit and view the url :)

Enjoy it! Happy coding.

+1
source share

By adding to the accepted answer, you really can set the IP and specify which network interface to use.

My linux box setup via Wi-Fi and static IP: You can find your wifi interface name by running ifconfig command.

 Vagrant.configure("2") do |config| config.vm.network "public_network", :bridge => 'wlp8s0', ip: "192.168.1.199" end 
0
source share

All Articles