首页 > 解决方案 > Laravel Homestead:无法从 VM 内部 ping 任何 .local 站点

问题描述

不知道问题出在哪里。我的另一个同事从主机 Mac 以及从 VM 内部 ping foo.local 没有问题。

Homestead.yaml的很简单:

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

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Code
      to: /home/vagrant/code

sites:
    - map: vppaportal.local
      to: /home/vagrant/code/vppa-portal/public
    - map: iosportal.local
      to: /home/vagrant/code/ios-portal/public
    - map: ascent.local
      to: /home/vagrant/code/ascent/public
    - map: peem.local
      to: /home/vagrant/code/peem-v2/public

databases:
    - homestead

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# zray:
#  If you've already freely registered Z-Ray, you can place the token here.
#     - email: foo@bar.com
#       token: foo
#  Don't forget to ensure that you have 'zray: "true"' for your site.

因此,当我的 Homestead 在我的 Mac 上运行时,我可以ping iosportal.local并且它可以工作,但是当我ssh进入机器时,ping iosportal.local我会得到:

vagrant@homestead:~/code$ ping iosportal.local
ping: iosportal.local: Temporary failure in name resolution

标签: laravelhomestead

解决方案


我通过/etc/hosts 在 Homestead 内部打开并添加:

127.0.1.1 iosportal.local

关键是我的同事都不必这样做,因此我认为这是一种临时解决方法。如果有人会提出更好的解决方案,我很乐意投票并更改已接受的答案。


推荐阅读