How can I create a virtualhost with vagrant and see it in a local network?

1

How can I create a virtualhost with vagrant and see it in a local network?

In my vagrant box I have ubuntu and apache and I have already managed to create a VirtualHost, but the problem is that I can not get it to be seen in the local network from another computer; if someone puts the ip address if it is seen, but if someone puts the name of the virtualhost (for example: prueba.com ) nothing is seen, only the default page of the browser is seen that there was an error when trying to connect.

How can I solve it? since in my Vagrantfile I already put the sentence of: config.vm.network "public_network" and nothing happens. If I modify the file hosts of my physical pc, if I can see it, but obviously you do not have to change the hosts of each machine that wants to see the page.

    
asked by Stratovarius 01.07.2018 в 22:36
source

1 answer

0

It is that prueba.com only resolves to the correct IP if there is a dns that knows about the relation between name and IP, or a line that defines it in the file hosts local of the machine that makes the request .

To achieve this in a local network there are several options:

  • Having a computer running as local DNS for your entire network, you configure the router so that when you deliver a DHCP IP you also give them the IP of that machine as the main DNS, and that of your ISP or google as secondary.

  • Get a compatible router with OpenWrt to change the firmware and then configure dnsmasq to raise the domains you want to resolve locally, in addition to reserve the IPs so that DHCP does not deliver them to another device.

  • Use a plugin for vagrant that raises a temporary dns (local), for example landrush , the instructions to configure other devices you can find them at link , which is basically telling your other computers / devices that use your host machine as DNS.

  • linux: mount your own local DNS with dnsmasq and manually add the ip / names (and then configure this dns on the other devices in the network)

answered by 02.07.2018 в 00:23