鍍金池/ 問答/PHP  網(wǎng)絡(luò)安全/ laravel homestead 內(nèi)網(wǎng)無法訪問?

laravel homestead 內(nèi)網(wǎng)無法訪問?

  1. win10上裝的homestead;
  2. aaa.test 域名,想讓局域網(wǎng)內(nèi)的別人也訪問到;
  3. 根據(jù)網(wǎng)上的教程 改public_network和同一IP段的IP10.8.220.12;
  4. 本機改完hosts可以訪問aaa.test;
  5. 局域網(wǎng)內(nèi)其他電腦改完hosts文件后 無法訪問;
  6. 而且IP也ping不通;

win10:

Ethernet adapter VirtualBox Host-Only Network:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::c02b:a17b:c92e:b45b%3
   Autoconfiguration IPv4 Address. . : 169.254.180.91
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :

Ethernet adapter VirtualBox Host-Only Network #2:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::d054:8abc:18ec:f421%8
   IPv4 Address. . . . . . . . . . . : 192.168.10.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Ethernet adapter 以太網(wǎng):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::5ac:6bd5:2a2d:3137%9
   IPv4 Address. . . . . . . . . . . : 10.8.220.237
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 10.8.220.1

虛擬機:

vagrant@homestead:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fef0:d6cc  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:f0:d6:cc  txqueuelen 1000  (Ethernet)
        RX packets 7403  bytes 1256971 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5213  bytes 598032 (598.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.8.220.12  netmask 255.255.255.0  broadcast 10.8.220.255
        inet6 fe80::a00:27ff:fece:2c45  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:ce:2c:45  txqueuelen 1000  (Ethernet)
        RX packets 9801  bytes 644909 (644.9 KB)
        RX errors 0  dropped 3  overruns 0  frame 0
        TX packets 140  bytes 97322 (97.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 502  bytes 153873 (153.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 502  bytes 153873 (153.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 

我該怎么做才能讓其他電腦pinghomesteadIP?改成相同的也沒用。。。誰懂?

回答
編輯回答
怣痛

1.查看自己的 ip,以及網(wǎng)關(guān)

假如自己的ip是 192.168.20.50,網(wǎng)關(guān):192.168.20.100
那么另一個人的配置應(yīng)該為:
192.168.20.xxx, 網(wǎng)關(guān)一致。

2.設(shè)置 homestead 配置

在 Homestead 目錄下面的 homestead.yaml:

追加配置:
networks:
- type: "public_network"
    ip: "192.168.20.10" //這里是重點,配置成局域網(wǎng)同ip段的
    bridge: "en1: Wi-Fi (AirPort)"

3.重啟 homestead

vagrant reload
2018年5月19日 10:52