无法访问 debian 9 stretch vagrant vm box 主机
debian 9 stretch vagrant vm box host not reachable
先决条件:
- Debian 9 Stretch
-> virgin and not on a VM
- VirtualBox 5.1.24 r117012 (Qt5.7.1)
-> VirtualBox Extension Pack 5.1.24 117012
-> Virtual Box Guest Additions
- Vagrant 1.9.7
Vagrantfile
Vagrant.configure("2") do |config|
# It's a Ubuntu box
config.vm.box = "Foo/Bar"
config.vm.box_download_insecure = true
config.vm.network "private_network", ip: "192.168.3.23"
config.vm.hostname = "www.hostname.domain"
config.hostsupdater.aliases = ["hostname.domain", "pma.www.hostname.domain"]
config.vm.provision "file", source: "env/vgrt/id_rsa", destination: "/home/vagrant/.ssh/id_rsa"
config.vm.provision "file", source: "env/vgrt/ssh_config", destination: "/home/vagrant/.ssh/config"
config.vm.provision "shell", path: "env/vgrt/bootstrap.sh"
end
vagrant up
和 vagrant ssh
执行良好
/etc/hosts
127.0.0.1 localhost
127.0.1.1 mypchostname
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.28.128.1 hostname.domain
192.168.3.23 www.hostname.domain # VAGRANT: 48b09d14c4dfba94981a628a986b69e0 (default) / d0fbe81e-2bd6-49f5-a285-3e2c4d4e7cef
192.168.3.23 hostname.domain # VAGRANT: 48b09d14c4dfba94981a628a986b69e0 (default) / d0fbe81e-2bd6-49f5-a285-3e2c4d4e7cef
192.168.3.23 pma.hostname.domain # VAGRANT: 48b09d14c4dfba94981a628a986b69e0 (default) / d0fbe81e-2bd6-49f5-a285-3e2c4d4e7cef
流浪者中shell(客)
ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:2c:61:d0
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe2c:61d0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1841 errors:0 dropped:0 overruns:0 frame:0
TX packets:1567 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:171675 (171.6 KB) TX bytes:164725 (164.7 KB)
enp0s8 Link encap:Ethernet HWaddr 08:00:27:7d:ea:54
inet addr:192.168.3.23 Bcast:192.168.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7d:ea54/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:1296 (1.2 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ping 192.168.3.23
=> 很好
在 debian shell(主机)
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d4:81:d7:cd:4a:5b brd ff:ff:ff:ff:ff:ff
inet 192.168.0.98/24 brd 192.168.0.255 scope global enp0s31f6
valid_lft forever preferred_lft forever
inet6 fe80::d681:d7ff:fecd:4a5b/64 scope link
valid_lft forever preferred_lft forever
3: wlp1s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 28:16:ad:e5:90:75 brd ff:ff:ff:ff:ff:ff
4: vboxnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.1/24 scope global vboxnet0
valid_lft forever preferred_lft forever
ping 192.168.3.23
=> 无法访问主机
我不知道如何将 Vagrant VM Box 主机安装到我的 Debian 上。可能有人遇到过类似的问题。
VirtualBox 5.1.24 r117012 (Qt5.7.1)
提示在ip addr
4: vboxnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.1/24 scope global vboxnet0
valid_lft forever preferred_lft forever
VirtualBox 界面已创建但未启动。我必须输入
ifconfig vboxnet0 up
一个更好的解决方案是在一个盒子创建时自动启动一个 VirtualBox 界面的守护进程。
更新:
VirtualBox 5.1.22 r115126 (Qt5.7.1)
关于由@szeestraten 链接的 virtualbox.org 的票证:
我安装了 https://www.virtualbox.org/ticket/16911#comment:12 中提到的 VirtualBox 5.1.22。带上vagrant box后自动出现界面
有了这个解决方案,问题就部分解决了。部分地,虽然我被迫安装旧版本的 VirtualBox。所以我把这两种解决方案都保留在这里。
更新:
VirtualBox 5.1.26 r117224 (Qt5.7.1)
昨天(2017 年 8 月 2 日)发布了新的更新,他们解决了这个问题。它按预期工作,不需要降级到旧版本的 VirtualBox。
您可能 运行 遇到以下 VirtualBox 5.1.24 问题,https://www.virtualbox.org/ticket/16911。
另请参阅 Vagrant 问题 https://github.com/mitchellh/vagrant/issues/8802。
先决条件:
- Debian 9 Stretch
-> virgin and not on a VM
- VirtualBox 5.1.24 r117012 (Qt5.7.1)
-> VirtualBox Extension Pack 5.1.24 117012
-> Virtual Box Guest Additions
- Vagrant 1.9.7
Vagrantfile
Vagrant.configure("2") do |config|
# It's a Ubuntu box
config.vm.box = "Foo/Bar"
config.vm.box_download_insecure = true
config.vm.network "private_network", ip: "192.168.3.23"
config.vm.hostname = "www.hostname.domain"
config.hostsupdater.aliases = ["hostname.domain", "pma.www.hostname.domain"]
config.vm.provision "file", source: "env/vgrt/id_rsa", destination: "/home/vagrant/.ssh/id_rsa"
config.vm.provision "file", source: "env/vgrt/ssh_config", destination: "/home/vagrant/.ssh/config"
config.vm.provision "shell", path: "env/vgrt/bootstrap.sh"
end
vagrant up
和 vagrant ssh
执行良好
/etc/hosts
127.0.0.1 localhost
127.0.1.1 mypchostname
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.28.128.1 hostname.domain
192.168.3.23 www.hostname.domain # VAGRANT: 48b09d14c4dfba94981a628a986b69e0 (default) / d0fbe81e-2bd6-49f5-a285-3e2c4d4e7cef
192.168.3.23 hostname.domain # VAGRANT: 48b09d14c4dfba94981a628a986b69e0 (default) / d0fbe81e-2bd6-49f5-a285-3e2c4d4e7cef
192.168.3.23 pma.hostname.domain # VAGRANT: 48b09d14c4dfba94981a628a986b69e0 (default) / d0fbe81e-2bd6-49f5-a285-3e2c4d4e7cef
流浪者中shell(客)
ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:2c:61:d0
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe2c:61d0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1841 errors:0 dropped:0 overruns:0 frame:0
TX packets:1567 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:171675 (171.6 KB) TX bytes:164725 (164.7 KB)
enp0s8 Link encap:Ethernet HWaddr 08:00:27:7d:ea:54
inet addr:192.168.3.23 Bcast:192.168.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7d:ea54/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:1296 (1.2 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ping 192.168.3.23
=> 很好
在 debian shell(主机)
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d4:81:d7:cd:4a:5b brd ff:ff:ff:ff:ff:ff
inet 192.168.0.98/24 brd 192.168.0.255 scope global enp0s31f6
valid_lft forever preferred_lft forever
inet6 fe80::d681:d7ff:fecd:4a5b/64 scope link
valid_lft forever preferred_lft forever
3: wlp1s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 28:16:ad:e5:90:75 brd ff:ff:ff:ff:ff:ff
4: vboxnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.1/24 scope global vboxnet0
valid_lft forever preferred_lft forever
ping 192.168.3.23
=> 无法访问主机
我不知道如何将 Vagrant VM Box 主机安装到我的 Debian 上。可能有人遇到过类似的问题。
VirtualBox 5.1.24 r117012 (Qt5.7.1)
提示在ip addr
4: vboxnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.1/24 scope global vboxnet0
valid_lft forever preferred_lft forever
VirtualBox 界面已创建但未启动。我必须输入
ifconfig vboxnet0 up
一个更好的解决方案是在一个盒子创建时自动启动一个 VirtualBox 界面的守护进程。
更新:
VirtualBox 5.1.22 r115126 (Qt5.7.1)
关于由@szeestraten 链接的 virtualbox.org 的票证:
我安装了 https://www.virtualbox.org/ticket/16911#comment:12 中提到的 VirtualBox 5.1.22。带上vagrant box后自动出现界面
有了这个解决方案,问题就部分解决了。部分地,虽然我被迫安装旧版本的 VirtualBox。所以我把这两种解决方案都保留在这里。
更新:
VirtualBox 5.1.26 r117224 (Qt5.7.1)
昨天(2017 年 8 月 2 日)发布了新的更新,他们解决了这个问题。它按预期工作,不需要降级到旧版本的 VirtualBox。
您可能 运行 遇到以下 VirtualBox 5.1.24 问题,https://www.virtualbox.org/ticket/16911。
另请参阅 Vagrant 问题 https://github.com/mitchellh/vagrant/issues/8802。