How to configure the host file to direct to the server of a "virtual box" virtual machine?

Asked

Viewed 766 times

1

I have a virtual machine windows 7 using virtual box. Inside this machine I have a study project. Inside this machine I access this project through the url "lara/", configured in Routes.

I would like to know how to direct a physical machine url request into my virtual machine. What I did was:

  1. I got the IP from the virtual machine - 192.168.56.1
  2. I set up the file etc/hosts from the physical machine to point to the virtual machine when the URL "lara;" is requested. 192.168.56.1 lara/

My process is not working. I know I could use Vagrant but I wanted to know how to do it without this tool.

It is possible?

  • Hello zwitterion, which server? (Apache, Nginx, Artisan, etc.) This url lara is probably part of an application on a virtual host of your http server within the Virtual Box. You need to expose this virtual host to the world (point something out in etc/hosts machine host it makes no difference if the guest not exposing anything in his IP).

  • Hi Anthony. I am using IIS in my physical machine (Win 7). In the virtual machine I am sweating with apache. I simply created a link in the etc/hosts file of my physical machine that points to the ip of the virtual machine. In the virtual machine I put in the bridge option.

  • See apache settings then (https.conf and company. You will only be able to access the URL from outside the virtual box after making this host visible).

  • Take a look in that reply in English.

1 answer

1

I made it, and it was simpler than I thought. I’ll share the steps in case anyone needs:

  1. Set the virtual machine network card to "bridge"inserir a descrição da imagem aqui

  2. Open the virtual machine and check the ipinserir a descrição da imagem aqui. or you can choose fixed ip configuration. Note: this is the terminal of INSIDE THE VIRTUAL MACHINE

  3. Open the file hosts of PHYSICAL MACHINE in C:\Windows\System32\drivers\etc/hosts and pass the ip of the virtual machine. Then refresh the DNS with the following command ipconfig /flushdns inserir a descrição da imagem aqui

  4. Now just type in browser of your physical machine the IP of the virtual machine or the Alias chosen in host and it’s ready. inserir a descrição da imagem aqui

  5. Note: To make any network group user have access, just follow steps 3 and 4 on each user’s machine.

  6. Note: In the physical machine I’m using IIS. In the virtual machine I’m using Apache.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.