linuxvagrantdebianprivate-network

debian 9 stretch vagrant vm box host not reachable


Prerequisites:

- 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 and vagrant ssh are executing well

/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

In the vagrant shell (guest)

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 => fine

In the debian shell (host)

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 => host not reachable

I don't know how to get the Vagrant VM Box host up to my Debian. May someone experienced a similar issue.


Solution

  • VirtualBox 5.1.24 r117012 (Qt5.7.1)

    The hint is in 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
    

    The VirtualBox interface has been created but is not up. I have to type

    ifconfig vboxnet0 up
    

    A better solution will be a daemon to automatically up an VirtualBox interface when created by a box.


    UPDATE:

    VirtualBox 5.1.22 r115126 (Qt5.7.1)

    Regarding the ticket at virtualbox.org linked by @szeestraten:

    I installed VirtualBox 5.1.22 as mentioned in https://www.virtualbox.org/ticket/16911#comment:12. The interface automatically comes up after bringing the vagrant box up.

    With this solution the problem is partially solved. Partially, while I'm forced to install an older version of VirtualBox. So I keep both solutions here.


    UPDATE:

    VirtualBox 5.1.26 r117224 (Qt5.7.1)

    The new update has been released yesterday (Aug 2'17) and they solved this issue. It works as expected und no downgrade to an older version of VirtualBox is needed.