Vagrant / Virtualbox / host-only / can't access host (ping from guest)

1,274 views
Skip to first unread message

Wolfgang Klinger

unread,
Jan 4, 2016, 5:19:27 AM1/4/16
to Vagrant

Hi,

I tried it with different boxes, always the same, I can't ping the host.
ping to the outside world via NAT works, but not on the host-only adapter.


this is my Vagrantfile:
----
# -*- mode: ruby -*-
# vi: set ft=ruby :

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

    config.vm.box = "scotch/box"
    config.vm.network "private_network", ip: "192.168.33.10"
    config.vm.hostname = "scotchbox"
    config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]

        config.vm.provider "virtualbox" do |v|
        v.customize ["modifyvm", :id, "--cpuexecutioncap", "80"]
        v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
        v.gui = false
        v.memory = "2048"
        v.cpus = 2
        end
end
-----

Adapter 1 = NAT
Adapter 2 = host-only (vboxnet0, IP: 192.168.33.10)

----- guest:
eth1      Link encap:Ethernet  HWaddr 08:00:27:0c:f4:d3
          inet addr:192.168.33.10  Bcast:192.168.33.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe0c:f4d3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:215 (215.0 B)  TX bytes:1844 (1.8 KB)


----- host:
vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        ether 0a:00:27:00:00:00
        inet 192.168.33.1 netmask 0xffffff00 broadcast 192.168.33.255


------ guest:
vagrant@scotchbox:~$ ping 192.168.33.1
PING 192.168.33.1 (192.168.33.1) 56(84) bytes of data.
^C
--- 192.168.33.1 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4032ms

vagrant@scotchbox:~$ ping www.google.at
PING www.google.at (64.15.113.181) 56(84) bytes of data.
64 bytes from 64.15.113.181: icmp_seq=1 ttl=63 time=34.1 ms
64 bytes from 64.15.113.181: icmp_seq=2 ttl=63 time=33.5 ms

------ guest:
vagrant@scotchbox:~$ arp
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.2.3                 ether   52:54:00:12:35:03   C                     eth0
10.0.2.2                 ether   52:54:00:12:35:02   C                     eth0
192.168.33.1             ether   08:00:27:38:ca:5d   C                     eth1

------


OSX 10.11.2 (15C50), Firewall OFF
Vagrant 1.8.1

VirtualBox 5.0.12 r104815



Any hints or help appreciated!

tia!


This worked before El Capitan.



Kind regards

Wolfgang Klinger


Alvaro Miranda Aguilera

unread,
Jan 5, 2016, 3:20:46 AM1/5/16
to vagra...@googlegroups.com
Hello There

in VirtualBox the host is available as 10.0.2.2

Below full output.

I copied and paste your line, just the line, and my Vagrant didn't like it.

Can you run "dos2unix Vagrantfile" just in case?

test 1 :

here is one that works:

Vagrant.configure(2) do |config|

  config.vm.box = "cbednarski/ubuntu-1404"

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

end


If still doesn't work, please run this:

ifconfig 2>&1 | grep -B2 -i '192.168.33'

And using the VirtualBox gui -> preferences -> network -> host only network,. delete that interface and let Vagrant to create it again.


Full output:




root@ubuntu-1404-vbox:~# ping 10.0.2.2

PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data.

64 bytes from 10.0.2.2: icmp_seq=1 ttl=63 time=0.165 ms

^C

--- 10.0.2.2 ping statistics ---

1 packets transmitted, 1 received, 0% packet loss, time 0ms

rtt min/avg/max/mdev = 0.165/0.165/0.165/0.000 ms

root@ubuntu-1404-vbox:~# ssh -XY kik...@10.0.2.2

The authenticity of host '10.0.2.2 (10.0.2.2)' can't be established.

ECDSA key fingerprint is e4:29:24:62:83:c2:22:99:38:e0:a0:63:f5:17:db:d4.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '10.0.2.2' (ECDSA) to the list of known hosts.

Password:

mini:~ kikitux$ 


Added the network ip, and works for me:


mini:ubuntu1404 kikitux$ vagrant ssh -c "sudo su -"

root@ubuntu-1404-vbox:~# ifconfig eth1


eth1      Link encap:Ethernet  HWaddr 08:00:27:5b:04:72  

          inet addr:192.168.33.10  Bcast:192.168.33.255  Mask:255.255.255.0

          inet6 addr: fe80::a00:27ff:fe5b:472/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1 errors:0 dropped:0 overruns:0 frame:0

          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:231 (231.0 B)  TX bytes:1526 (1.5 KB)



root@ubuntu-1404-vbox:~# ping 192.168.33.1

PING 192.168.33.1 (192.168.33.1) 56(84) bytes of data.

64 bytes from 192.168.33.1: icmp_seq=1 ttl=64 time=0.577 ms

64 bytes from 192.168.33.1: icmp_seq=2 ttl=64 time=0.466 ms

^C

--- 192.168.33.1 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 0.466/0.521/0.577/0.060 ms

root@ubuntu-1404-vbox:~# ssh kik...@192.168.33.1

The authenticity of host '192.168.33.1 (192.168.33.1)' can't be established.

ECDSA key fingerprint is e4:29:24:62:83:c2:22:99:38:e0:a0:63:f5:17:db:d4.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.33.1' (ECDSA) to the list of known hosts.

Password:

mini:~ kikitux$ 


Thanks

Alvaro


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/5a1734d0-7d00-4398-8b8f-8b46a03d038b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wolfgang Klinger

unread,
Jan 7, 2016, 3:47:10 AM1/7/16
to Vagrant

Hello,

thanks for your reply, but I don't know where the solution is.
I already tried many different boxes. That problem must be somewhere else.




----- guest:
# ifconfig 2>&1 | grep -B2 -i '192.168.42'

eth1      Link encap:Ethernet  HWaddr 08:00:27:27:81:95
          inet addr:192.168.42.42  Bcast:192.168.42.255  Mask:255.255.255.0

# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.42.1             ether   0a:00:27:00:00:02   C                     eth1
10.0.2.3                 ether   52:54:00:12:35:03   C                     eth0
10.0.2.2                 ether   52:54:00:12:35:02   C                     eth0


----- host:
# ifconfig 2>&1 | grep -B2 -i '192.168.42'
vboxnet2: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        ether 0a:00:27:00:00:02
        inet 192.168.42.1 netmask 0xffffff00 broadcast 192.168.42.255


# arp -i vboxnet2 -l -a
Neighbor                Linklayer Address Expire(O) Expire(I)    Netif Refs Prbs
192.168.42.42           8:0:27:27:81:95   expired   expired   vboxnet2    1
192.168.42.255          (incomplete)      (none)    (none)    vboxnet2




Any idea how I can debug this connection problems within the guest (e.g. Debian)?
Any logs I can take a look?



tia,
kind regards
Wolfgang


Alvaro Miranda Aguilera

unread,
Jan 8, 2016, 7:03:03 PM1/8/16
to vagra...@googlegroups.com
Hello,

Did you try this Vagrantfile?

Vagrant.configure(2) do |config|

  config.vm.box = "cbednarski/ubuntu-1404"

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

end


Can you share your Vagrantfile?


Thanks


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages