无法从主机连接到 Vagrant 专用网络 - 无法访问目标主机
Unable to connect to Vagrant private network from host - Destination host unreachable
我正在尝试设置我的 Virtualbox VM 运行 Vagrant。到目前为止,我一直无法连接到机器。
我正在使用 Vagrant 2.2.4 和 Virtualbox 6.0.8r130520(Debian/Ubuntu 18 的官方 Oracle 软件包:deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian bionic contrib")
我在我的 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"]
这是 vagrant up 的输出:
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.
Vagrant 状态显示:
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
路由-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
我错过了什么吗?这个盒子在本地工作。
任何帮助或建议将不胜感激。
您的 vagrant VM 似乎在启动和超时时冻结。
有没有可能你也是 运行 VM 上的主机(VM 启动)?
是的,这是个大问题,第一级VM只能模拟硬件。
需要大量调整和自定义驱动程序才能使其正常工作。
运行 在裸机上,这是 VirtualBox 的设计目标。
我对 vagrant up 有疑问。我刚刚意识到我必须更新 powershell 和 windows 管理框架 现在它可以正常和更快地工作。希望对你有帮助。
我正在尝试设置我的 Virtualbox VM 运行 Vagrant。到目前为止,我一直无法连接到机器。
我正在使用 Vagrant 2.2.4 和 Virtualbox 6.0.8r130520(Debian/Ubuntu 18 的官方 Oracle 软件包:deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian bionic contrib")
我在我的 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"]
这是 vagrant up 的输出:
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.
Vagrant 状态显示:
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
路由-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
我错过了什么吗?这个盒子在本地工作。 任何帮助或建议将不胜感激。
您的 vagrant VM 似乎在启动和超时时冻结。
有没有可能你也是 运行 VM 上的主机(VM 启动)?
是的,这是个大问题,第一级VM只能模拟硬件。
需要大量调整和自定义驱动程序才能使其正常工作。
运行 在裸机上,这是 VirtualBox 的设计目标。
我对 vagrant up 有疑问。我刚刚意识到我必须更新 powershell 和 windows 管理框架 现在它可以正常和更快地工作。希望对你有帮助。