【发布时间】:2015-05-12 21:21:49
【问题描述】:
我一直在尝试用 vagrant 替换手动 vitualbox 设置。我通常创建一个带有 2 个网络适配器的来宾节点,一个 NAT 供来宾(ubuntu)使用主机互联网进行所有 apt-get 操作,以及一个主机只供我的主机连接到来宾。我一直工作得很好。
下面是我的流浪文件
Vagrant.configure("1") do |config|
config.vm.boot_mode = :gui
end
Vagrant.configure("2") do |config|
config.vm.define "web" do |web|
web.vm.box = "ubuntu/trusty64"
web.vm.network "forwarded_port", guest:22, host:2222, id:"ssh", disabled:true
web.vm.network "private_network", ip:"192.168.56.103", :adapter =>2
end
end
下面是输出:
Bringing machine 'web' up with 'virtualbox' provider...
==> web: Importing base box 'ubuntu/trusty64'...
==> web: Matching MAC address for NAT networking...
==> web: Checking if box 'ubuntu/trusty64' is up to date...
==> web: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> web: have version '14.04'. The latest is version '20150430.0.0'. Run
==> web: `vagrant box update` to update.
==> web: Setting the name of the VM: ansible_web_1431424632866_64634
==> web: Clearing any previously set forwarded ports...
==> web: Clearing any previously set network interfaces...
==> web: Preparing network interfaces based on configuration...
web: Adapter 1: nat
web: Adapter 2: hostonly
==> web: Forwarding ports...
==> web: Booting VM...
==> web: Waiting for machine to boot. This may take a few minutes...
web: SSH address: 127.0.0.1:22
web: SSH username: vagrant
web: SSH auth method: private key
web: Warning: Authentication failure. Retrying...
web: Warning: Authentication failure. Retrying...
web: Warning: Authentication failure. Retrying...
现在在 vagrant 上它几乎可以工作,但我想不通:
问题 1 vagrant 是否需要端口转发才能连接到访客?
问题 2 当 vagrant 说:==> web: Preparing network interfaces based on configuration...
web: Adapter 1: nat
web: Adapter 2: hostonly 我认为 eth1 应该启动但事实并非如此。 ifconfig -a 显示没有任何 IP 的接口 eth1 任何 sudo ifup eth1 显示 Ignoring unknown interface eth1=eth1。这里发生了什么,我该如何解决?
感谢您的帮助
【问题讨论】:
-
这种情况可能是因为 VirtualBox 未能重定向端口,尽管说 '==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ' 您可以在我的问题link 中查看完整描述。我仍然不知道如何修复重定向失败(请在我的帖子中添加注释,如果以及如何成功!
标签: vagrant virtualbox