Vagrantbox 与 Hyper-V 无法启动

Vagrantbox 与 Hyper-V 无法启动

我正在尝试在本地 Windows 10 机器上使用 Hyper-V 设置 vagrantbox。我的工作站在代理后面运行,但我配置了本地 cntlm 代理来绕过这些限制。代理设置工作正常,因为我能够安装 vagrant 插件并下载一个 box 图像。

但是现在我的客户 Linux 无法启动,我也没有办法了。

我的流浪档案

Vagrant.configure("2") do |config|

    config.vm.box = "bento/ubuntu-18.04" # ubuntu 18.04 image with support for virtual box and Hyper-V
    config.vm.hostname = "skywalker"

    config.vm.provider "virtualbox" do |vb|
        vb.memory = "2048"
    end

    config.vm.provider "hyperv" do |hv|
        hv.memory = "2048"
    end

    config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" # prevent tty errors

    # install the vagrant plugin "vagrant-cachier" to cache downloaded artifacts
    if Vagrant.has_plugin?("vagrant-cachier")
        config.cache.scope = :box
    end

    # vagrant behing local cntlm proxy if plugin exists (= provinzial win10 workstation)
    if !Vagrant.has_plugin?("vagrant-proxyconf")
        config.proxy.http     = "http://localhost:3128/"
        config.proxy.https    = "http://localhost:3128/"
        config.proxy.no_proxy = "localhost, 127.0.0.1"
    end

    # --------------------------------------------------------------------------

    # provision virtual mashine (basic setup) and install applications in VM
    #config.vm.provision "shell", path: "scripts/install-ansible.sh"
    config.vm.provision "shell", path: "scripts/install-ncdu.sh"
    config.vm.provision "shell", path: "scripts/install-git.sh"
    config.vm.provision "shell", path: "scripts/install-openjdk-11.sh"
    config.vm.provision "shell", path: "scripts/install-maven.sh"
    config.vm.provision "shell", path: "scripts/install-node-npm.sh"
    config.vm.provision "shell", path: "scripts/install-docker.sh"
    config.vm.provision "shell", path: "scripts/install-docker-compose.sh"

    # npm webserver
    config.vm.provision "shell", path: "apps/install-npm-apps.sh"
    config.vm.network "forwarded_port", guest: 8000, host: 8000

    # artifactory setup (start artifactory after vm startup)
    config.vm.network "forwarded_port", guest: 8081, host: 8081 # artifactory from docker
    config.vm.network "forwarded_port", guest: 8082, host: 8082 # artifactory from docker
    # See README.md for Artifactory in Docker

end

使用此设置启动框会导致

C:\home\work\workspace\vagrant-boxes\skywalker (master -> origin)
λ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
==> default: Importing a Hyper-V instance
    default: Creating and registering the VM...
    default: Successfully imported VM
    default: Configuring the VM...
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
    default: Timeout: 120 seconds
    default: IP: fe80::215:5dff:fe02:8b01
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: fe80::215:5dff:fe02:8b01:22
    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.

在另一台使用 VirtualBox 作为 VM 提供程序的机器上,此 Vagrantfile 运行良好。遗憾的是,由于我无法控制的限制,我无法在我的 Windows 机器上使用 Hyper-V 以外的任何 VM 提供程序...

我使用 设置了 Hyper-V Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

有什么想法吗?提前致谢,并致以最诚挚的问候。塞巴斯蒂安

答案1

您的机器上的 Vagrant up 报告了一个 IPv6 地址。通常,VM 的网络初始化涉及发送 DHCP 请求并返回一个 IPv4 地址。我怀疑您的 VM 确实这样做了,但请求超时了,它只能报告默认的 IPv6 地址。

“vagrant up”序列中的其余步骤是通过 ssh 进入报告的地址来完成的,但据我所知,这在 IPv6 中不起作用,因此报告无法正常启动。

如果您看到它在 Hyper-V 管理器中运行并且可以连接到控制台,则我认为您的问题是由 VM 和 Windows 主机之间的防火墙更改或以太网适配器配置更改禁用 DHCP 服务器引起的。

您可以使用 Hyper-V 控制台在 VM 中运行“tcpdump -i any port 67”来查看发送/接收的数据包之内虚拟机并使用主机上的任何工具查看主机上的数据包。

相关内容