biped

Vagrant连接超时

2015-09-14

在强行关闭 Vagrant 后,会造成下次启动时连接超时,始终提示default: Warning: Connection timeout. Retrying...信息,通过启用 GUI 发现此时已进入系统登录窗口。

多方查证,这算是一个 Ubuntu Cloud Image 的 Bug。在 Vagrant 的 issues 3860 中有这样一个反馈,Issues with virtualbox provisioner private_network mode in cloud ubuntu 14.04 box。其中 Ramblurr 提到一种解决方案,使用 VirtualBox GUI 方式登录系统,以管理员权限编辑/etc/networking/interfaces文件,使其仅存在一个ethX interfaces

实际测试,Ubuntu 14.04.3 LTS 下正确的文件路径是/etc/network/interfaces,而非/etc/networking/interfaces。Private Network 方式下修正后的配置文件如下:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# Source interfaces
# Please check /etc/network/interfaces.d before changing this file
# as interfaces may have been defined in /etc/network/interfaces.d
# NOTE: the primary ethernet device is defined in
# /etc/network/interfaces.d/eth0
# See LP: #1262951
source /etc/network/interfaces.d/*.cfg

#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth1
iface eth1 inet static
      address 192.168.168.168
      netmask 255.255.255.0
#VAGRANT-END

biped
前端工程师

热爱文字和生活