无法从主机连接到Vagrant专用网络-无法访问目标主机

时间:2019-06-17 10:24:49

标签: networking vagrant virtual-machine virtualbox

我正在尝试将我的Virtualbox VM设置为与Vagrant一​​起运行。到目前为止,我一直无法连接到机器。

我正在使用Vagrant 2.2.4和Virtualbox 6.0.8r130520(用于Debian / Ubuntu 18的Oracle官方软件包:deb [arch = amd64] http://download.virtualbox.org/virtualbox/debian仿生贡献者”)

我在Vagrantfile中使用具有静态IP link的专用网络:

config.vm.network "private_network", ip: "192.168.33.10"

另外:

    v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]

这是无业游民的输出:

Bringing machine 'test' up with 'virtualbox' provider...
==> test: Importing base box 'dev'...
==> test: Matching MAC address for NAT networking...
==> test: Setting the name of the VM: test
==> test: Fixed port collision for 22 => 2222. Now on port 2200.
==> test: Clearing any previously set network interfaces...
==> test: Preparing network interfaces based on configuration...
    test: Adapter 1: nat
    test: Adapter 2: hostonly
==> test: Forwarding ports...
    test: 22 (guest) => 2200 (host) (adapter 1)
==> test: Running 'pre-boot' VM customizations...
==> test: Booting VM...
==> test: Waiting for machine to boot. This may take a few minutes...
    test: SSH address: 127.0.0.1:2200
    test: SSH username: username
    test: SSH auth method: password
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.

流浪状态显示:

Current machine states:

test                    running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

ping 192.168.33.10的输出:

PING 192.168.33.10 (192.168.33.10) 56(84) bytes of data.
From 192.168.33.1 icmp_seq=1 Destination Host Unreachable
From 192.168.33.1 icmp_seq=5 Destination Host Unreachable
From 192.168.33.1 icmp_seq=6 Destination Host Unreachable

我尝试在Vagrantfile中设置public_network而不是private_network,但没有任何区别link

ifconfig输出:

ens2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.64.62.141  netmask 255.255.255.254  broadcast 10.64.62.141
        inet6 fe80::dc1c:3cff:fe64:2047  prefixlen 64  scopeid 0x20<link>
        inet6 2001:bc8:47a0:1f46::1  prefixlen 127  scopeid 0x0<global>
        ether de:1c:3c:64:20:47  txqueuelen 1000  (Ethernet)
        RX packets 764159  bytes 2552235354 (2.5 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 473453  bytes 124372499 (124.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 35498  bytes 451319135 (451.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 35498  bytes 451319135 (451.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.33.1  netmask 255.255.255.0  broadcast 192.168.33.255
        inet6 fe80::800:27ff:fe00:0  prefixlen 64  scopeid 0x20<link>
        ether 0a:00:27:00:00:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 434  bytes 42136 (42.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

route -n输出:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.64.62.140    0.0.0.0         UG    0      0        0 ens2
10.64.62.140    0.0.0.0         255.255.255.254 U     0      0        0 ens2
192.168.33.0    0.0.0.0         255.255.255.0   U     0      0        0 vboxnet0

我想念什么吗?此框在本地工作。 任何帮助或建议,将不胜感激。

3 个答案:

答案 0 :(得分:0)

好像您的无用的VM在启动和超时时冻结。

您是否也有可能在VM上运行主机(VM启动)?

答案 1 :(得分:0)

是的,这是一个很大的问题,VM的第一级只能模拟硬件。

要使其正常工作,需要大量的调整和自定义驱动程序。

在裸机上运行,​​这是VirtualBox设计的。

答案 2 :(得分:0)

我对流浪汉有疑问。我只是认为我必须更新Powershell和Windows管理框架  现在,它可以正常且更快地工作。希望对您有所帮助。