如何从本地网络上的其他设备浏览到Vagrant VM网站? [英] How to browse to Vagrant VM site from other devices on local network?

查看:154
本文介绍了如何从本地网络上的其他设备浏览到Vagrant VM网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 10上运行Laravel Homestead(Vagrant).

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

我也希望能够使用LAN上的其他设备来测试我的Homestead站点.(我的LAN也有Mac和iPhone.)

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.)

我发现了两个古老的问题( 1 和<似乎与我的目标有关的href ="https://serverfault.com/questions/545413/expose-virtual-machine-vagrant-to-local-wifi"> 2 ),但我仍然陷入困境

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

我尝试根据文档(我也尝试过直接编辑homestead.rb文件(但这似乎无济于事,所以我将其还原了.)

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

我的Homestead.yaml是:

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"

我的Windows计算机在我的局域网上是192.168.1.104.

My Windows machine is 192.168.1.104 on my LAN.

我应该对我的设置进行哪些更改,以便不仅可以从其上的Windows计算机而且可以从LAN上的其他设备浏览Homestead网站?

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?

然后尝试在iPhone上浏览到该站点(http://kvbmem.rcw)之前应该运行哪些命令? vagrant reload --provision?

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

(如果有帮助,我有一个带有DNSmasq的DD-WRT路由器.)

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

推荐答案

您所指出的问题为您提供了很好的提示,因此您需要启用桥连接,而无聊地使用它的public_network

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

如果要分配静态IP,则不能使用Windows计算机的相同IP,否则局域网中的另一台计算机将访问Windows计算机上运行的服务器.

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.

您想在Windows计算机的同一网络中的LAN上选择一个可访问的IP,因此,如果当前IP为192.168.1.104,则可以使用任何可用的192.168.1.x,例如

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"

这篇关于如何从本地网络上的其他设备浏览到Vagrant VM网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆