2017-07-25 120 views
2

我使用Puphpet.com通過VirtualBox 5.1.24部署本地Ubuntu 16.04 LAMP開發機器。我用VM IP地址(192.168.56.101)更新了/ etc/hosts。Puphpet/Vagrant:無法訪問IP地址爲LAMP的虛擬機

$ cat /etc/hosts 

127.0.0.1 localhost 
127.0.1.1 flippy 
192.168.56.101 dev.mysite.com 

# The following lines are desirable for IPv6 capable hosts 
::1  ip6-localhost ip6-loopback 
fe00::0 ip6-localnet 
ff00::0 ip6-mcastprefix 
ff02::1 ip6-allnodes 
ff02::2 ip6-allrouters 

我可以SSH到虛擬機,但我無法通過IP地址(192.168.56.101),也不域名訪問它。

Ping不通:

$ ping 192.168.56.101 

PING 192.168.56.101 (192.168.56.101) 56(84) bytes of data. 
^C 
--- 192.168.56.101 ping statistics --- 
164 packets transmitted, 0 received, 100% packet loss, time 166895ms 

和捲曲失敗:

$ curl -v 192.168.56.101 

* Rebuilt URL to: 192.168.56.101/ 
* Trying 192.168.56.101... 
* connect to 192.168.56.101 port 80 failed: Connection timed out 
* Failed to connect to 192.168.56.101 port 80: Connection timed out 
* Closing connection 0 
curl: (7) Failed to connect to 192.168.56.101 port 80: Connection timed out 

主機上另外netstat -rn不顯示擊潰了虛擬機的IP地址:

$ netstat -rn 

Kernel IP routing table 
Destination  Gateway   Genmask   Flags MSS Window irtt Iface 
0.0.0.0   192.168.0.1  0.0.0.0   UG  0 0   0 wlp1s0 
169.254.0.0  0.0.0.0   255.255.0.0  U   0 0   0 wlp1s0 
192.168.0.0  0.0.0.0   255.255.255.0 U   0 0   0 wlp1s0 

還有什麼我可以檢查嗎?

回答

0

我提供了an answer here,我相信是相關的,但是我會在這裏發佈它以及其他任何奇蹟到這個線程尋找一個解決方案。

這聽起來很像是在5.1.26中修復的bug in VirtualBox 5.1.24

該問題似乎是由VirtualBox無法爲主機專用網絡創建路由引起的。要檢查是否屬於這種情況,請在主機上運行vagrant up,然後從終端運行netstat -rn。這會向您顯示內核IP路由表中的可用路徑。將有輸出的幾行,但中你應該看到您的內部網絡的IP看起來像這樣:

Destination  Gateway   Genmask   Flags MSS Window irtt Iface 
192.168.56.101 0.0.0.0   255.255.255.0 U   0 0   0 vboxnet3 

如果您沒有看到該IP,那麼你可能已經被這個錯誤咬傷潰敗集。升級到Virtualbox 5.1.26爲我解決了這個問題(在Linux上)。不過puphpet.com在主頁上說這個:

官方推薦的Virtualbox版本是5.0.26!

所以,你可能希望回滾到該版本

+0

是的,我使用VirtualBox 5.1.24。 'netstat -rn'沒有列出我的虛擬機IP地址。我會嘗試回滾到以前的版本。 – robotdindu

+0

我的問題已通過回滾到以前的版本解決,5.0.40r115130,謝謝!我現在可以使用ping,curl等來訪問虛擬機IP地址。主機上的'netstat -rn'命令有一個'Iface vboxnet0'的條目,其目的地址爲192.168.56.0' - 這與我的虛擬機IP地址不匹配,但似乎都沒問題。 – robotdindu