Vagrant 1.9.1
Win10
Ubuntu 14.04
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_check_update = false
config.vm.synced_folder '.', '/vagrant', disabled: true # let phpstorm handle uploads; prevent vagrant from nuking your local files
config.vm.network :forwarded_port, guest: 35729, host: 35729 # livereload
config.vm.network :forwarded_port, guest: 3306, host: 3306 # mariadb
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 8081, host: 8081 # webpack-dev-server
config.vm.network :public_network #, bridge: "Intel(R) Ethernet Connection (2) I219-V" ip: "162.156.139.102", netmask: '255.255.255.0' # http://superuser.com/a/865947/5106
config.vm.hostname = 'kymarkbookings.dev'
config.vm.provider :virtualbox do |vb|
vb.gui = false # change to `true` if you get "Error: Connection timeout." while booting
vb.memory = 4096 # warning: this is higher than what our production server has
vb.cpus = 2
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
#config.vm.provision "shell", path: "vagrant-provision"
end
Pinging google.com should return a response.
What actually happened?
Network unreachable.
This is an inconsistent problem, so I can't provide steps that will always work
vagrant upvagrant sshping google.comi.e., just SSH into your vagrant box and check if you have internet.
None.
My motherboard has two ethernet ports. I only use one of them. Internet always works on my host OS, but more often than not when I SSH into my vagrantbox, it does not have internet. Running vagrant reload a few times usually works but it's extremely frustrating because I usually don't find out until my app does something that requires the internet and then errors out.
Virtualbox looks like its configured correctly:

That is the correct name of the adapter I'm using (Intel Ethernet), and Promiscuous Mode is set to "Allow All" so I don't know why it doesn't connect sometimes.
@mnpenner Hello.
Have a look at this:
https://www.vagrantup.com/docs/virtualbox/common-issues.html
the articlein SO shows this:
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
Its seems related to how host OS handle the dns.. more a Virtualbox setup rather than Vagrant.
Please feel free to reopen if you think this is a vagrant bug.
Thanks
@kikitux I do have that exact line in my Vagrantfile already, so I don't think that's it.
Today Vagrant/VirtualBox decided to be nice and connect. I'll come back to this the next time it fails and see if I can get some more info for you. I didn't try pinging 8.8.8.8 so I'm not sure if it's a DNS resolving issue, or something else.
Today it happened. I'm pasting the output of various random commands I found online to give you a better idea of what's going on.
vagrant@project:~$ ping google.com
connect: Network is unreachable
vagrant@project:~$ ping 8.8.8.8
connect: Network is unreachable
vagrant@project:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.0.2.3
nameserver 192.168.1.1
vagrant@project:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:5c:d2:2f brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:f0:80:7c brd ff:ff:ff:ff:ff:ff
vagrant@project:~$ sudo lshw -numeric -C network
*-network:0
description: Ethernet interface
product: 82540EM Gigabit Ethernet Controller [8086:100E]
vendor: Intel Corporation [8086]
physical id: 3
bus info: pci@0000:00:03.0
logical name: eth0
version: 02
serial: 08:00:27:5c:d2:2f
size: 1Gbit/s
capacity: 1Gbit/s
width: 32 bits
clock: 66MHz
capabilities: pm pcix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000 driverversion=7.3.21-k8-NAPI duplex=full ip=10.0.2.15 latency=64 link=yes mingnt=255 multicast=yes port=twisted pair speed=1Gbit/s
resources: irq:19 memory:f0000000-f001ffff ioport:d000(size=8)
*-network:1
description: Ethernet interface
product: 82540EM Gigabit Ethernet Controller [8086:100E]
vendor: Intel Corporation [8086]
physical id: 8
bus info: pci@0000:00:08.0
logical name: eth1
version: 02
serial: 08:00:27:f0:80:7c
size: 1Gbit/s
capacity: 1Gbit/s
width: 32 bits
clock: 66MHz
capabilities: pm pcix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000 driverversion=7.3.21-k8-NAPI duplex=full ip=192.168.1.33 latency=64 link=yes mingnt=255 multicast=yes port=twisted pair speed=1Gbit/s
resources: irq:16 memory:f0820000-f083ffff ioport:d040(size=8)
vagrant@project:~$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.675 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.434 ms
vagrant@project:~$ sudo ip route add default via 192.168.1.1
vagrant@project:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=60 time=5.72 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=60 time=6.18 ms
Looks like this command did the trick:
sudo ip route add default via 192.168.1.1
I'm not sure if that's a long-term solution though. Is there anything I need to do to make this 'stick'?
Even if I add this to my Vagrantfile:
config.vm.provision "shell", inline: "sudo ip route add default via 192.168.1.1"
It sometimes doesn't connect. Seems like a bug in vagrant to me. Maybe some kind of race condition.
got the same issue here but adding a route did not help.
I'm still experiencing this with Vagrant 2 and VirtualBox 5.2 too.
Chiming in here to also say I'm experiencing this. As @mnpenner said, I had this issue on 1.9. Upgraded Virtualbox to 5.2 and Vagrant to 2 and still getting this error.
I tried adding the vb.customize as suggested by @kikitux however does not resolve this issue for me.
Every time I start the machine with vagrant up I need to SSH into the machine and run sudo ip route add default via 192.168.1.1 dev eth1 which brings back network connectivity. As soon as I reboot the machine with vagrant halt and vagrant up, I lose internet access on the guest.
Right now, my machine is trying to update Virtualbox guest additions, but can't access the network, so it fails. Incase someone else gets stuck here, I had to set config.vbguest.auto_update = false in my Vagrantfile, then SSH into the guest machine and run ip route as above. The run vagrant vbguest to manually update the guest additions.
I'm having this issue too. After the initial box startup internet works without problems. But after vagrant halt and vagrant up the VM looses internet connectivity. After trying multiple configurations I found that this is a box related problem: I'm having this issue with the most recent _bento/ubuntu-16.04_ box but not with the _bento/ubuntu-14.04_ box. Also the problem does not happen with the _ubuntu/xenial64_ box (although, I have other problems with that box). I'll try some older version of _bento/ubuntu-16.04_ see if that also helps. My host is Windows 10, btw.
Edit:
Ok, using
config.vm.box = "bento/ubuntu-16.04"
config.vm.box_version = "2.3.5"
seems to solve this problem too. But anyway, strange behaviour...
This is still driving me bonkers. Is there anything I can do avoid having to run
sudo ip route add default via 192.168.1.1
Every time I vagrant up?
Have you tried maybe upgrading your Vagrant box? From what @rec00n was saying it seems like an issue with the box itself.
Alternatively, you could use this as a workaround and use the Vagrant triggers core feature to run a command after running vagrant up:
config.trigger.after :up do |trigger|
trigger.run_remote = {inline: "sudo ip route add default via 192.168.1.1"}
end
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Today it happened. I'm pasting the output of various random commands I found online to give you a better idea of what's going on.
Looks like this command did the trick:
credit
I'm not sure if that's a long-term solution though. Is there anything I need to do to make this 'stick'?