How to browse to Vagrant VM site from other devices on local network?

扶醉桌前 提交于 2019-12-11 06:19:51

问题


I'm running Laravel Homestead (Vagrant) on Windows 10.

I'd like to be able to use other devices on my LAN to test my Homestead site too. (My LAN also has a Mac and an iPhone.)

I found two ancient questions (1 and 2) that seem related to my goal, but I'm still stuck.

I've tried adding a public_network config to my Homestead.yaml according to the docs (https://laravel.com/docs/5.4/homestead#network-interfaces).

I've tried editing the homestead.rb file directly, too (but that didn't seem to help, so I reverted it).

My Homestead.yaml is:

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa2013

folders:
    - map: c:/code/katievb-members
      to: /home/vagrant/Code/katievb-members

sites:
    - map: kvbmem.rcw
      to: /home/vagrant/Code/katievb-members/public
      schedule: false

databases:
    - kvbmem

networks:
    - type: "public_network"
      ip: "192.168.1.104"
      bridge: "Realtek RTL8811 Wireless LAN 802.11ac USB 2 Network Adapter"

My Windows machine is 192.168.1.104 on my LAN.

What should I change about my setup so that my Homestead website is browsable not just from the Windows machine that its on but also the other devices on the LAN?

And then what commands should I run before trying to browse to that site (http://kvbmem.rcw) on my iPhone? vagrant reload --provision?

(I have a DD-WRT router with DNSmasq if that will be helpful.)


回答1:


The question you pointed gave you good hints so you need to enable bridge connection, in vagrant its public_network

If you want to assign a static IP, you cannot use the same IP of your windows machine, otherwise the other machine from your LAN will hit the servers running on the windows machine.

You want to select an IP reachable on your LAN in the same network of your windows machine so if your current IP is 192.168.1.104 you can use any of the 192.168.1.x that is available, for example

networks:
    - type: "public_network"
      ip: "192.168.1.100"
      bridge: "Realtek RTL8811 Wireless LAN 802.11ac USB 2 Network Adapter"


来源:https://stackoverflow.com/questions/43397630/how-to-browse-to-vagrant-vm-site-from-other-devices-on-local-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!