【发布时间】:2017-11-22 00:20:17
【问题描述】:
所以这是我的问题。我用 Vagrant 在我的 Mac 上安装了一个虚拟机。
- 流浪者:1.9.1
- 虚拟框:4.3.38
- OSX:10.11.6
- 机器:geerlingguy/ubuntu1604
当我运行 vagrant up 时,我得到了这个输出
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'geerlingguy/ubuntu1604'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'geerlingguy/ubuntu1604' is up to date...
==> default: Setting the name of the VM: <name>
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
但是,运行vagrant status 表明该框已启动并正在运行。当我尝试将vagrant ssh 放入框中时,它会挂起一段时间然后退出
ssh_exchange_identification: Connection closed by remote host
最后,在 GUI 模式下启动机器可以让我成功登录。现在,玩了一段时间后,我注意到了以下几点。
-
运行
lsof -i 2222表明端口实际上并未按应有的方式转发。VirtualBo 38361 <user> 29u IPv4 <device> 0t0 TCP localhost:2222 (LISTEN) 在来宾机器上运行
ifconfig显示没有IP 地址,只有硬件地址。-
当我尝试根据错误消息的建议增加 Vagrant 超时(至 3600s = 1h)时,
lsof显示端口不断被转发,消息中断(CLOSED_WAIT),然后重新转发到另一个端口,超过一遍又一遍,以至于vagrant up不得不用 ctl-C 手动停止。VirtualBo 38361 <user> 29u IPv4 <device> 0t0 TCP localhost:rockwell-csp2 (LISTEN) VirtualBo 38361 <user> 30u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61746 (CLOSE_WAIT) VirtualBo 38361 <user> 31u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61750 (CLOSE_WAIT) VirtualBo 38361 <user> 32u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61753 (CLOSE_WAIT) VirtualBo 38361 <user> 30u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61746 (CLOSE_WAIT) VirtualBo 38361 <user> 18u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61748 (CLOSE_WAIT) VirtualBo 38361 <user> 29u IPv4 <device> 0t0 TCP localhost:rockwell-csp2 (LISTEN) VirtualBo 38361 <user> 30u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61746 (CLOSE_WAIT) VirtualBo 38361 <user> 31u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61750 (CLOSE_WAIT) VirtualBo 38361 <user> 32u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61753 (CLOSE_WAIT)]等等
非常感谢您的建议,因为这几天让我发疯了。
【问题讨论】:
-
盒子没有 IP,因为 vagrant 无法正确设置它 - 你能检查
.ssh文件夹是否有正确的权限,authorized_keys是否正确
标签: macos vagrant ip virtualbox portforwarding